Skip to content

Instantly share code, notes, and snippets.

@paraita
Created September 3, 2018 14:44
Show Gist options
  • Save paraita/a08a80e8f58f38a4a7d08a6286ddc17d to your computer and use it in GitHub Desktop.
Save paraita/a08a80e8f58f38a4a7d08a6286ddc17d to your computer and use it in GitHub Desktop.
Host in AE + SS in Az (8.2.0)
#!/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
usermod -aG docker activeeon
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment