Added script for etherpad

This commit is contained in:
root 2018-02-19 18:24:09 +01:00
parent ce9ff10f67
commit 69a5a39372

73
install-etherpad.bash Executable file
View File

@ -0,0 +1,73 @@
#!/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 <<EOF
#[Unit]
#Description=Gogs (Go Git Service)
#After=syslog.target
#After=network.target
#After=postgresql.service
#After=nginx.service
#
#[Service]
#Type=simple
#User=${APPNAME}
#Group=${APPNAME}
#WorkingDirectory=/home/${APPNAME}/${APPNAME}
#ExecStart=/home/${APPNAME}/${APPNAME}/${APPNAME} web
#Restart=always
#Environment=USER=${APPNAME} HOME=/home/${APPNAME}
#
#[Install]
#WantedBy=multi-user.target
#EOF
#
#lxc exec $CONTAINER systemctl enable ${APPNAME}
#lxc exec $CONTAINER systemctl start ${APPNAME}
# lxc restart $CONTAINER