Skip to content

Instantly share code, notes, and snippets.

@Gohan
Last active August 29, 2015 14:00
Show Gist options
  • Save Gohan/11315091 to your computer and use it in GitHub Desktop.
Save Gohan/11315091 to your computer and use it in GitHub Desktop.
Ubuntu 12.04 bootstrap
#!/bin/bash
function Add_Sudo_NoPass {
echo "Add Sudo NoPass Option";
if [ -f "/etc/sudoers.tmp" ]; then
exit 1
fi
sudo touch /etc/sudoers.tmp
# Set default nopass for sudo
sudo cat /etc/sudoers | sed 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD:ALL/g' | tee /tmp/sudoers.new > /dev/null
sudo visudo -c -f /tmp/sudoers.new
if [ "$?" -eq "0" ]; then
sudo cp /tmp/sudoers.new /etc/sudoers
fi
sudo rm /etc/sudoers.tmp
rm /tmp/sudoers.new
}
function SetUp_Locales {
cd /usr/share/locales/
sudo ./install-language-pack zh_CN
sudo ./install-language-pack en_US
sudo locale-gen --purge zh_CN.UTF-8 en_US.UTF-8
sudo tee /etc/default/locale <<EOF > /dev/null
LC_CTYPE="zh_CN.UTF-8"
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
EOF
#sudo sed -i -e 's/^LC_CTYPE=.*/LC_CTYPE=zh_CN.UTF-8/; t; $aLC_CTYPE=zh_CN.UTF-8' /etc/default/locale
#sudo sed -i -e 's/^LANG=.*/LANG=en_US.UTF-8/; t; $aLANG=en_US.UTF-8' /etc/default/locale
export LC_CTYPE=zh_CN.UTF-8
export LANG=en_US.UTF-8
}
Add_Sudo_NoPass;
SetUp_Locales;
# install minimal ubuntu
sudo apt-get update
sudo apt-get install -y aptitude ubuntu-minimal
sudo aptitude markauto '~i!~nubuntu-minimal'
# install wget/openssh-server
sudo apt-get -y install wget openssh-server
# install salt-stack
wget -O - http://bootstrap.saltstack.org | sudo sh
# set salt-master
echo -n Set Salt-Master hostname:
read SALT_MASTER
echo master: ${SALT_MASTER} > /etc/salt/minion.d/100.master_settings.conf
# fix openvz
sudo sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf
sudo service rsyslog restart
# install wget
sudo apt-get -y install wget
# install salt-stack
wget -O - http://bootstrap.saltstack.org | sudo sh
# set salt-minion_id
echo -n Set Salt-Minion ID:
read SALT_MINION
echo ${SALT_MINION} > /etc/salt/minion_id
# set salt-master
echo -n Set Salt-Master hostname:
read SALT_MASTER
echo master: ${SALT_MASTER} > /etc/salt/minion.d/100.master_settings.conf
# install wget
sudo apt-get -y install wget ca-certificates
wget -O install.sh https://raw.github.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh
bash install.sh
# set salt-minion_id
echo -n Set Salt-Minion ID:
read SALT_MINION
echo ${SALT_MINION} > /etc/salt/minion_id
# set salt-master
echo -n Set Salt-Master hostname:
read SALT_MASTER
echo master: ${SALT_MASTER} > /etc/salt/minion.d/100.master_settings.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment