#!/bin/bash CONTAINER=$1 APPNAME="gogs" APPURL="wget https://cdn.gogs.io/0.11.4/linux_amd64.tar.gz" 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 lxc exec $CONTAINER -- apt install -y curl wget git lxc exec $CONTAINER -- apt install -y nginx 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}\';" lxc exec $CONTAINER -- useradd -m --shell /bin/bash ${APPNAME} lxc exec $CONTAINER -- usermod --groups sudo --append ${APPNAME} lxc exec $CONTAINER -- su --login ${APPNAME} --command "wget ${APPURL}" lxc exec $CONTAINER -- su --login ${APPNAME} --command "tar vxzf linux_amd64.tar.gz" lxc file edit $CONTAINER/etc/systemd/system/${APPNAME}.service <