Forked from
CAN / UNIX command line
109 commits behind the upstream repository.
-
Laurent Modolo authoredLaurent Modolo authored
deploy.sh 2.00 KiB
#!/bin/bash
# This script is executed on the virtual machine during the *Deployment* phase.
# It is used to apply parameters specific to the current deployment.
# It is executed secondly during a cloud deployement in IFB-Biosphere, after the *Installation* phase.
source /etc/profile.d/ifb.sh
LOCUSER=${LOCUSER:-ubuntu}
LOCUSER_DIR=`eval echo "~$LOCUSER"`
# Docker params
# APP_IMG="gitlab-registry.in2p3.fr/ifb-biosphere/apps/<...>"
# Configure default user
# IFB_DATADIR is set in profile ‘ifb.sh'
ln -s $IFB_DATADIR $LOCUSER_DIR/data
# Allow local user to run docker
usermod -a -G docker $LOCUSER
# Manage ephemeral disk
EPHEM_DIR=`df | grep vdb | awk '{print $6}'`
if [ -n "$EPHEM_DIR" ]; then
chown $LOCUSER:$LOCUSER $EPHEM_DIR
ln -s $EPHEM_DIR $IFB_DATADIR/mydatalocal
# Move docker data dir to ephemeral disk
DOCKER_DJSON=/etc/docker/daemon.json
export DOCKER_DATADIR=${EPHEM_DIR}/docker-data
mkdir $DOCKER_DATADIR
if [ -e $DOCKER_DJSON ]
then
curjson="$(jq '."data-root"=env.DOCKER_DATADIR' $DOCKER_DJSON)"
echo "${curjson}" > $DOCKER_DJSON
else
echo -e "{\n \"data-root\": \"$DOCKER_DATADIR\"\n}" > $DOCKER_DJSON
fi
systemctl restart docker
else
mkdir $IFB_DATADIR/mydatalocal
fi
# Mount IFB shared volumes
ifb_sharedvols=$(ss-get --timeout=5 ifb_share_endpoints)
if [ -n "$ifb_sharedvols" ]; then
wget -O /root/config_partages.py https://raw.githubusercontent.com/IFB-ElixirFr/biosphere-commons/master/scripts/utils/config_partages.py
python3 /root/config_partages.py $ifb_sharedvols
rm /root/config_partages.py
fi
USER_LOGIN=etudiant
USER_PASSWORD=$( openssl rand -hex 12 )
useradd -m -s /bin/bash -g users -G adm,dialout,cdrom,floppy,audio,dip,video,plugdev,netdev ${USER_LOGIN}
cp /etc/skel/.* /home/${USER_LOGIN}/
passwd ${USER_LOGIN} << EOF
${USER_PASSWORD}
${USER_PASSWORD}
EOF
HOST_NAME=$( ss-get --timeout=3 hostname )
HTTP_ENDP="https://$HOST_NAME"
ss-set url.service "${HTTP_ENDP}"
ss-set ss:url.service "[HTTPS]$HTTP_ENDP,[LOGIN]$USER_LOGIN,[PASSWORD]$USER_PASSWORD"