Skip to content

Instantly share code, notes, and snippets.

@laobubu
Last active July 13, 2016 16:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save laobubu/4596ba6cf018e334a79c to your computer and use it in GitHub Desktop.
Save laobubu/4596ba6cf018e334a79c to your computer and use it in GitHub Desktop.
Customize a newly-installed Ubuntu, easily.
#!/bin/bash
#-----------------------------------------
# Personal PC Setup
#-----------------------------------------
# Warning:
# Modify this script to make it work for you properly.
# The author makes no warranty or guarantee.
#-----------------------------------------
# What does this do
# - Install `apt-fast screen aria2c`
# - Install `git vim gvim python-pip`
# - (optional) Install Google Chrome and/or shadowsocks
# - Make grub2 remember your last choose
# - Run `sudo` without password (only current user)
# - Use English directory name and things will be easy in Terminal.
# - Use `DejaVuSansMono`, instead of `DroidSansFallback`, as the monospace font.
# - Make vim/gvim looks better.
#-----------------------------------------
# Author
# Twitter/GitHub/V2EX @laobubu
COLOR='\033[1;33m'
NC='\033[0m' # No Color
if [[ "$(whoami)" != "root" ]]; then
echo "root user is required"
exit 1
fi
function let_us() {
echo -e "${COLOR}$*${NC}"
#tell user what's going on
}
function confirm() {
echo -e -n "${COLOR}$*${NC} (y/N):"
read -t 15 rr
[[ "$rr" =~ y|Y ]]
return $?
}
#Find current username
HOMEUSER="$(ls -1 /home)"
ORIGLANG=$LANG
NO_DESKTOP=$([ "$DESKTOP_SESSION" ]; echo $?)
############## APP INSTALL
let_us install apt-fast aria2c and scren
add-apt-repository ppa:saiarcot895/myppa
apt-get update
apt-get -y install apt-fast screen
let_us install necessary apps
apt-fast install -y git vim python3-pip python-pip
if [ NO_DESKTOP == 0 ]
then
let_us install Desktop Apps
apt-fast install -y vim-gtk
let_us install Google Chrome
if confirm "Install Google Chrome (stable,amd64)?"
then
GOOGLE_CHROME_DEB=/tmp/google.deb
aria2c -x 10 -o $GOOGLE_CHROME_DEB 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'
dpkg -i $GOOGLE_CHROME_DEB
apt-get -f install
rm $GOOGLE_CHROME_DEB
fi
fi
let_us install shadowsocks
if confirm "Install Shadowsocks?"
then
SS_CONF=/etc/shadowsocks.json
SS_LOCAL_COMMAND="sslocal -d start -c $SS_CONF"
pip install shadowsocks
>$SS_CONF cat <<EOF
{
"server":"?",
"server_port":8388,
"local_port":1080,
"password":"?",
"timeout":600,
"method":"aes-256-cfb"
}
EOF
nano $SS_CONF
$SS_LOCAL_COMMAND
echo "The shadowsocks command is running: $SS_LOCAL_COMMAND"
echo " and it will start automatically."
sed -i -e "/^exit 0$/i $SS_LOCAL_COMMAND" /etc/rc.local
fi
############### USER/SYS CONFIG
let_us make grub remember the last choose
sed /etc/default/grub -i \
-e 's/GRUB_DEFAULT=0/GRUB_DEFAULT=saved\nGRUB_SAVEDEFAULT=true/' \
-e 's/GRUB_TIMEOUT=.\+/GRUB_TIMEOUT=3/'
update-grub
grub-reboot 0
if confirm "Execute sudo without password for ${HOMEUSER}?"
then
echo "${HOMEUSER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
fi
let_us use English Directory Names
export LANG=en_US
xdg-user-dirs-update
su $HOMEUSER -c xdg-user-dirs-update
export LANG=$ORIGLANG
if confirm "Use DejaVu Sans Mono as Latin Monospace instead of DroidSans?"
then
let_us fix monospace font problem
sed -i -e '/monospace/,/Droid/{/Droid/i<string>DejaVu Sans Mono</string>
}' /etc/fonts/conf.d/*-language-selector-zh-cn.conf
fi
############### VIM
let_us configure vimrc
>>/etc/vim/vimrc cat<<END_OF_VIMRC
colorscheme desert
set guifont=DejaVu\ Sans\ Mono\ 12
set tabstop=2
END_OF_VIMRC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment