diff --git a/etherpad-docker.sh b/etherpad-docker.sh index cc97857..559d9f8 100644 --- a/etherpad-docker.sh +++ b/etherpad-docker.sh @@ -64,13 +64,20 @@ WS_CONF_MATCH1="# ensure all static content can always be found first" read -p "Set your etherpad docker admin password: " -r ETHERPAD_ADMIN_PASS +install -m 600 /dev/null /var/opt/etherpad_details.txt +cat << EOF > /var/opt/etherpad_details.txt +ETHERPAD_ADMIN_PASS=$ETHERPAD_ADMIN_PASS +ETHERPAD_DB_USER=$ETHERPAD_DB_USER +ETHERPAD_DB_NAME=$ETHERPAD_DB_NAME +ETHERPAD_DB_PASS=$ETHERPAD_DB_PASS +EOF + # Make sure we can rely on the match strings. printf "> Testing match strings on config files.\n" test_match "$WS_MATCH1" "$WS_CONF" # Install required packages install_ifnot docker.io -install_ifnot docker-compose install_ifnot postgresql-"$PSGVER" # Create DB @@ -81,26 +88,26 @@ CREATE USER ${ETHERPAD_DB_USER} WITH ENCRYPTED PASSWORD '${ETHERPAD_DB_PASS}'; GRANT ALL PRIVILEGES ON DATABASE ${ETHERPAD_DB_NAME} TO ${ETHERPAD_DB_USER}; DB -# Set environment varibales for docker -mkdir /opt/etherpad -cat << EOF > /opt/etherpad/.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 644 /opt/etherpad/.env -cp files/etherpad/docker-compose.yml /opt/etherpad/ -chmod 644 /opt/etherpad/docker-compose.yml - -docker-compose -f /opt/etherpad/docker-compose.yml up -d +# 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 # Tune webserver for Jitsi App control