diff --git a/etherpad-docker.sh b/etherpad-docker.sh index b7f6f7c..4bd1053 100644 --- a/etherpad-docker.sh +++ b/etherpad-docker.sh @@ -13,9 +13,8 @@ do esac done -#DEBUG if [ "$MODE" = "debug" ]; then -set -x + set -x fi if ! [ "$(id -u)" = 0 ]; then @@ -32,7 +31,9 @@ echo ' ' FORGE_REPO="https://forge.switnet.net/switnet/quick-jibri-installer" check_apt_policy() { -apt-cache policy 2>/dev/null| awk "/$1/{print \$3}" | awk -F '/' 'NR==1{print$2}' + apt-cache policy 2>/dev/null| \ + awk "/$1/{print \$3}" | \ + awk -F '/' 'NR==1{print$2}' } install_ifnot() { if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then @@ -69,6 +70,7 @@ test_match "$WS_MATCH1" "$WS_CONF" # Install required packages install_ifnot docker.io +install_ifnot docker-compose install_ifnot postgresql-"$PSGVER" # Create DB @@ -78,29 +80,27 @@ CREATE DATABASE ${ETHERPAD_DB_NAME}; CREATE USER ${ETHERPAD_DB_USER} WITH ENCRYPTED PASSWORD '${ETHERPAD_DB_PASS}'; GRANT ALL PRIVILEGES ON DATABASE ${ETHERPAD_DB_NAME} TO ${ETHERPAD_DB_USER}; DB -echo " -- Your etherpad db password is: $ETHERPAD_DB_PASS" -echo -e " Please save it somewhere safe.\n" -# Check fot docker if not running then execute -if [ ! "$(docker ps -q -f name=etherpad)" ]; then - if [ "$(docker ps -aq -f status=exited -f name=etherpad)" ]; then - # cleanup - docker rm etherpad - fi - # run your container - docker run -d --restart always \ - --network=host \ - --name etherpad \ - -p 127.0.0.1:9001:9001 \ - -e "ADMIN_PASSWORD=$ETHERPAD_ADMIN_PASS" \ - -e "DB_TYPE=postgres" \ - -e "DB_HOST=localhost" \ - -e "DB_PORT=5432" \ - -e "DB_NAME=$ETHERPAD_DB_NAME" \ - -e "DB_USER=$ETHERPAD_DB_USER" \ - -e "DB_PASS=$ETHERPAD_DB_PASS" \ - -i -t etherpad/etherpad -fi +# Set environment varibales for docker +mkdir /opt/etherpat +cat << EOF > /opt/etherpat/.env +DOCKER_COMPOSE_APP_ADMIN_PASSWORD="$ETHERPAD_ADMIN_PASS" +DOCKER_COMPOSE_APP_DB_CHARSET="utf8mb4" +DOCKER_COMPOSE_POSTGRES_HOST="localhost" +DOCKER_COMPOSE_POSTGRES_USER="$ETHERPAD_DB_USER" +DOCKER_COMPOSE_POSTGRES_DATABASE="$ETHERPAD_DB_NAME" +DOCKER_COMPOSE_POSTGRES_PASSWORD="$ETHERPAD_DB_PASS" +DOCKER_COMPOSE_POSTGRES_PORT="5432" +#DOCKER_COMPOSE_APP_DEFAULT_PAD_TEXT= +DOCKER_COMPOSE_APP_DISABLE_IP_LOGGING="false" +DOCKER_COMPOSE_APP_SOFFICE="null" +DOCKER_COMPOSE_APP_TRUST_PROXY="true" +EOF +chmod 600 /opt/etherpat/.env +cp files/etherpad/docker-compose.yml /opt/etherpat/ +chmod 644 /opt/etherpat/docker-compose.yml + +docker-compose -f /opt/etherpat/docker-compose.yml up -d # Tune webserver for Jitsi App control @@ -121,8 +121,8 @@ elif [ -f "$WS_CONF" ]; then sed -i "/$WS_CONF_MATCH1/i \ \ \ \ }" "$WS_CONF" sed -i "/$WS_CONF_MATCH1/i \\\n" "$WS_CONF" else - echo "> No etherpad config done to server file, please report to: - -> https://forge.switnet.net/switnet/quick-jibri-installer/issues" + echo "> No etherpad config done to server file, please report to:" + echo " -> https://forge.switnet.net/switnet/quick-jibri-installer/issues" fi # Configure config.js @@ -140,6 +140,6 @@ if nginx -t 2>/dev/null ; then # systemctl reload nginx else echo "Please check your configuration, something may be wrong." - echo "Will not try to enable etherpad nginx configuration, please report to: - -> https://forge.switnet.net/switnet/quick-jibri-installer/issues" + echo "Will not try to enable etherpad nginx configuration, please report to:" + echo " -> https://forge.switnet.net/switnet/quick-jibri-installer/issues" fi