Skip to content

Instantly share code, notes, and snippets.

@mickours
Last active December 15, 2015 04:59
Show Gist options
  • Save mickours/5205750 to your computer and use it in GitHub Desktop.
Save mickours/5205750 to your computer and use it in GitHub Desktop.
Bash script to configure a debian-based distribution (like ubutnu) It checks the user rights and install the package only if necessary
#!/bin/bash
#################################
# Config script for Ubuntu #
#################################
# exit if error
set -e
# check rights
if [ "$(whoami)" != "root" ]; then
echo "ERROR: You must be root to run this script. Try:
sudo $0 $1"
exit 1
fi
### SETTINGS ###
# Add wathever you what to install
TO_ADD_REPO="ppa:webupd8team/sublime-text-2"
TO_INSTALL="zsh terminator git sublime-text"
### UTILS ###
install(){
if ! dpkg-query -Wf'${db:Status-abbrev}' $1 2>/dev/null; then
apt-get install $1
fi
}
### MAIN ###
add-apt-repository $TO_ADD_REPO
apt-get update
install $TO_INSTALL
#zsh conf
ZSH_PATH=$(which zsh)
if [ $? -eq 1 ]; then
chsh $USER -s ZSH_PATH
wget -O .zshrc http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
fi
### END ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment