Skip to content

Instantly share code, notes, and snippets.

@simonmysun
Last active August 29, 2015 14:20
Show Gist options
  • Save simonmysun/79a49b609be0df3cea52 to your computer and use it in GitHub Desktop.
Save simonmysun/79a49b609be0df3cea52 to your computer and use it in GitHub Desktop.
My install script for debian
#!/bin/bash
set -eu
trap 'roll_back' INT TERM
alias apt-get='apt-get -y'
rand=$RANDOM;
mkdir tmp_install_$rand;
cd tmp_install_$rand;
function show_menu() {
echo -e "*********************************************";
echo -e "Install Script";
echo -e "*********************************************";
echo -e "0. Add parrot source";
echo -e "1. Install C-dev";
echo -e "2. Install Py-dev";
echo -e "3. Install basic tools";
echo -e "4. Install Ruby-dev";
echo -e "5. Install Node-dev";
echo -e "6. Install GFW tools";
echo -e "7. Install Web tools";
echo -e "8. Install Tex live";
echo -e "9. Install configs";
echo -e "*********************************************";
echo -e "Please enter menu options and enter or press enter to exit. ";
echo -e "e.g. '1235679'. ";
read opt;
}
function init() {
apt-get update;
apt-get upgrade;
apt-get dist-upgrade;
}
function add_parrot_source() {
echo -e "deb http://eu.repository.frozenbox.org/mirrors/parrot stable main contrib non-free" > /etc/apt/sources.list.d/parrot.list;
echo -e "deb http://eu.repository.frozenbox.org/mirrors/debian stable main contrib non-free\n#deb-src http://eu.repository.frozenbox.org/mirrors/debian stable main contrib non-free\n\n#deb http://eu.repository.frozenbox.org/mirrors/debian wheezy-backports main contrib non-free\n#deb-src http://eu.repository.frozenbox.org/mirrors/debian wheezy-backports main contrib non-free\n\ndeb http://security.debian.org/ wheezy/updates main\n#deb-src http://security.debian.org/ wheezy/updates main\n\ndeb http://eu.repository.frozenbox.org/mirrors/debian stable-updates main contrib non-free\n#deb-src http://eu.repository.frozenbox.org/mirrors/debian stable-updates main contrib non-free\n\n#deb http://eu.repository.frozenbox.org/mirrors/debian wheezy-proposed-updates main contrib non-free\n#deb-src http://eu.repository.frozenbox.org/mirrors/debian stable-updates main contrib non-free" >> /etc/apt/sources.list.d/debian.list;
wget -qO - http://repository.frozenbox.org/parrot/frozenbox.gpg.key | apt-key add -;
apt-get update;
apt-get dist-upgrade;
}
function install_c() {
apt-get install build-essential gdb codeblocks;
}
function install_py() {
apt-get install python python-pip python-m2crypto;
pip install --upgrade distribute;
pip install pygments;
}
function install_basic_tools() {
apt-get install emacs vim git fakeroot libssl-dev curl ssh chrpath libxft-dev wget x11-xserver-utils wireshark rhythmbox vlc pandoc xfonts-intl-chinese xfonts-wqy ibus-pinyin supervisor ttf-arphic-uming;
aptitude install gimp;
}
function install_ruby() {
apt-get install ruby irb rdoc ruby-dev gem;
gem update --system;
gem install rdiscount RedCloth jekyll;
}
function install_node() {
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc;
echo 'export NODE_PATH=$HOME/local/lib/node_modules' >> ~/.bashrc;
. ~/.bashrc;
mkdir -p ~/local;
mkdir -p node-latest-install;
cd node-latest-install;
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1;
./configure --prefix=~/local; # if SSL support is not required, use --without-ssl
make;
make install;
npm install -g harp;
npm install -g grunt-cli;
npm install -g bower;
apt-get install libfreetype6 libfreetype6-dev;
apt-get installn libfontconfig1 libfontconfig1-dev;
npm install -g phantomjs;
}
function install_gfw() {
pip install shadowsocks;
echo -e "\
{\n\
\"server\":\"0.0.0.0\",\n\
\"server_port\":7325,\n\
\"local_port\":1080,\n\
\"password\":\"my password\",\n\
\"timeout\":600,\n\
\"method\":\"aes-256-cfb\"\n\
}\n\
" > /etc/shadowsocks.json;
echo -e "\n\
[program:shadowsocks]\n\
command=sslocal -c /etc/shadowsocks.json\n\
autorestart=true\n\
user=nobody\n\n\
" >> /etc/supervisor/conf.d/shadowsocks.conf;
echo "ulimit -n 51200" >> /etc/default/supervisor;
service supervisor start;
supervisorctl reload;
apt-get install proxychains; # edit /etc/proxychains.conf
}
function install_web() {
aptitude install iceweasel;
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb;
dpkg -i google-chrome-*.deb;
apt-get install -f;
}
function install_tex() {
apt-get install calibre wget texlive-full imagemagick dvipdfmx cjk-latex latex-cjk-all texmaker xfonts-wqy msttcorefonts;
# apt-get install ttf-baekmuk ttf-kochi-gothic ttf-kochi-mincho ttf-sazanami-gothic ttf-sazanami-mincho; # Japanese and Korean fonts;
}
function install_configs() {
sh -c 'echo en_US.ISO-8859-1 ISO-8859-1 >> /var/lib/locales/supported.d/local';
sh -c 'echo zh_CN.GBK GBK >> /var/lib/locales/supported.d/local';
sh -c 'echo en_US.ISO-zh_CN.GB2312 GB2312 >> /var/lib/locales/supported.d/local';
dpkg-reconfigure locales;
}
function roll_back() {
echo -e "\nError occured(or maybe just interrupted)! Rolling back...";
sleep 1;
echo "Sorry. No roll back script is written. ";
exit 2;
}
if [ `whoami` == "root" ]; then
clear;
show_menu;
if [[ "$(echo opt | grep "0")" != "" ]]
then
init;
add_parrot_source;
fi
if [[ "$(echo opt | grep "1")" != "" ]]
then
install_c;
fi
if [[ "$(echo opt | grep "2")" != "" ]]
then
install_py;
fi
if [[ "$(echo opt | grep "3")" != "" ]]
then
install_basic_tools;
fi
if [[ "$(echo opt | grep "4")" != "" ]]
then
install_ruby;
fi
if [[ "$(echo opt | grep "5")" != "" ]]
then
install_node;
fi
if [[ "$(echo opt | grep "6")" != "" ]]
then
install_gfw;
fi
if [[ "$(echo opt | grep "7")" != "" ]]
then
install_web;
fi
if [[ "$(echo opt | grep "8")" != "" ]]
then
install_tex;
fi
if [[ "$(echo opt | grep "9")" != "" ]]
then
install_configs;
fi
else
echo "This script needs to be run as root!";
fi
rm -rf tmp_install_$rand;
unalias apt-get;
trap - SIGINT SIGQUIT SIGTSTP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment