diff --git a/README.md b/README.md index 7fe35eb..43b11d6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # lxd-selfhosting-scripts -Provisionning bash scripts collection used to deploy some self hosted applications in LXD containers \ No newline at end of file +Provisionning bash scripts collection used to deploy some self hosted applications in LXD containers diff --git a/install-gogs.bash b/install-gogs.bash new file mode 100755 index 0000000..13b82bf --- /dev/null +++ b/install-gogs.bash @@ -0,0 +1,58 @@ +#!/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 <