Skip to content

Instantly share code, notes, and snippets.

@taking
Last active May 12, 2022 00:41
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/ac709dff87bd33a7fe0ff1983cc4d948 to your computer and use it in GitHub Desktop.
Save taking/ac709dff87bd33a7fe0ff1983cc4d948 to your computer and use it in GitHub Desktop.
#!/bin/bash
## ROOT 계정으로 실행하기
## 21-03-02
#!/bin/bash
RED=`tput setaf 1`
GREEN=`tput setaf 2`
NC=`tput sgr0`
# Check permission
if [ "$EUID" -ne 0 ]
then echo "${RED}Please run as root ${NC}"
exit
fi
# ID 입력
read -p "username(not root): " uname
if [ -f /bin/python3 ]; then
echo 'python3 not installed'
if [ -f /etc/redhat-release ]; then
yum install python3
fi
if [ -f /etc/lsb-release ]; then
apt-get install python3
fi
else
echo 'python3 installed'
fi
################ add sudoers #################
SUDOERS_PATH="/etc/sudoers"
STRING="$( cat "$SUDOERS_PATH" )"
if [[ $STRING =~ "$uname" ]]; then
echo 'sudoers exist'
else
echo 'sudoers not exist'
cat <<EOT >> /etc/sudoers
$uname ALL=(ALL) NOPASSWD: ALL
EOT
echo 'edit /etc/sudoers'
echo 'add sudoers list'
fi
###########################################
############### ZSH Setup #################
###########################################
if [ -d /root/.oh-my-zsh ]; then
echo 'zsh installed'
else
echo 'zsh installing'
if [ -f /etc/redhat-release ]; then
yum install zsh -y && chsh -s `which zsh`
fi
if [ -f /etc/lsb-release ]; then
apt-get install zsh -y && chsh -s `which zsh`
fi
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'
fi
###########################################
############## zsh setting ################
###########################################
wget -O $HOME/.zshrc 'https://gist.github.com/taking/1a03b19d580dda6376300d865b19b443/raw/8ce35f88c71b28a80d99dc2cb6410dccacdcf890/.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 의 shell 변경을 위해 암호를 입력하세요 :'
su -c 'chsh -s `which zsh`' - $uname
@taking
Copy link
Author

taking commented May 11, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment