Skip to content

Instantly share code, notes, and snippets.

@nathanhaigh
Created November 3, 2012 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanhaigh/4007408 to your computer and use it in GitHub Desktop.
Save nathanhaigh/4007408 to your computer and use it in GitHub Desktop.
Script to take deploy the ACAD workshop to the NGSTrainingV1.2 image.
#!/bin/bash
export WORKSHOP_NAME="ACAD"
export PARENT_DIR="/mnt"
export SUDO_USER="ubuntu"
export TRAINEE_USER="ngstrainee"
export TMPDIR=/mnt/tmp
# set the timezone
TZ="Australia/Adelaide"
echo "$TZ" > /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata
mkdir --mode=777 $TMPDIR
mkdir -p $PARENT_DIR/$WORKSHOP_NAME/{tools,working_dir}
mkdir -p $PARENT_DIR/$WORKSHOP_NAME/working_dir/{Mon,Tue,Wed,Thu,Fri}
chown -R $TRAINEE_USER $PARENT_DIR/$WORKSHOP_NAME/working_dir
# install some additional tools for Tue Hands-on
cd $TMPDIR; wget http://pysam.googlecode.com/files/pysam-0.6.tar.gz
tar -zxf pysam-0.6.tar.gz
python setup.py install
easy_install https://bitbucket.org/james_taylor/bx-python/get/tip.tar.bz2
# set things up from the trainee's perspective
sudo su $TRAINEE_USER
# Home and Desktop symlinks to the workshop's working directory
ln -s $PARENT_DIR/$WORKSHOP_NAME/working_dir /home/$TRAINEE_USER/$WORKSHOP_NAME
if [[ ! -e "/home/$TRAINEE_USER/Desktop" ]]; then
mkdir --mode=755 /home/$TRAINEE_USER/Desktop
fi
ln -s $PARENT_DIR/$WORKSHOP_NAME/working_dir /home/$TRAINEE_USER/Desktop/$WORKSHOP_NAME
echo "[Desktop Entry]
Name=ACAD dropcanvas
Type=Application
Encoding=UTF-8
Comment=A dropcanvas for ACAD workshop materials
Exec=firefox http://dropcanvas.com/g7Nm41a398087J
Icon=/usr/lib/firefox/icons/mozicon128.png
Terminal=FALSE" > /home/$TRAINEE_USER/Desktop/ACADdropcanvas.desktop
chmod 700 /home/$TRAINEE_USER/Desktop/ACADdropcanvas.desktop
chown $TRAINEE_USER:$TRAINEE_USER /home/$TRAINEE_USER/Desktop/ACADdropcanvas.desktop
###############
# Setup for Mon
###############
day="Mon"
container="ACAD_$day"
cd $PARENT_DIR/$WORKSHOP_NAME/working_dir/$day
wget https://swift.rc.nectar.org.au:8888/v1/AUTH_33065ff5c34a4652aa2fefb292b3195a/$container/Commandline.zip && unzip Commandline.zip && rm Commandline.zip
wget https://swift.rc.nectar.org.au:8888/v1/AUTH_33065ff5c34a4652aa2fefb292b3195a/$container/words.zip && unzip words.zip && rm words.zip
###############
# Setup for Tue
###############
day="Tue"
container="ACAD_$day"
cd $PARENT_DIR/$WORKSHOP_NAME/working_dir/$day
# pull down all the contents of the day's container
#curl --silent https://swift.rc.nectar.org.au:8888/v1/AUTH_33065ff5c34a4652aa2fefb292b3195a/$container | awk -v container=$container '{print "https://swift.rc.nectar.org.au:8888/v1/AUTH_33065ff5c34a4652aa2fefb292b3195a/" container "/" $0}' | xargs -I {} wget {}
###############
# Setup for Wed
###############
day="Wed"
container="ACAD_$day"
#cd $PARENT_DIR/$WORKSHOP_NAME/working_dir/$day
cd $PARENT_DIR/$WORKSHOP_NAME
#curl --silent https://swift.rc.nectar.org.au:8888/v1/AUTH_33065ff5c34a4652aa2fefb292b3195a/$container | awk -v container=$container '{print "https://swift.rc.nectar.org.au:8888/v1/AUTH_33065ff5c34a4652aa2fefb292b3195a/" container "/" $0}' | xargs -I {} wget {}
# tar up the working_dir using the machine's IP address
#myip=$(ip addr show eth0 | grep -o 'inet [0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' | grep -o [0-9].*)
#cd; tar -zcf ${myip}.tar.gz working_dir
#swift upload ACAD_working_dirs ${myip}.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment