Skip to content

Instantly share code, notes, and snippets.

@paraita
Last active July 10, 2018 05:57
Show Gist options
  • Save paraita/c7450c377070da649ceaf2366fb87286 to your computer and use it in GitHub Desktop.
Save paraita/c7450c377070da649ceaf2366fb87286 to your computer and use it in GitHub Desktop.
Azure user script for the 600 nodes bench
#!/bin/bash
set -x
set -e
set -o pipefail
umask 0022
JSONCONFIG=`base64 -d /var/lib/waagent/CustomData`
echo $JSONCONFIG
export HOST=`echo $JSONCONFIG | jq '.rmurl' -r | sed 's/http[s]\?:\?\/\{2\}//g'`
export RMURL=`echo $JSONCONFIG | jq '.rmurl' -r | sed 's/http[s]\?:\?\/\{2\}//g'`
export CREDVALUE=`echo $JSONCONFIG | jq '.credentials' -r`
export NODESOURCENAME=`echo $JSONCONFIG | jq '.nodesourcename' -r`
export STORAGEACCOUNT=`echo $JSONCONFIG | jq '.storageaccount' -r`
export SASKEY=`echo $JSONCONFIG | jq '.saskey' -r`
export USERCUSTOMSCRIPTURL=`echo $JSONCONFIG | jq '.usercustomscripturl' -r`
export EXT_STORACC_RAW=`echo $JSONCONFIG | jq '.exernalstorageaccount' -r`
export EXT_STOR_ACC=`echo $EXT_STORACC_RAW | sed 's/\:.*$//'`
export EXT_STOR_ACC_SAS=`echo $EXT_STORACC_RAW | sed 's/^.*\:?//'`
function debug {
DEBUGCONTENT=`echo $1 | base64 -w 0`
DEBUGMESSAGE="<QueueMessage><MessageText>$DEBUGCONTENT</MessageText></QueueMessage>"
curl -X POST -d "$DEBUGMESSAGE" "https://$STORAGEACCOUNT.queue.core.windows.net/debug/messages?$SASKEY"
}
debug "CNES user script $HOSTNAME INFO: CustomData read properly (as I can write this message)"
# Simplified log function that reads input stream and sends to log
# This function is used from commands
function logStd {
while IFS= read -r line; do debug "CNES user script $line"; done
}
err_report() {
debug "CNES user script : Error on line : $2 status : $1"
}
trap 'err_report $? $LINENO' ERR
#yum -y update
yum install -y yum-utils device-mapper-persistent-data lvm2 python-pip
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
typeset -r pepsuser=hpcpeps
typeset -i pepsuid=8298
typeset -r pepsgroup=peps
typeset -i pepsgid=16000
groupadd -g $pepsgid $pepsgroup
useradd -u $pepsuid -g $pepsgid $pepsuser
echo "* hard core 0 " >> /etc/security/limits.conf
echo "" >> /etc/security/limits.conf
echo "hpcpeps hard nofile 65535" >> /etc/security/limits.conf
echo "hpcpeps soft nofile 65535" >> /etc/security/limits.conf
echo "hpcpeps hard nproc 65535" >> /etc/security/limits.conf
echo "hpcpeps soft nproc 65535" >> /etc/security/limits.conf
systemctl start docker
sysctl net.bridge.bridge-nf-call-iptables=1
sysctl net.bridge.bridge-nf-call-ip6tables=1
usermod -aG docker hpcpeps
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# required for the native python feature
pip install py4j
yum install -y samba-client samba-common cifs-utils
yum install -y unzip
mkdir /vizo
chown 8298:16000 /vizo
chmod 0755 /vizo
mkdir -p /home/hpcpeps
chown 8298:16000 /home/hpcpeps
chmod 0755 /home/hpcpeps
mkdir -p /mnt/resource/working_dir
chown 8298:16000 /mnt/resource/working_dir
chmod 0755 /mnt/resource/working_dir
#sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<share-name> <mount-point> -o vers=<smb-version>,username=<storage-account-name>,password=<storage-account-key>,dir_mode=0777,file_mode=0777,serverino
mount -t cifs //$EXT_STOR_ACC.file.core.windows.net/vizoazurefileshare /vizo -o vers=3.0,username=$EXT_STOR_ACC,password=57srh1yNeCxlON3HXiU/Dcz6P7Bnh9W2bEirgxzjasL4RBSVi4PVd3dWqZbQ8M+STs2efwAorhaHkyPw7sT9hw==,dir_mode=0755,file_mode=0755,serverino,uid=8298,gid=16000,rw
#mkdir -p /vizo/working_dir
#mkdir -p /vizo/results/logs
#mkdir -p /vizo/products
#mkdir -p /vizo/data
#mkdir -p /vizo/results/quicklook
#mkdir -p /vizo/results/s1tiling
#curl -X GET "https://$EXT_STOR_ACC.blob.core.windows.net/nodefiles/docker-compose-test.yml?$EXT_STOR_ACC_SAS" > /vizo/data/docker-compose-test.yml
#curl -X GET "https://$EXT_STOR_ACC.blob.core.windows.net/nodefiles/S1Processor.cfg?$EXT_STOR_ACC_SAS" > /vizo/data/S1Processor.cfg
#curl -X GET "https://$EXT_STOR_ACC.blob.core.windows.net/nodefiles/shapefile.zip?$EXT_STOR_ACC_SAS" > /vizo/data/shapefile.zip
#cd /vizo/data
#rm -rf /vizo/data/shapefile
#unzip shapefile.zip 2>&1 | logStd
#rm shapefile.zip
#curl -X GET "https://$EXT_STOR_ACC.blob.core.windows.net/nodefiles/SRTM_30_FR.zip?$EXT_STOR_ACC_SAS" > /vizo/data/SRTM_30_FR.zip
#unzip SRTM_30_FR.zip
#mv SRTM_30_FR SRTM_30
#rm SRTM_30_FR.zip
#chown -R 8298:16000 /vizo
#chmod -R 0755 /vizo
#curl -X GET "https://$EXT_STOR_ACC.blob.core.windows.net/nodefiles/vizo_amalthee_1.3.tar?$EXT_STOR_ACC_SAS" > /tmp/vizo_amalthee_1.3.tar
docker load -i /vizo/docker_images/amalthee_1.4.tar
#curl -X GET "https://$EXT_STOR_ACC.blob.core.windows.net/nodefiles/vizo_s1tiling_1.3.tar?$EXT_STOR_ACC_SAS" > /tmp/vizo_s1tiling_1.3.tar
docker load -i /vizo/docker_images/s1tiling_1.5.tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment