Skip to content

Instantly share code, notes, and snippets.

@dmonllao
Created May 25, 2016 06:33
Show Gist options
  • Select an option

  • Save dmonllao/6603968430f152e9d5038bdcfe152117 to your computer and use it in GitHub Desktop.

Select an option

Save dmonllao/6603968430f152e9d5038bdcfe152117 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
UBUNTURELEASE="ubuntu-trusty"
GITUSERNAME="David Monllao"
GITUSEREMAIL="[email protected]"
DBPASSWORD="moodle"
USERSTUFFDIR=$HOME'/opt'
# Install basic stuff.
sudo apt-get install -y firefox zsh curl git-core pidgin xvfb synaptic ctags cscope vim-gtk xclip skype gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly
# SSH keys.
if [ ! -f ~/.ssh/id_rsa ]; then
# Create ssh key, always using [email protected]
ssh-keygen -t rsa -b 4096 -C "[email protected]"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# Already copied to the clipboard.
xclip -sel clip < ~/.ssh/id_rsa.pub
while [[ "$CONFIRM" != "y" ]]; do
read -s -p "Set your new SSH key (you have it copied in the clipboard) in:
- https://github.com/settings/keys
- https://bitbucket.org/account/user/dmonllao/ssh-keys/
- https://git.in.moodle.com/profile/keys
[y]: `echo $'\n> '`" CONFIRM
done
fi
# Install lastpass in the browser.
while [[ "$CONFIRM" != "y" ]]; do
read -s -p "Install lastpass extension in your browser. Set 'Automatically log out the all browsers closed for 5 mins' [y]: `echo $'\n> '`" CONFIRM
done
# Install vimium too.
while [[ "$CONFIRM" != "y" ]]; do
read -s -p "Install vimium in your browser/s' [y]: `echo $'\n> '`" CONFIRM
done
# Set git stuff
git config --global user.name $GITUSERNAME
git config --global user.email $GITUSEREMAIL
# Web server.
sudo apt-get install -y php5-dev php5-curl php5-gd php5-ldap php5-mcrypt php5-memcache php5-memcached php5-mysql php5-pgsql php5-mongo php5-radius php5-redis php5-xdebug php5-xhprof php5-xmlrpc php5-xsl apache2 libapache2-mod-php5
# Postgres.
sudo apt-get install -y postgresql-9.3 pgadmin3
if [ ! -f "/etc/postgresql/9.3/main/pg_hba.conf.bak" ]; then
sudo -u postgres psql -U postgres -c "alter user postgres with password '$DBPASSWORD';"
sudo sed -i.bak 's/local *all *postgres *peer/local all postgres md5/g' /etc/postgresql/9.3/main/pg_hba.conf
sudo service postgresql restart
fi
# Vim-IDE.
if [ ! -d ~/.vim/bundle/IDE ]; then
cd ~/.vim || mkdir ~/.vim
git clone [email protected]:dmonllao/vim-IDE.git .
mv ~/.vimrc ~/.vimrc.backup ||
ln -s ~/.vim/.vimrc ~/.vimrc
git submodule init
git submodule update
# Set my personal options
cp ~/.vim/custom.vim.dist ~/.vim/custom.vim
sed -i.bak 's/" *let *g:IDEOnlyEditor *= *0/let g:IDEOnlyEditor = 1/g' ~/.vim/custom.vim
rm ~/.vim/custom.vim.bak
fi
# Other stuff.
if [ ! -d $USERSTUFFDIR ]; then
mkdir $USERSTUFFDIR
cd $HOME/Downloads
fi
# Node.js
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Docker (from https://docs.docker.com/engine/installation/linux/ubuntulinux/).
sudo apt-get install -y apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
echo "deb https://apt.dockerproject.org/repo $UBUNTURELEASE main" | sudo tee -a /etc/apt/sources.list.d/docker.list
fi
sudo apt-get update
sudo apt-get install -y docker-engine
# Add the system user to the docker group.
sudo usermod -aG docker $USER
# Some docker containers using always sudo as we would need to log out $USER to reload groups.
if [[ -z "$(sudo docker images | grep '^memcached\s')" ]]; then
sudo docker run --name sessions-memcache -d memcached
sudo docker run --name cache-memcache -d memcached
fi
if [[ -z "$(sudo docker images | grep '^mysql/mysql-server\s')" ]]; then
sudo docker run --name=mysql -e MYSQL_ROOT_PASSWORD="$DBPASSWORD" -e MYSQL_DATABASE=moodle -e MYSQL_USER=moodle -e MYSQL_PASSWORD="$DBPASSWORD" -p 3306:3306 -d mysql/mysql-server:latest
fi
if [[ -z "$(sudo docker images | grep '^mariadb\s')" ]]; then
sudo docker run --name mariadb -e MYSQL_ROOT_PASSWORD="$DBPASSWORD" -e MYSQL_DATABASE=moodle -e MYSQL_USER=moodle -e MYSQL_PASSWORD="$DBPASSWORD" -p 3306:3306 -d mariadb:latest
fi
# Oh my zsh.
if [ ! -d ~/.oh-my-zsh ]; then
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
# And set it as default (once the computer is restarted).
chsh -s $(which zsh)
fi
# Selenium.
if [ ! -f $USERSTUFFDIR/selenium-server-standalone.jar ]; then
wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar
mv selenium-server-standalone-2.53.0.jar $USERSTUFFDIR/selenium-server-standalone-2.53.0.jar
ln -s $USERSTUFFDIR/selenium-server-standalone-2.53.0.jar $USERSTUFFDIR/selenium-server-standalone.jar
fi
if [ ! -f $USERSTUFFDIR/chromedriver ]; then
wget http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
unzip chromedriver_linux64.zip -d $USERSTUFFDIR/
fi
if [ ! -d $USERSTUFFDIR/phantomjs ]; then
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar -xf phantomjs-2.1.1-linux-x86_64.tar.bz2 $USERSTUFFDIR/
ln -s $USERSTUFFDIR/phantomjs-2.1.1-linux-x86_64 $USERSTUFFDIR/phantomjs
fi
# My aliases also linked for zsh.
if [ ! -f $USERSTUFFDIR/.bash_aliases/.bash_aliases ]; then
git clone [email protected]:dmonllao/.bash_aliases.git $USERSTUFFDIR/.bash_aliases
if [ -f ~/.bash_aliases ] || [ ! -h ~/.bash_aliases ]; then
# Backup the aliases file if it is not a symlink.
mv ~/.bash_aliases ~/.bash_aliases.bak
fi
ln -s $USERSTUFFDIR/.bash_aliases/.bash_aliases $HOME/.bash_aliases
echo "source $HOME/.bash_aliases" >> ~/.zshrc
fi
# Setting up mdlrelease, mdk, integration repo and security repo.
if [ ! -d $USERSTUFFDIR/mdlrelease ]; then
mkdir $USERSTUFFDIR/mdlrelease && cd $USERSTUFFDIR/mdlrelease && git init
git remote add origin [email protected]:dmonllao/mdlrelease.git
git remote add upstream git://github.com/moodlehq/mdlrelease.git
git fetch origin && git fetch upstream && git checkout -B master upstream/master
fi
if [ ! -d $USERSTUFFDIR/mdk ]; then
mkdir $USERSTUFFDIR/mdk && cd $USERSTUFFDIR/mdk && git init
git remote add origin [email protected]:dmonllao/mdk.git
git remote add upstream git://github.com/FMCorz/mdk.git
git fetch origin && git fetch upstream && git checkout -B master origin/master && git rebase upstream/master
# And install mdk.
sudo apt-get install -y python-pip libmysqlclient-dev libpq-dev python-dev
sudo pip install moodle-sdk
fi
if [ ! -d $USERSTUFFDIR/push_int ]; then
mkdir $USERSTUFFDIR/push_int && cd $USERSTUFFDIR/push_int && git init
git remote add origin [email protected]:moodle/integration.git
git fetch origin && git checkout master
fi
if [ ! -d $USERSTUFFDIR/push_sec ]; then
mkdir $USERSTUFFDIR/push_sec && cd $USERSTUFFDIR/push_sec && git init
git remote add security [email protected]:integration/moodle-security.git
git fetch security && git checkout master
fi
# Init moodle.
if [ ! -d $USERSTUFFDIR/init-moodle ]; then
git clone [email protected]:dmonllao/init-moodle.git $USERSTUFFDIR/init-moodle
cd $USERSTUFFDIR/init-moodle
cp config.properties.dist config.properties
while [[ "$CONFIRM" != "y" ]]; do
read -s -p "Set your postgres password in $USERSTUFFDIR/init-moodle/config.properties and check that all values are fine [y]: `echo $'\n> '`" CONFIRM
done
fi
# Telegram not in user stuff as it is not only for dev.
if [ ! -d ~/Telegram ]; then
wget -qO- https://tdesktop.com/linux | tar -C $HOME/Telegram -xJ
$HOME/Telegram/Telegram &> /dev/null &
fi
echo "All automated tasks done, now some manual tasks and we finished:
* Nice Laia background
* Set console default profile
** Transparent background to around 75%
** Use custom default terminal size to huge
* Cleanup links to the launcher and add: terminal, pgadmin, pidgin, telegram, synaptic, firefox, rhythmbox
* Setup pidgin & OTR conversations plugin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment