Skip to content

Instantly share code, notes, and snippets.

@taking
Last active March 25, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taking/ca285cfccec35ce71e7a83d180481e75 to your computer and use it in GitHub Desktop.
Save taking/ca285cfccec35ce71e7a83d180481e75 to your computer and use it in GitHub Desktop.
#!/bin/sh
## 20-03-25
## CentOS 7 기준
## ROOT 계정으로 실행하기
###########################################
read -p "hostname (ex testdev, dont use UNDER BAR): " uhost
read -p "username(not root): " uname
############ nameserver setting ###############
cat <<EOT > /etc/resolv.conf
search UHOSTNAME
;KT DNS
;nameserver 168.126.63.1
;nameserver 168.126.63.2
;Google DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
; LG Uplus
;nameserver 180.182.54.1
;nameserver 210.94.0.73
EOT
sed -i "s/UHOSTNAME/$uhost/g" /etc/resolv.conf
echo 'Edit /etc/resolv.conf Success'
############ language change ###############
localedef -c -i ko_KR -f UTF-8 ko_KR.utf8
localectl set-locale LANG=ko_KR.utf8
service network restart
echo 'service network restart Success'
############### Timezone ###################
timedatectl set-timezone Asia/Seoul
echo 'timezone Change Success'
############ hostname change ###############
hostnamectl set-hostname $uhost
echo 'Hostname Change Success'
##### remove #######
systemctl stop postfix firewalld NetworkManager
systemctl disable postfix firewalld NetworkManager
systemctl mask NetworkManager
yum remove -y postfix NetworkManager NetworkManager-libnm
##### firewalld disable, selinux disable, csf install #######
sed -i 's/enforcing/disabled/g' /etc/sysconfig/selinux
setenforce 0
getenforce
systemctl stop firewalld && systemctl disable firewalld
iptable -F
################## Setup ##################
echo '[base]
name=CentOS-$releasever - Base
baseurl=http://ftp.daumkakao.com/centos/$releasever/os/$basearch/
gpgcheck=0
[updates]
name=CentOS-$releasever - Updates
baseurl=http://ftp.daumkakao.com/centos/$releasever/updates/$basearch/
gpgcheck=0
[extras]
name=CentOS-$releasever - Extras
baseurl=http://ftp.daumkakao.com/centos/$releasever/extras/$basearch/
gpgcheck=0' > /etc/yum.repos.d/Daum.repo
echo 'Edit /etc/yum.repos.d/Daum.repo'
echo 'repository edit Success'
yum update -y
yum install epel-release -y
yum install net-tools vim curl git wget openssh openssh-server openssh-clients openssl-libs nmap ntpdate -y
dnf groupinstall "Fonts" "Korean Support" -y
echo 'ifconfig, vim, samba, curl, git, wget, openssh, nmap, Korean Support install Success'
yum install -y centos-release-openstack-queens.noarch
yum install -y openstack-utils openstack-selinux
yum install -y openstack-packstack
yum downgrade -y leatherman
ntpdate pool.ntp.org
cd ~
packstack --gen-answer-file=~/my.conf
sed -i 's/CONFIG_NTP_SERVERS=/CONFIG_NTP_SERVERS=pool.ntp.org/g' ~/my.conf
echo 'packstack --answer-file=my.conf' > ~/readme.txt
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
rm -rf ~/get-pip.py
############# openssh setting #############
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/\#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/\#ListenAddress 0\.0\.0\.0/ListenAddress 0\.0\.0\.0/g' /etc/ssh/sshd_config
sed -i 's/\#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
sed -i 's/\X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
sed -i 's/\#X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
cat <<EOT >> /etc/ssh/sshd_config
#AllowUsers USERNAME
ClientAliveInterval 3600
ClientAliveCountMax 120
PrintMotd no
EOT
#sed -i "s/USERNAME/$uname/g" /etc/ssh/sshd_config
echo 'Edit /etc/ssh/sshd_config'
systemctl enable sshd.service
service sshd restart
echo 'service sshd restart Success'
################ add sudoers #################
cat <<EOT >> /etc/sudoers
$uname ALL=(ALL) NOPASSWD: ALL
EOT
echo 'edit /etc/sudoers'
echo 'add sudoers list'
###########################################
############### ZSH Setup #################
###########################################
yum install zsh -y && chsh -s `which zsh`
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
git clone https://github.com/powerline/fonts.git && ./fonts/install.sh && rm -rf ~/fonts
cd $HOME/.oh-my-zsh/custom/plugins && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git && git clone https://github.com/zsh-users/zsh-autosuggestions && git clone https://github.com/djui/alias-tips.git
echo 'zsh shell install Success'
echo 'oh-my-zsh, plugins install Success'
###########################################
############## zsh setting ################
###########################################
wget -O $HOME/.zshrc 'https://gist.githubusercontent.com/taking/1a03b19d580dda6376300d865b19b443/raw/f817dc5e32d0c61797cc6ef7c86862d6a6c5ff55/.zshrc%2520(linux)'
chsh -s `which zsh`
echo 'edit ~/.zsh'
echo 'zsh setting edit Success'
###########################################
######## new account zsh setting ##########
###########################################
cp $HOME/.zshrc /home/$uname/
cp -r $HOME/.oh-my-zsh /home/$uname/
chown -R $uname:$uname /home/$uname/
echo '$uname input passwd :'
su -c 'chsh -s `which zsh`' - $uname
###########################################
############## vim Setting ################
###########################################
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
mkdir $HOME/.vim/colors/
curl -G https://raw.githubusercontent.com/ErichDonGubler/vim-sublime-monokai/master/colors/sublimemonokai.vim -o $HOME/.vim/colors/sublimemonokai.vim
wget -O $HOME/.vimrc https://gist.github.com/taking/2d762c0d0a63120ace2fa3b87bf262e5/raw/bcf8e9c29730d20459d9f458d8af7361f2fba9b8/.vimrc
vim +PluginInstall +qall
cp $HOME/.vimrc /home/$uname/
cp -r $HOME/.vim /home/$uname/
chown -R $uname:$uname /home/$uname/
su -c 'vim +PluginInstall +qall' - $uname
echo 'setting okay.\n'
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment