#!/bin/bash CONTAINER=$1 APPNAME="etherpad" APPREPO="git://github.com/ether/etherpad-lite.git" NODEVER="9.5.0" DOMAIN="logerais.com" TIMEZONE="Europe/Paris" if [ -z "$CONTAINER" ]; then echo "Missing parameter"; exit 1 ; fi # Set container timezone lxc file edit "$CONTAINER/etc/timezone" <<< "${TIMEZONE}" # Install packages lxc exec $CONTAINER -- apt update # Database lxc exec $CONTAINER -- apt install -y postgresql lxc exec $CONTAINER -- su --login postgres <<< "createuser ${APPNAME}" lxc exec $CONTAINER -- su --login postgres <<< "createdb --owner=${APPNAME} ${APPNAME}" lxc exec $CONTAINER -- su --login postgres --shell /usr/bin/psql <<< "ALTER USER \"${APPNAME}\" WITH PASSWORD '${APPNAME}';" # Application lxc exec $CONTAINER -- apt install -y curl wget git lxc exec $CONTAINER -- apt install -y gzip python libssl-dev pkg-config build-essential lxc exec $CONTAINER -- apt install -y moreutils jq lxc exec $CONTAINER -- userdel -r ${APPNAME} lxc exec $CONTAINER -- useradd -m --shell /bin/bash ${APPNAME} lxc exec $CONTAINER -- usermod --groups sudo --append ${APPNAME} lxc exec $CONTAINER -- su --login ${APPNAME} --command 'git clone https://github.com/riywo/anyenv ~/.anyenv' lxc exec $CONTAINER -- su --login ${APPNAME} --command 'echo export PATH="\$HOME/.anyenv/bin:\$PATH" >> ~/.profile' lxc exec $CONTAINER -- su --login ${APPNAME} --command 'echo eval \"\$\(anyenv init -\)\" >> ~/.profile' lxc exec $CONTAINER -- su --login ${APPNAME} --command 'anyenv install nodenv' lxc exec $CONTAINER -- su --login ${APPNAME} --command "nodenv install ${NODEVER}" lxc exec $CONTAINER -- su --login ${APPNAME} --command "git clone ${APPREPO} ${APPNAME}" lxc exec $CONTAINER -- su --login ${APPNAME} --command "cd ${APPNAME} && nodenv local ${NODEVER}" lxc exec $CONTAINER -- su --login ${APPNAME} --command "cd ${APPNAME} && bin/run.sh" #lxc file edit $CONTAINER/etc/systemd/system/${APPNAME}.service <