Last active
March 2, 2016 09:15
-
-
Save ecpplus/24682a670c4f0f52cc12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
############################### | |
# setup script for CentOS7 | |
# - Run as root | |
# - Don't forget to set $USER | |
# export USER=hoge | |
############################### | |
if [ "${ADMINUSER-undefined}" = "undefined" ]; then | |
echo '\n[ERROR] set $USER before you run this scirpt!' | |
exit 0 | |
fi | |
# installpackages | |
sudo yum update -y | |
sudo yum upgrade -y | |
sudo yum localinstall -y http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm | |
sudo yum install -y git zsh tmux bzip2 gcc make readline-devel openssl-devel mysql-community-devel mysql-community-server | |
# mysqld | |
sudo systemctl enable mysqld.service | |
sudo systemctl start mysqld.service | |
# add deploy user | |
sudo useradd -m deploy -s /bin/zsh | |
sudo mkdir /home/deploy/.ssh | |
sudo sh -c "curl -s https://github.com/ecpplus.keys > /home/deploy/.ssh/authorized_keys" | |
sudo chmod -R 700 /home/deploy/.ssh | |
sudo chown -R deploy:deploy /home/deploy/.ssh | |
# make deployment directories | |
sudo mkdir -p /srv/www | |
sudo chown deploy:deploy /srv/www | |
#admin user | |
sudo useradd -m $ADMINUSER -s /bin/zsh | |
sudo mkdir /home/$ADMINUSER/.ssh | |
sudo sh -c "curl -s https://github.com/ecpplus.keys > /home/$ADMINUSER/.ssh/authorized_keys" | |
sudo chmod -R 700 /home/$ADMINUSER/.ssh | |
sudo chown -R $ADMINUSER:$ADMINUSER /home/$ADMINUSER/.ssh | |
#zsh | |
su - deploy -c "git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh" | |
su - deploy -c "sed -i -e 's/.*ZSH_THEME.*/ZSH_THEME=\"maran\"/g' ~/.zshrc" | |
su - $ADMINUSER -c "git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh" | |
su - $ADMINUSER -c "sed -i -e 's/.*ZSH_THEME.*/ZSH_THEME=\"maran\"/g' ~/.zshrc" | |
# tmux | |
su - $ADMINUSER -c "curl https://gist.githubusercontent.com/ecpplus/f42e81793c6508cb5349/raw/9d55da6433bf85c0e669f1b91dd44d559299a155/.tmux.conf > /home/$ADMINUSER/.tmux.conf" | |
su - deploy -c "curl https://gist.githubusercontent.com/ecpplus/f42e81793c6508cb5349/raw/9d55da6433bf85c0e669f1b91dd44d559299a155/.tmux.conf > /home/deploy/.tmux.conf" | |
# rbenv | |
su - deploy -c "git clone https://github.com/rbenv/rbenv.git ~/.rbenv" | |
su - deploy -c "git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build" | |
sudo echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> /home/deploy/.zshrc | |
sudo echo 'eval "$(rbenv init -)"' >> /home/deploy/.zshrc | |
su - deploy -c "source ~/.zshrc && rbenv install 2.3.0" | |
su - deploy -c "source ~/.zshrc && rbenv global 2.3.0" | |
# result | |
sudo cat /var/log/mysqld.log| grep password|grep generated # show mysql initial password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CentOS
usermod -aG wheel {user}
sh -c "$(curl -fsSL https://gist.githubusercontent.com/ecpplus/24682a670c4f0f52cc12/raw)"