#!/bin/bash # # Bookstack Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin . /etc/federated get_appvars config_bookstack() { echo -ne "* Configuring bookstack container.." if [ ! -d "/federated/apps/bookstack" ]; then mkdir -p /federated/apps/bookstack/data/config fi cat > /federated/apps/bookstack/docker-compose.yml < /federated/apps/bookstack/.env < /dev/null docker exec pdnsmysql bash -c "mariadb -uroot -p$MYSQL_ROOTPASSWORD -e \"CREATE USER 'bookstack'@'%' IDENTIFIED BY '$BOOKSTACK_SECRET';\"" &> /dev/null docker exec pdnsmysql bash -c "mariadb -uroot -p$MYSQL_ROOTPASSWORD -e \"grant all privileges on bookstack.* to 'bookstack'@'%';\"" &> /dev/null docker exec pdnsmysql bash -c "mariadb -uroot -p$MYSQL_ROOTPASSWORD -e 'flush privileges;'" &> /dev/null echo -ne "done.\n" } start_bookstack() { # Start service with command to make sure it's up before proceeding start_service "bookstack" "nc -z 192.168.0.36 80 &> /dev/null" "7" if [[ "${PLUS}" != "true" ]]; then docker exec pdns pdnsutil add-record $DOMAIN bookstack A 86400 $EXTERNALIP &> /dev/null docker exec pdns pdnsutil add-record $DOMAIN documentation A 86400 $EXTERNALIP &> /dev/null fi docker exec pdnsmysql mariadb -ubookstack -p$BOOKSTACK_SECRET bookstack -e "delete from users where email = 'admin@admin.com';" &> /dev/null docker exec bookstack php /app/www/artisan bookstack:create-admin --email="admin@$DOMAIN" --name="Admin" --password="$ADMINPASS" &> /dev/null # Set mail configuration sed -i "s#MAIL_FROM=.*#MAIL_FROM=admin@$DOMAIN#g" /federated/apps/bookstack/data/config/www/.env sed -i "s#MAIL_FROM_NAME=.*#MAIL_FROM_NAME=admin#g" /federated/apps/bookstack/data/config/www/.env sed -i "s#MAIL_HOST=.*#MAIL_HOST=mail.$DOMAIN#g" /federated/apps/bookstack/data/config/www/.env sed -i "s#MAIL_PORT=.*#MAIL_PORT=587#g" /federated/apps/bookstack/data/config/www/.env sed -i "s#MAIL_USERNAME=.*#MAIL_USERNAME=admin#g" /federated/apps/bookstack/data/config/www/.env sed -i "s#MAIL_PASSWORD=.*#MAIL_PASSWORD=$ADMINPASS#g" /federated/apps/bookstack/data/config/www/.env sed -i "s#MAIL_ENCRYPTION=.*#MAIL_ENCRYPTION=TLS#g" /federated/apps/bookstack/data/config/www/.env echo -ne "done.\n" } email_bookstack() { echo -ne "* Sending email to customer.." cat > /federated/apps/mail/data/root/certs/mailfile <

Bookstack is now installed on $DOMAIN

Here is your applications chart on how to access this service:

Applications

Service Link User / Pass Access Docs Description
Bookstack bookstack.$DOMAIN admin@$DOMAIN
$ADMINPASS
User access is separate from panel Click here Bookstack is a simple, open-source, self-hosted, easy-to-use platform (Wiki) for organising and storing information

Thanks for your support!

Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful time with Federated Core.

Again, if we can be of any assistance, please don't hesitate to get in touch.

Support: https://support.federated.computer
Phone: (970) 722-8715
Email: support@federated.computer

It's your computer. Let's make it work for you! EOF # Send out e-mail from mail container with details docker exec mail bash -c "mail -r admin@$DOMAIN -a \"Content-type: text/html\" -s \"Application installed on $DOMAIN\" $EMAIL < /root/certs/mailfile" rm /federated/apps/mail/data/root/certs/mailfile echo -ne "done.\n" } uninstall_bookstack() { echo -ne "* Uninstalling bookstack container.." # First stop the service cd /federated/apps/bookstack && docker compose -f docker-compose.yml -p bookstack down &> /dev/null # Delete database and user docker exec pdnsmysql bash -c "mariadb -uroot -p$MYSQL_ROOTPASSWORD -e 'drop database bookstack;'" &> /dev/null docker exec pdnsmysql bash -c "mariadb -uroot -p$MYSQL_ROOTPASSWORD -e 'drop user bookstack;'" &> /dev/null # Delete the app directory rm -rf /federated/apps/bookstack # Delete the image docker image rm lscr.io/linuxserver/bookstack:$IMAGE_VERSION &> /dev/null # Delete the DNS record if [[ "${PLUS}" != "true" ]]; then docker exec pdns pdnsutil delete-rrset $DOMAIN bookstack A &> /dev/null docker exec pdns pdnsutil delete-rrset $DOMAIN documentation A &> /dev/null fi # Uninstall the SSO configuration if it exists in authelia (authelia must exist too) if [[ $(grep "### Bookstack" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]]; then sed -i '/### Bookstack/,/### /{/### PowerDNS/!{/### /!d}}' /federated/apps/authelia/data/config/idproviders.yml sed -i '/### Bookstack/d' /federated/apps/authelia/data/config/idproviders.yml run_command "/federated/bin/stop authelia" run_command "/federated/bin/start authelia" fi echo -ne "done.\n" } configsso_bookstack() { if [[ "${PLUS}" != "true" ]]; then echo -ne "* Configuring bookstack container with SSO.." [ ! -d "/federated/apps/authelia" ] && failcheck "Authelia is not installed. You need this first before continuing." [ ! -f "/federated/apps/authelia/data/config/idproviders.yml" ] && failcheck "Authelia idproviders.yml is missing." [[ $(grep "### Bookstack" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]] && failcheck "Authelia already has a Bookstack configuration." BOOKSTACK_CLIENT_SECRET=$(create_password); BOOKSTACK_CLIENT_SECRET_HASH=$(docker run --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --password $BOOKSTACK_CLIENT_SECRET | awk '{ print $2 }') cat >> /federated/apps/authelia/data/config/idproviders.yml <> /federated/apps/bookstack/.env <> /federated/apps/bookstack/.env <