From ec0e9f29c78b582fa3660611628f8ba4b1a05c4b Mon Sep 17 00:00:00 2001 From: ShockDW Date: Tue, 1 Dec 2020 22:49:37 -0600 Subject: [PATCH 1/7] add install.sh to automate deployment --- install.sh | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..5748434a --- /dev/null +++ b/install.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +# This script is meant to automate the deployment of Szurubooru via Docker/Docker-Compose, +# and to automatically take the necessary steps to allow Szurubooru to run on ARM devices +# such as the Raspberry Pi. + +###########################################[Notes]########################################### +# * Written and tested on Raspberry Pi 4 running Raspbian 10 (armv7), heavily based on a fork +# by kaijuagenda for the Pi 3: https://github.com/kaijuagenda/szurubooru-rpi3 +# +# * Modifies docker-compose.yml rather than relying on a static alternative file to hopefully +# avoid the need for parallel maintenance of two files. +############################################################################################# + +echo "Welcome to Szurubooru. This install script will ask you to set a few config values, then get szurubooru up and running." + +# Check to ensure Docker and Docker-Compose are both installed before proceeding +if ! command -v docker &> /dev/null || ! command -v docker-compose &> /dev/null; then + echo "Both Docker and Docker-Compose must already be installed to use this script." + echo "Please ensure both are installed and accessible using commands 'docker' and 'docker-compose', then run this script again." + exit 1 +else echo "Docker and Docker-Compose verified. Continuing installation..." +fi + +######################################################################################## +# Check CPU architectue and, if ARM (such as Raspberry Pi), modify docker-compose.yml +# https://github.com/rr-/szurubooru/wiki/ARM-and-Raspberry-Pi-Support-for-Docker-builds +# https://github.com/rr-/szurubooru/blob/master/docker-compose.yml +######################################################################################## + +if [[ "$(uname -m)" == 'a'* ]]; then + echo "ARM architecture detected. Modfying docker-compose.yml accordingly." + sed -zi "s|image: szurubooru/server:latest|build:\n context: ./server|; \ # Modify services/server to build locally instead of pulling from DockerHub + s|image: szurubooru/client:latest|build:\n context: ./client|; \ # Modify services/client to build locally instead of pulling from DockerHub + s|depends_on:\n - sql|depends_on:\n - sql\n - elasticsearch|; \ # Add dependency for alternate arm compatible elasticsearch defined below. + s|POSTGRES_HOST: sql|POSTGRES_HOST: sql\n ESEARCH_HOST: elasticsearch'|" docker-compose.yml # Point Postgres to the alternate elasticsearch container + + # Add a new section to define the alternate elasticsearch service + cat >> docker-compose.yml <<-ESS + elasticsearch: + image: ind3x/rpi-elasticsearch #recommended in the wiki, does get the job done. + environment: + ## Specifies the Java heap size used + ## Read + ## https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html + ## for more info + ES_JAVA_OPTS: -Xms512m -Xmx512m + volumes: + - index:/usr/share/elasticsearch/data + volumes: + index: # Scratch space for ElasticSearch index, will be rebuilt if lost + ESS +fi + + +function server_config () { + ################################################################################################################ + # Copy ./server/config.yaml.dist to ./server/config.yaml, then prompt the user to set the basic config settings + # https://github.com/rr-/szurubooru/blob/master/doc/INSTALL.md + ################################################################################################################ + + cp server/config.yaml.dist server/config.yaml + + echo "===[General Settings]===" + + # Prompt for Secret, proposing a randomly generated 32-character alphanumeric value as a default. + default_secret="$(tr -dc '[:alnum:]' < /dev/urandom | dd bs=4 count=8 2>/dev/null)" + echo "Enter your Secret (Used to salt the users' password hashes and generate filenames for static content)"; read -e -p "> " -i "$default_secret" SECRET + sed -i "s|secret: change|secret: $SECRET|" server/config.yaml + + # Other useful (but less important) settings + echo "Enter the desired name for your server. (Shown in the website title and on the front page)"; read -e -p "> " -i "szurubooru" SERVERNAME + echo "Enter the full url to the homepage of this szurubooru site, with no trailing slash."; read -e -p "> " URL + sed -i "s|name: szurubooru|name: $SERVERNAME|;s|domain: |domain: $URL|" server/config.yaml + + # SMTP (email) settings + echo "===[SMTP (Email) Settings]===" + echo "If host name is left blank, the password reset feature will be disabled." + echo "Enter your email server's host address." + read -e -p "> " SMTP_HOST + + if [ -n "$SMTP_HOST" ]; then # Prompt for additional SMTP details and then update server/config.yaml if host was set + echo "Enter the Port number for your SMTP server"; read -e -p "> " SMTP_PORT + echo "Enter the UserName for your SMTP server"; read -e -p "> " SMTP_USER + echo "Enter the Password for your SMTP server"; read -e -p -s "> " SMTP_PASS + echo "Enter the 'From' address emails should show"; read -e -p "> " SMTP_FROM + sed -i "s|host: |host: $SMTP_HOST|; \ + s|port: |port: $SMTP_PORT|; \ + s|user: |user: $SMTP_USER|; \ + s|pass: |pass: $SMTP_PASS|; \ + s|from: |from: $SMTP_FROM|" \ + server/config.yaml + else # Warn user that they should set a contact email if no smtp host is specified + echo "WARNING: No SMTP host specified!" + echo "It is recommended you set a contact email in the next prompt for manual password reset requests." + fi + + echo "Enter your server's primary contact email address." + read -e -p "> " CONTACT_ADDR + if [ -n "$CONTACT_ADDR" ]; then sed -i "s|contact_email: |contact_email: $CONTACT_ADDR|"; fi +} + +function set_env () { + ############################################################################################################ + # Copy ./doc/example.env to ./.env, then prompt the user to set the basic config settings + # https://github.com/rr-/szurubooru/blob/master/doc/INSTALL.md + ############################################################################################################ + cp doc/example.env .env + echo "===[Environmental Variables]===" + echo "Enter your desired database username"; read -e -p "> " -i "szuru" DB_USER + while true; do + echo "Enter your desired database password"; read -e -p -s "> " DB_PASS + if [ -n $DB_PASS ]; break + else echo "ERROR: You must set a password!" + fi + done + echo "Enter the build info you'd like to display on the home screen"; read -e -p "> " -i "latest" BUILD_INFO + echo "Enter the port # to expose the HTTP service to. " + echo "Set to 127.0.0.1:8080 if you wish to reverse proxy the docker's port."; read -e -p "> " -i "8080" PORT + echo "Enter the URL base to run szurubooru under"; read -e -p "> " -i "/" BASE_URL + echo "Enter the directory you wish to store image data in"; read -e -p "> " -i "/var/local/szurubooru/data" MOUNT_DATA + echo "Enter the directory in which you wish to store database files"; read -e -p "> " -i "/var/local/szurubooru/sql" MOUNT_SQL + sed -i "s|POSTGRES_USER=szuru|POSTGRES_USER=$DB_USER|; \ + s|POSTGRES_PASSWORD=changeme| POSTGRES_PASSWORD=$DB_PASS|; \ + s|BUILD_INFO=latest|BUILD_INFO=$BUILD_INFO|; \ + s|PORT=8080|PORT=$PORT|; \ + s|BASE_URL=/|BASE_URL=$URL|; \ + s|MOUNT_DATA=/var/local/szurubooru/data|MOUNT_DATA=$MOUNT_DATA|; \ + s|MOUNT_SQL=/var/local/szurubooru/sql|MOUNT_SQL=$MOUNT_SQL|" .env +} + +server_config # Configuration via ./server/config.yaml +set_env # Configuration via ./.env +mount=$(grep "MOUNT_DATA" .env | sed 's/MOUNT_DATA=//'); chown 1000:1000 "$mount" # Ensures users can upload files +docker-compose pull # Download containers +docker-compose up -d sql # Start SQL first +sleep 30 # Give the database time to become available +docker-compose up -d # Start remaining containers From cdb3b7dddc79a31fe8f3d60f8fa98ae3b4c2e6a8 Mon Sep 17 00:00:00 2001 From: ShockDW Date: Wed, 2 Dec 2020 00:21:50 -0600 Subject: [PATCH 2/7] add install.sh to automate deployment --- install.sh | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 5748434a..b5858e58 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,16 @@ # avoid the need for parallel maintenance of two files. ############################################################################################# -echo "Welcome to Szurubooru. This install script will ask you to set a few config values, then get szurubooru up and running." +# Check for root to ensure the accessibility of the Docker daemon, and to +# allow mount point permissions to be set after building. + +if [[ $EUID -ne 0 ]]; then + echo "Sorry, but this script needs root to properly function. Please try again using sudo ./install.sh" 1>&2 + exit 1 +fi + +echo "Welcome to Szurubooru. This install script will ask you to set a few +echo "config values, then get szurubooru up and running." # Check to ensure Docker and Docker-Compose are both installed before proceeding if ! command -v docker &> /dev/null || ! command -v docker-compose &> /dev/null; then @@ -33,9 +42,9 @@ if [[ "$(uname -m)" == 'a'* ]]; then sed -zi "s|image: szurubooru/server:latest|build:\n context: ./server|; \ # Modify services/server to build locally instead of pulling from DockerHub s|image: szurubooru/client:latest|build:\n context: ./client|; \ # Modify services/client to build locally instead of pulling from DockerHub s|depends_on:\n - sql|depends_on:\n - sql\n - elasticsearch|; \ # Add dependency for alternate arm compatible elasticsearch defined below. - s|POSTGRES_HOST: sql|POSTGRES_HOST: sql\n ESEARCH_HOST: elasticsearch'|" docker-compose.yml # Point Postgres to the alternate elasticsearch container - - # Add a new section to define the alternate elasticsearch service + s|POSTGRES_HOST: sql|POSTGRES_HOST: sql\n ESEARCH_HOST: elasticsearch|" \ # Point Postgres to the alternate elasticsearch container + docker-compose.yml + # "Add a new section to define the alternate elasticsearch service cat >> docker-compose.yml <<-ESS elasticsearch: image: ind3x/rpi-elasticsearch #recommended in the wiki, does get the job done. @@ -60,7 +69,7 @@ function server_config () { ################################################################################################################ cp server/config.yaml.dist server/config.yaml - + echo "" echo "===[General Settings]===" # Prompt for Secret, proposing a randomly generated 32-character alphanumeric value as a default. @@ -129,10 +138,20 @@ function set_env () { s|MOUNT_SQL=/var/local/szurubooru/sql|MOUNT_SQL=$MOUNT_SQL|" .env } +function final_touches () { + docker-compose pull # Download containers + docker-compose up -d sql # Start SQL first + sleep 30 # Give the database time to become available + docker-compose up -d # Start remaining containers +} + + server_config # Configuration via ./server/config.yaml set_env # Configuration via ./.env -mount=$(grep "MOUNT_DATA" .env | sed 's/MOUNT_DATA=//'); chown 1000:1000 "$mount" # Ensures users can upload files -docker-compose pull # Download containers -docker-compose up -d sql # Start SQL first -sleep 30 # Give the database time to become available -docker-compose up -d # Start remaining containers +final_touches # Start Szurubooru + +# Ensure files can be uploaded by setting ownership of the /data/ mount point +puid=$(grep "PUID=" server/Dockerfile | sed "s/.*=//") +guid=$(grep "GUID=" server/Dockerfile | sed "s/.*=//") +mount=$(grep "MOUNT_DATA" .env | sed 's/MOUNT_DATA=//') +chown -R $puid:$guid "$mount" \ No newline at end of file From ed9b6c1f4891df84e3916370cd1f13ea380c7395 Mon Sep 17 00:00:00 2001 From: ShockDW <46183407+ShockDW@users.noreply.github.com> Date: Sun, 6 Dec 2020 00:39:59 -0600 Subject: [PATCH 3/7] Add files via upload Updated install.sh to remove logic relevant to deprecated elastisearch dependency, unnecessary root check; various other fixes. --- install.sh | 104 +++++++++++++++++++++++------------------------------ 1 file changed, 45 insertions(+), 59 deletions(-) diff --git a/install.sh b/install.sh index b5858e58..6a992409 100755 --- a/install.sh +++ b/install.sh @@ -15,13 +15,8 @@ # Check for root to ensure the accessibility of the Docker daemon, and to # allow mount point permissions to be set after building. -if [[ $EUID -ne 0 ]]; then - echo "Sorry, but this script needs root to properly function. Please try again using sudo ./install.sh" 1>&2 - exit 1 -fi - -echo "Welcome to Szurubooru. This install script will ask you to set a few -echo "config values, then get szurubooru up and running." +echo "Welcome to Szurubooru. This install script will ask you to" +echo "set a few config values, then get szurubooru up and running." # Check to ensure Docker and Docker-Compose are both installed before proceeding if ! command -v docker &> /dev/null || ! command -v docker-compose &> /dev/null; then @@ -38,27 +33,10 @@ fi ######################################################################################## if [[ "$(uname -m)" == 'a'* ]]; then - echo "ARM architecture detected. Modfying docker-compose.yml accordingly." - sed -zi "s|image: szurubooru/server:latest|build:\n context: ./server|; \ # Modify services/server to build locally instead of pulling from DockerHub - s|image: szurubooru/client:latest|build:\n context: ./client|; \ # Modify services/client to build locally instead of pulling from DockerHub - s|depends_on:\n - sql|depends_on:\n - sql\n - elasticsearch|; \ # Add dependency for alternate arm compatible elasticsearch defined below. - s|POSTGRES_HOST: sql|POSTGRES_HOST: sql\n ESEARCH_HOST: elasticsearch|" \ # Point Postgres to the alternate elasticsearch container - docker-compose.yml - # "Add a new section to define the alternate elasticsearch service - cat >> docker-compose.yml <<-ESS - elasticsearch: - image: ind3x/rpi-elasticsearch #recommended in the wiki, does get the job done. - environment: - ## Specifies the Java heap size used - ## Read - ## https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html - ## for more info - ES_JAVA_OPTS: -Xms512m -Xmx512m - volumes: - - index:/usr/share/elasticsearch/data - volumes: - index: # Scratch space for ElasticSearch index, will be rebuilt if lost - ESS + echo "ARM architecture detected. Modfying docker-compose.yml for local build." + # Modify docker-compose file to build locally instead of pulling from dockerhub + sed -zi "s|image: szurubooru/server:latest|build:\n context: ./server|; \ + s|image: szurubooru/client:latest|build:\n context: ./client|" ./docker-compose.yml fi @@ -69,21 +47,20 @@ function server_config () { ################################################################################################################ cp server/config.yaml.dist server/config.yaml - echo "" - echo "===[General Settings]===" + echo -e "\n===[General Settings]===" # Prompt for Secret, proposing a randomly generated 32-character alphanumeric value as a default. default_secret="$(tr -dc '[:alnum:]' < /dev/urandom | dd bs=4 count=8 2>/dev/null)" echo "Enter your Secret (Used to salt the users' password hashes and generate filenames for static content)"; read -e -p "> " -i "$default_secret" SECRET - sed -i "s|secret: change|secret: $SECRET|" server/config.yaml + sed -i "s|secret: change|secret: $SECRET|" ./server/config.yaml # Other useful (but less important) settings echo "Enter the desired name for your server. (Shown in the website title and on the front page)"; read -e -p "> " -i "szurubooru" SERVERNAME echo "Enter the full url to the homepage of this szurubooru site, with no trailing slash."; read -e -p "> " URL - sed -i "s|name: szurubooru|name: $SERVERNAME|;s|domain: |domain: $URL|" server/config.yaml + sed -i "s|name: szurubooru|name: $SERVERNAME|;s|domain: |domain: $URL|" ./server/config.yaml # SMTP (email) settings - echo "===[SMTP (Email) Settings]===" + echo -e "\n===[SMTP (Email) Settings]===" echo "If host name is left blank, the password reset feature will be disabled." echo "Enter your email server's host address." read -e -p "> " SMTP_HOST @@ -97,8 +74,7 @@ function server_config () { s|port: |port: $SMTP_PORT|; \ s|user: |user: $SMTP_USER|; \ s|pass: |pass: $SMTP_PASS|; \ - s|from: |from: $SMTP_FROM|" \ - server/config.yaml + s|from: |from: $SMTP_FROM|" ./server/config.yaml else # Warn user that they should set a contact email if no smtp host is specified echo "WARNING: No SMTP host specified!" echo "It is recommended you set a contact email in the next prompt for manual password reset requests." @@ -106,7 +82,7 @@ function server_config () { echo "Enter your server's primary contact email address." read -e -p "> " CONTACT_ADDR - if [ -n "$CONTACT_ADDR" ]; then sed -i "s|contact_email: |contact_email: $CONTACT_ADDR|"; fi + if [ -n "$CONTACT_ADDR" ]; then sed -i "s|contact_email: |contact_email: $CONTACT_ADDR |" ./server/config.yaml; fi } function set_env () { @@ -115,22 +91,21 @@ function set_env () { # https://github.com/rr-/szurubooru/blob/master/doc/INSTALL.md ############################################################################################################ cp doc/example.env .env - echo "===[Environmental Variables]===" - echo "Enter your desired database username"; read -e -p "> " -i "szuru" DB_USER - while true; do - echo "Enter your desired database password"; read -e -p -s "> " DB_PASS - if [ -n $DB_PASS ]; break - else echo "ERROR: You must set a password!" - fi + echo -e "\n===[Environmental Variables]===" + echo "Enter your desired database username."; read -e -p "> " -i "szuru" DB_USER + while true; do # Ensures the user sets a database password for security reasons. + echo "Enter your desired database password. (Will not print to console)"; read -s -p "> " DB_PASS + if [ -z $DB_PASS ]; then echo -e "\nERROR: You must set a password!"; else break; fi done - echo "Enter the build info you'd like to display on the home screen"; read -e -p "> " -i "latest" BUILD_INFO - echo "Enter the port # to expose the HTTP service to. " + echo "" + echo "Enter the build info you'd like to display on the home screen."; read -e -p "> " -i "latest" BUILD_INFO + echo "Enter the port # to expose the HTTP service to." echo "Set to 127.0.0.1:8080 if you wish to reverse proxy the docker's port."; read -e -p "> " -i "8080" PORT echo "Enter the URL base to run szurubooru under"; read -e -p "> " -i "/" BASE_URL - echo "Enter the directory you wish to store image data in"; read -e -p "> " -i "/var/local/szurubooru/data" MOUNT_DATA - echo "Enter the directory in which you wish to store database files"; read -e -p "> " -i "/var/local/szurubooru/sql" MOUNT_SQL + echo "Enter the directory in which you wish to store image data."; read -e -p "> " -i "/var/local/szurubooru/data" MOUNT_DATA + echo "Enter the directory in which you wish to store database files."; read -e -p "> " -i "/var/local/szurubooru/sql" MOUNT_SQL sed -i "s|POSTGRES_USER=szuru|POSTGRES_USER=$DB_USER|; \ - s|POSTGRES_PASSWORD=changeme| POSTGRES_PASSWORD=$DB_PASS|; \ + s|POSTGRES_PASSWORD=changeme|POSTGRES_PASSWORD=$DB_PASS|; \ s|BUILD_INFO=latest|BUILD_INFO=$BUILD_INFO|; \ s|PORT=8080|PORT=$PORT|; \ s|BASE_URL=/|BASE_URL=$URL|; \ @@ -138,20 +113,31 @@ function set_env () { s|MOUNT_SQL=/var/local/szurubooru/sql|MOUNT_SQL=$MOUNT_SQL|" .env } -function final_touches () { - docker-compose pull # Download containers - docker-compose up -d sql # Start SQL first - sleep 30 # Give the database time to become available - docker-compose up -d # Start remaining containers -} - - +echo "Creating and setting up server configuration (server/config.yaml)..." server_config # Configuration via ./server/config.yaml + +echo -e "\nCreating and setting up environmental variables (.env)..." set_env # Configuration via ./.env -final_touches # Start Szurubooru + +echo -e "\nConfig is all done! Now pulling Docker containers..." +docker-compose pull # Download containers + +echo "Starting SQL container..." +docker-compose up -d sql # Start SQL first + +echo "Waiting 30s to ensure the database is ready for connection..." +sleep 30 # Give the database time to become available + +echo "Starting Server and Client containers..." +docker-compose up -d # Start remaining containers # Ensure files can be uploaded by setting ownership of the /data/ mount point puid=$(grep "PUID=" server/Dockerfile | sed "s/.*=//") -guid=$(grep "GUID=" server/Dockerfile | sed "s/.*=//") +guid=$(grep "PGID=" server/Dockerfile | sed "s/.*=//") mount=$(grep "MOUNT_DATA" .env | sed 's/MOUNT_DATA=//') -chown -R $puid:$guid "$mount" \ No newline at end of file +echo "Performing a quick ownership change of $mount to make sure images can be submitted..." +chown -R $puid:$guid "$mount" + +echo "All done! You should now be able to access Szurubooru using the port number you set." +exit 0 + From e1390633ff5959bc7969ab0b0c9f9b0167017b20 Mon Sep 17 00:00:00 2001 From: ShockDW <46183407+ShockDW@users.noreply.github.com> Date: Sun, 6 Dec 2020 02:56:39 -0600 Subject: [PATCH 4/7] Add files via upload --- install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install.sh b/install.sh index 6a992409..ddb26fc9 100755 --- a/install.sh +++ b/install.sh @@ -12,9 +12,6 @@ # avoid the need for parallel maintenance of two files. ############################################################################################# -# Check for root to ensure the accessibility of the Docker daemon, and to -# allow mount point permissions to be set after building. - echo "Welcome to Szurubooru. This install script will ask you to" echo "set a few config values, then get szurubooru up and running." From 4a23b615fc2dd23cc71574c7ed31fdf655b28d0d Mon Sep 17 00:00:00 2001 From: ShockDW <46183407+ShockDW@users.noreply.github.com> Date: Sun, 13 Dec 2020 15:04:02 -0600 Subject: [PATCH 5/7] Update install.sh - added Daemon access check Added Docker daemon access check, updated output with colorized ERROR, OK, and NOTICE flags for readability. --- install.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index ddb26fc9..2db68fdc 100755 --- a/install.sh +++ b/install.sh @@ -11,18 +11,36 @@ # * Modifies docker-compose.yml rather than relying on a static alternative file to hopefully # avoid the need for parallel maintenance of two files. ############################################################################################# +ERROR="[\e[31mERROR\e[0m]" +OK="[\e[32mOK\e[0m]" +NOTICE="[\e[33mNOTICE\e[0m]" -echo "Welcome to Szurubooru. This install script will ask you to" -echo "set a few config values, then get szurubooru up and running." +echo 'Welcome to Szurubooru. This install script will ask you to set a few basic'\ + 'config values, then get szurubooru up and running.' -# Check to ensure Docker and Docker-Compose are both installed before proceeding +echo "Checking a few things to ensure successful deployment..." + +# Check to ensure Docker and Docker-Compose are both installed and usable via standard commands if ! command -v docker &> /dev/null || ! command -v docker-compose &> /dev/null; then - echo "Both Docker and Docker-Compose must already be installed to use this script." - echo "Please ensure both are installed and accessible using commands 'docker' and 'docker-compose', then run this script again." + echo -e "${ERROR} Both Docker and Docker-Compose must already be installed to use this script." + echo " Please ensure both are installed and available using commands docker and" + echo " docker-compose, then run this script again." exit 1 -else echo "Docker and Docker-Compose verified. Continuing installation..." +else echo -e "${OK} Docker and Docker-Compose Installation verified" fi +# Check to ensure the current user can access the Docker daemon +# https://github.com/rr-/szurubooru/pull/366#discussion_r541795141 +if [[ "$(docker ps &> /dev/null | echo $?)" > 0 ]]; then + echo -e "${ERROR} Unable to verify Docker daemon access! Please ensure the current user is" + echo " authorized for Docker access." + echo " For more info, see the official Docker documentation at" + echo " https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user" + exit 1 +else echo "${OK} Docker Daemon accessible." +fi + + ######################################################################################## # Check CPU architectue and, if ARM (such as Raspberry Pi), modify docker-compose.yml # https://github.com/rr-/szurubooru/wiki/ARM-and-Raspberry-Pi-Support-for-Docker-builds @@ -30,7 +48,7 @@ fi ######################################################################################## if [[ "$(uname -m)" == 'a'* ]]; then - echo "ARM architecture detected. Modfying docker-compose.yml for local build." + echo -e "${NOTICE} ARM architecture detected. Modfying docker-compose.yml for local build." # Modify docker-compose file to build locally instead of pulling from dockerhub sed -zi "s|image: szurubooru/server:latest|build:\n context: ./server|; \ s|image: szurubooru/client:latest|build:\n context: ./client|" ./docker-compose.yml @@ -73,8 +91,8 @@ function server_config () { s|pass: |pass: $SMTP_PASS|; \ s|from: |from: $SMTP_FROM|" ./server/config.yaml else # Warn user that they should set a contact email if no smtp host is specified - echo "WARNING: No SMTP host specified!" - echo "It is recommended you set a contact email in the next prompt for manual password reset requests." + echo -e "${NOTICE} No SMTP host specified! It is strongly recommended you set a contact email" + echo " in the next prompt for manual password reset requests." fi echo "Enter your server's primary contact email address." From 05823e5dec5d4f14590263b3c2c04c5d86192618 Mon Sep 17 00:00:00 2001 From: ShockDW <46183407+ShockDW@users.noreply.github.com> Date: Sun, 13 Dec 2020 15:05:55 -0600 Subject: [PATCH 6/7] Update install.sh --- install.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 2db68fdc..8b7115c0 100755 --- a/install.sh +++ b/install.sh @@ -11,6 +11,8 @@ # * Modifies docker-compose.yml rather than relying on a static alternative file to hopefully # avoid the need for parallel maintenance of two files. ############################################################################################# + +# Colorized flags for check status output ERROR="[\e[31mERROR\e[0m]" OK="[\e[32mOK\e[0m]" NOTICE="[\e[33mNOTICE\e[0m]" @@ -66,12 +68,15 @@ function server_config () { # Prompt for Secret, proposing a randomly generated 32-character alphanumeric value as a default. default_secret="$(tr -dc '[:alnum:]' < /dev/urandom | dd bs=4 count=8 2>/dev/null)" - echo "Enter your Secret (Used to salt the users' password hashes and generate filenames for static content)"; read -e -p "> " -i "$default_secret" SECRET + echo "Enter your Secret (Used to salt the users' password hashes and generate filenames for static content)" + read -e -p "> " -i "$default_secret" SECRET sed -i "s|secret: change|secret: $SECRET|" ./server/config.yaml # Other useful (but less important) settings - echo "Enter the desired name for your server. (Shown in the website title and on the front page)"; read -e -p "> " -i "szurubooru" SERVERNAME - echo "Enter the full url to the homepage of this szurubooru site, with no trailing slash."; read -e -p "> " URL + echo "Enter the desired name for your server. (Shown in the website title and on the front page)" + read -e -p "> " -i "szurubooru" SERVERNAME + echo "Enter the full url to the homepage of this szurubooru site, with no trailing slash." + read -e -p "> " URL sed -i "s|name: szurubooru|name: $SERVERNAME|;s|domain: |domain: $URL|" ./server/config.yaml # SMTP (email) settings From bc6950538240daf37350749691d27282f06bf394 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Sat, 19 Dec 2020 16:32:29 -0500 Subject: [PATCH 7/7] doc/install: applied formatting fixes to script --- install.sh => doc/install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename install.sh => doc/install.sh (97%) diff --git a/install.sh b/doc/install.sh similarity index 97% rename from install.sh rename to doc/install.sh index 8b7115c0..89691d54 100755 --- a/install.sh +++ b/doc/install.sh @@ -1,5 +1,7 @@ #!/bin/bash +# NOTE: This script is still a work in progress + # This script is meant to automate the deployment of Szurubooru via Docker/Docker-Compose, # and to automatically take the necessary steps to allow Szurubooru to run on ARM devices # such as the Raspberry Pi. @@ -97,7 +99,7 @@ function server_config () { s|from: |from: $SMTP_FROM|" ./server/config.yaml else # Warn user that they should set a contact email if no smtp host is specified echo -e "${NOTICE} No SMTP host specified! It is strongly recommended you set a contact email" - echo " in the next prompt for manual password reset requests." + echo " in the next prompt for manual password reset requests." fi echo "Enter your server's primary contact email address." @@ -114,7 +116,7 @@ function set_env () { echo -e "\n===[Environmental Variables]===" echo "Enter your desired database username."; read -e -p "> " -i "szuru" DB_USER while true; do # Ensures the user sets a database password for security reasons. - echo "Enter your desired database password. (Will not print to console)"; read -s -p "> " DB_PASS + echo "Enter your desired database password. (Will not print to console)"; read -s -p "> " DB_PASS if [ -z $DB_PASS ]; then echo -e "\nERROR: You must set a password!"; else break; fi done echo "" @@ -160,4 +162,3 @@ chown -R $puid:$guid "$mount" echo "All done! You should now be able to access Szurubooru using the port number you set." exit 0 -