2 DIR
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5 if [ "$1" == "2container" ]
8 echo "2container argument is deprecated. Use --two-container"
12 while [ ${#} -gt 0 ]; do
24 --skip-connection-test)
25 SKIP_CONNECTION_TEST
="1"
26 echo "skipping connection test"
34 ## Make sure only root can run our script
37 if [[ $EUID -ne 0 ]]; then
38 echo "This script must be run as root. Please sudo or log in as root first." 1>&2
44 ## Check whether a connection to HOSTNAME ($1) on PORT ($2) is possible
49 VERIFY
=$
(date +%s | sha256sum | base64 |
head -c 20)
50 if ! [ -x "$(command -v nc)" ]; then
51 echo "In order to check the connection to $HOST:$PORT we need to open a socket using netcat."
52 echo However netcat is not installed on your system. You can
continue without this check
53 echo or abort the setup
, install netcat and try again.
55 read -p "Would you like to continue without this check? [yn] " yn
59 *) echo "Please answer y or n." ;;
63 echo -e "HTTP/1.1 200 OK\n\n $VERIFY" | nc
-w 4 -l -p $PORT >/dev
/null
2>&1 &
64 if curl
--proto =http
-s $HOST:$PORT --connect-timeout 3 |
grep $VERIFY >/dev
/null
2>&1; then
67 curl
--proto =http
-s localhost
:$PORT >/dev
/null
2>&1
76 if [ "$SKIP_CONNECTION_TEST" == 1 ]
78 echo "Setting EC to 2"
81 echo Checking your domain name . . .
82 connect_to_port
$HOST 443; ec
=$?
86 echo "Connection to $HOST succeeded."
89 echo "WARNING: Port 443 of computer does not appear to be accessible using hostname: $HOST."
90 if connect_to_port
$HOST 80; then
92 echo SUCCESS
: A connection to port
80 succeeds
!
93 echo This suggests that your DNS settings are correct
,
94 echo but something is keeping traffic to port
443 from getting to your server.
95 echo Check your networking configuration to see that connections to port
443 are allowed.
97 echo "WARNING: Connection to http://$HOST (port 80) also fails."
99 echo "This suggests that $HOST resolves to some IP address that does not reach this "
100 echo machine where you are installing discourse.
103 echo "The first thing to do is confirm that $HOST resolves to the IP address of this server."
104 echo You usually
do this
at the same place you purchased the domain.
106 echo If you are sure that the IP address resolves correctly
, it could be a firewall issue.
107 echo A web search
for \"open ports YOUR CLOUD SERVICE
\" might
help.
109 echo This tool is designed only
for the most standard installations. If you cannot resolve
110 echo the issue above
, you will need to edit containers
/app.yml yourself and
then type
112 echo .
/launcher rebuild app
117 echo "Skipping port check."
123 ## Do we have docker?
127 (which docker ||
which docker.io
) &>/dev
/null
130 check_and_install_docker
() {
131 if ! check_docker
; then
132 echo Failed to
find docker or docker.io on your PATH.
133 read -p "Enter to install Docker from https://get.docker.com/ or Ctrl+C to exit"
134 curl https
://get.docker.com
/ | sh
136 if ! check_docker
; then
137 echo Still failed to
find docker or docker.io on your PATH.
138 echo Docker
install failed. Quitting.
145 ## What are we running on
152 ## macOS available memory
154 check_macos_memory
() {
155 echo $
(($
(memory_pressure |
head -n 1 |
awk '{ print $4 }') / 1024 / 1024 / 1024))
159 ## Linux available memory
161 check_linux_memory
() {
162 ## some VMs report just under 1GB of RAM, so
163 ## make an exception and allow those with more
165 mem
=`free -m --si | awk ' /Mem:/ {print $2}'`
166 if [ "$mem" -ge 990 -a "$mem" -lt 1000 ]; then
169 echo `free -g --si | awk ' /Mem:/ {print $2} '`
174 ## Do we have enough memory and disk space for Discourse?
176 check_disk_and_memory
() {
179 if [ "$os_type" == "Darwin" ]; then
180 avail_mem
=$
(check_macos_memory
)
182 avail_mem
=$
(check_linux_memory
)
185 if [ "$avail_mem" -lt 1 ]; then
186 echo "WARNING: Discourse requires 1GB RAM to run. This system does not appear"
187 echo "to have sufficient memory."
189 echo "Your site may not work properly, or future upgrades of Discourse may not"
190 echo "complete successfully."
194 if [ "$avail_mem" -le 2 ]; then
195 total_swap
=`free -g --si | awk ' /Swap:/ {print $2} '`
197 if [ "$total_swap" -lt 2 ]; then
198 echo "WARNING: Discourse requires at least 2GB of swap when running with 2GB of RAM"
199 echo "or less. This system does not appear to have sufficient swap space."
201 echo "Without sufficient swap space, your site may not work properly, and future"
202 echo "upgrades of Discourse may not complete successfully."
204 echo "Ctrl+C to exit or wait 5 seconds to have a 2GB swapfile created."
208 ## derived from https://meta.discourse.org/t/13880
210 install -o root
-g root
-m 0600 /dev
/null
/swapfile
211 fallocate
-l 2G
/swapfile
214 echo "/swapfile swap swap auto 0 0" |
tee -a /etc
/fstab
215 sysctl
-w vm.swappiness
=10
216 echo 'vm.swappiness = 10' > /etc
/sysctl.d
/30-discourse-swap.conf
218 total_swap
=`free -g --si | awk ' /Swap:/ {print $2} '`
219 if [ "$total_swap" -lt 2 ]; then
220 echo "Failed to create swap: are you root? Are you running on real hardware, or a fully virtualized server?"
227 free_disk
="$(df /var | tail -n 1 | awk '{print $4}')"
228 if [ "$free_disk" -lt 5000 ]; then
229 echo "WARNING: Discourse requires at least 5GB free disk space. This system"
230 echo "does not appear to have sufficient disk space."
232 echo "Insufficient disk space may result in problems running your site, and"
233 echo "may not even allow Discourse installation to complete successfully."
235 echo "Please free up some space, or expand your disk, before continuing."
237 echo "Run \`apt-get autoremove && apt-get autoclean\` to clean up unused"
238 echo "packages and \`./launcher cleanup\` to remove stale Docker containers."
246 ## If we have lots of RAM or lots of CPUs, bump up the defaults to scale better
248 scale_ram_and_cpu
() {
250 local changelog
=/tmp
/changelog.
$PPID
251 # grab info about total system ram and physical (NOT LOGICAL!) CPU cores
255 if [ "$os_type" == "Darwin" ]; then
256 avail_gb
=$
(check_macos_memory
)
257 avail_cores
=`sysctl hw.ncpu | awk '/hw.ncpu:/ {print $2}'`
259 avail_gb
=$
(check_linux_memory
)
260 avail_cores
=$
((`awk '/cpu cores/ {print $4;exit}' /proc/cpuinfo`*`sort /proc/cpuinfo | uniq | grep -c "physical id"`))
262 echo "Found ${avail_gb}GB of memory and $avail_cores physical CPU cores"
264 # db_shared_buffers: 128MB for 1GB, 256MB for 2GB, or 256MB * GB, max 4096MB
265 if [ "$avail_gb" -eq "1" ]
267 db_shared_buffers
=128
269 if [ "$avail_gb" -eq "2" ]
271 db_shared_buffers
=256
273 db_shared_buffers
=$
(( 256 * $avail_gb ))
276 db_shared_buffers
=$
(( db_shared_buffers
< 4096 ? db_shared_buffers
: 4096 ))
278 sed -i -e "s/^ #\?db_shared_buffers:.*/ db_shared_buffers: \"${db_shared_buffers}MB\"/w $changelog" $data_file
281 echo "setting db_shared_buffers = ${db_shared_buffers}MB"
285 # UNICORN_WORKERS: 2 * GB for 2GB or less, or 2 * CPU, max 8
286 if [ "$avail_gb" -le "2" ]
288 unicorn_workers
=$
(( 2 * $avail_gb ))
290 unicorn_workers
=$
(( 2 * $avail_cores ))
292 unicorn_workers
=$
(( unicorn_workers
< 8 ? unicorn_workers
: 8 ))
294 sed -i -e "s/^ #\?UNICORN_WORKERS:.*/ UNICORN_WORKERS: ${unicorn_workers}/w $changelog" $web_file
297 echo "setting UNICORN_WORKERS = ${unicorn_workers}"
301 echo $data_file memory parameters updated.
306 ## standard http / https ports must not be occupied
311 echo "Ports 80 and 443 are free for use"
316 ## check a port to see if it is already in use
320 local valid
=$
(lsof
-i:${1} |
grep "LISTEN")
322 if [ -n "$valid" ]; then
323 echo "Port ${1} appears to already be in use."
325 echo "This will show you what command is using port ${1}"
326 lsof
-i tcp
:${1} -s tcp
:listen
328 echo "If you are trying to run Discourse simultaneously with another web"
329 echo "server like Apache or nginx, you will need to bind to a different port"
331 echo "See https://meta.discourse.org/t/17247"
333 echo "If you are reconfiguring an already-configured Discourse, use "
335 echo "./launcher stop app"
337 echo "to stop Discourse before you reconfigure it and try again."
343 ## read a variable from the config file
346 config_line
=`egrep "^ #?$1:" $web_file`
347 read_config_result
=`echo $config_line | awk -F":" '{print $2}'`
348 read_config_result
=`echo $read_config_result | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"`
352 config_line
=`egrep "^ #?$1:" samples/standalone.yml`
353 read_default_result
=`echo $config_line | awk -F":" '{print $2}'`
354 read_default_result
=`echo $read_config_result | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"`
357 assert_maxmind_license_key
() {
358 if ! grep DISCOURSE_MAXMIND_LICENSE_KEY
$web_file >/dev
/null
2>&1
360 echo "Adding MAXMIND placeholder to $web_file"
361 sed -i '/^.*LETSENCRYPT_ACCOUNT_EMAIL.*/a \ \ #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456' $web_file
363 if ! grep DISCOURSE_MAXMIND_LICENSE_KEY
$web_file >/dev
/null
2>&1
367 Adding DISCOURSE_MAXMIND_LICENSE_KEY to $web_file has failed! This
368 indicates either that your $web_file is very old or otherwise not
369 what the script expects or that there is a bug in this script. The
370 best solution for a novice is to delete $web_file and start over.
371 An expert might prefer to edit $web_file by hand.
374 read -p "Press return to continue or control-c to quit..."
378 assert_smtp_domain
() {
379 if ! grep DISCOURSE_SMTP_DOMAIN
$web_file >/dev
/null
2>&1
381 echo "Adding SMTP_DOMAIN placeholder to $web_file"
382 sed -i '/^.*DISCOURSE_SMTP_PASSWORD.*/a \ \ #DISCOURSE_SMTP_DOMAIN: discourse.example.com # (required by some providers)' $web_file
384 if ! grep DISCOURSE_SMTP_DOMAIN
$web_file >/dev
/null
2>&1
388 Adding DISCOURSE_SMTP_DOMAIN to $web_file has failed! This
389 indicates either that your $web_file is very old or otherwise not
390 what the script expects or that there is a bug in this script. The
391 best solution for a novice is to delete $web_file and start over.
392 An expert might prefer to edit $web_file by hand.
395 read -p "Press return to continue or control-c to quit..."
400 assert_notification_email
() {
401 if ! grep DISCOURSE_NOTIFICATION_EMAIL
$web_file >/dev
/null
2>&1
403 echo "Adding DISCOURSE_NOTIFICATION_EMAIL placeholder to $web_file"
404 sed -i '/^.*DISCOURSE_SMTP_PASSWORD.*/a \ \ #DISCOURSE_NOTIFICATION_EMAIL: nobody@discourse.example.com # (address to send notifications from)' $web_file
406 if ! grep DISCOURSE_NOTIFICATION_EMAIL
$web_file >/dev
/null
2>&1
410 Adding DISCOURSE_NOTIFICATION_EMAIL to $web_file has failed! This
411 indicates either that your $web_file is very old or otherwise not
412 what the script expects or that there is a bug in this script. The
413 best solution for a novice is to delete $web_file and start over.
414 An expert might prefer to edit $web_file by hand.
417 read -p "Press return to continue or control-c to quit..."
423 ## prompt user for typical Discourse config file values
425 ask_user_for_config
() {
427 # NOTE: Defaults now come from standalone.yml
429 read_config
"DISCOURSE_HOSTNAME"
430 hostname
=$read_config_result
431 local changelog
=/tmp
/changelog.
$PPID
432 read_config
"DISCOURSE_SMTP_ADDRESS"
433 local smtp_address
=$read_config_result
434 # NOTE: if there are spaces between emails, this breaks, but a human should be paying attention
435 read_config
"DISCOURSE_DEVELOPER_EMAILS"
436 local developer_emails
=$read_config_result
437 read_config
"DISCOURSE_SMTP_PASSWORD"
438 local smtp_password
=$read_config_result
439 read_config
"DISCOURSE_SMTP_PORT"
440 local smtp_port
=$read_config_result
441 read_config
"DISCOURSE_SMTP_USER_NAME"
442 local smtp_user_name
=$read_config_result
443 if [ "$smtp_password" = "pa$$word" ]
447 read_config
"DISCOURSE_NOTIFICATION_EMAIL"
448 local notification_email
=$read_config_result
449 read_config
"DISCOURSE_SMTP_DOMAIN"
450 local discourse_smtp_DOMAIN
=$read_config_result
452 read_config
"LETSENCRYPT_ACCOUNT_EMAIL"
453 local letsencrypt_account_email
=$read_config_result
454 if [ -z $letsencrypt_account_email ]
456 letsencrypt_account_email
="me@example.com"
458 if [ "$letsencrypt_account_email" = "me@example.com" ]
460 local letsencrypt_status
="ENTER to skip"
462 local letsencrypt_status
="Enter 'OFF' to disable."
465 read_config
"DISCOURSE_MAXMIND_LICENSE_KEY"
466 local maxmind_license_key
=$read_config_result
467 if [ -z $maxmind_license_key ]
469 maxmind_license_key
="1234567890123456"
471 if [ "$maxmind_license_key" == "1234567890123456" ]
473 local maxmind_status
="ENTER to continue without MAXMIND GeoLite2 geolocation database"
482 while [[ "$config_ok" == "n" ]]
484 if [ ! -z "$hostname" ]
486 read -p "Hostname for your Discourse? [$hostname]: " new_value
487 if [ ! -z "$new_value" ]
489 hostname
="$new_value"
491 if [[ $hostname =~ ^
[0-9]{1,3}\.
[0-9]{1,3}\.
[0-9]{1,3}\.
[0-9]{1,3}$
]]
494 echo "Discourse requires a DNS hostname. IP addresses are unsupported and will not work."
496 hostname
="discourse.example.com"
500 check_IP_match
$hostname
502 if [ ! -z "$developer_emails" ]
504 local email_valid
="n"
505 until [ "$email_valid" == "y" ]
507 read -p "Email address for admin account(s)? [$developer_emails]: " new_value
508 if [ ! -z "$new_value" ]
510 if [[ ${#new_value} -ge 7 && $new_value == *@
* ]]
512 developer_emails
="$new_value"
516 echo "[Error] Invalid email address"
525 if [ ! -z "$smtp_address" ]
527 read -p "SMTP server address? [$smtp_address]: " new_value
528 if [ ! -z "$new_value" ]
530 smtp_address
="$new_value"
534 if [ ! -z "$smtp_port" ]
536 read -p "SMTP port? [$smtp_port]: " new_value
537 if [ ! -z "$new_value" ]
539 smtp_port
="$new_value"
544 ## automatically set correct user name based on common mail providers unless it's been set
546 if [ "$smtp_user_name" == "user@example.com" ]
548 if [ "$smtp_address" == "smtp.sparkpostmail.com" ]
550 smtp_user_name
="SMTP_Injection"
552 if [ "$smtp_address" == "smtp.sendgrid.net" ]
554 smtp_user_name
="apikey"
556 if [ "$smtp_address" == "smtp.mailgun.org" ]
558 smtp_user_name
="postmaster@$hostname"
562 if [ ! -z "$smtp_user_name" ]
564 read -p "SMTP user name? [$smtp_user_name]: " new_value
565 if [ ! -z "$new_value" ]
567 smtp_user_name
="$new_value"
571 read -p "SMTP password? [$smtp_password]: " new_value
572 if [ ! -z "$new_value" ]
574 smtp_password
="$new_value"
577 if [[ "$notification_email" == "noreply@discourse.example.com"* ]]
579 notification_email
="noreply@$hostname"
582 read -p "notification email address? [$notification_email]: " new_value
583 if [ ! -z "$new_value" ]
585 notification_email
="$new_value"
588 # set smtp_domain default value here rather than use Rails default of localhost
589 smtp_domain
=$
(echo $notification_email |
sed -e "s/.*@//")
591 if [ ! -z $letsencrypt_account_email ]
593 read -p "Optional email address for Let's Encrypt warnings? ($letsencrypt_status) [$letsencrypt_account_email]: " new_value
594 if [ ! -z "$new_value" ]
596 letsencrypt_account_email
="$new_value"
597 if [ "${new_value,,}" = "off" ]
599 letsencrypt_status
="ENTER to skip"
601 letsencrypt_status
="Enter 'OFF' to disable."
606 read_config
"DISCOURSE_MAXMIND_LICENSE_KEY"
607 local maxmind_license_key
=$read_config_result
608 read -p "Optional Maxmind License key ($maxmind_status) [$maxmind_license_key]: " new_value
609 if [ ! -z "$new_value" ]
611 maxmind_license_key
="$new_value"
614 echo -e "\nDoes this look right?\n"
615 echo "Hostname : $hostname"
616 echo "Email : $developer_emails"
617 echo "SMTP address : $smtp_address"
618 echo "SMTP port : $smtp_port"
619 echo "SMTP username : $smtp_user_name"
620 echo "SMTP password : $smtp_password"
621 echo "Notification email: $notification_email"
623 if [ "$letsencrypt_status" == "Enter 'OFF' to disable." ]
625 echo "Let's Encrypt : $letsencrypt_account_email"
628 if [ "$maxmind_license_key" != "1234567890123456" ]
630 echo "Maxmind license: $maxmind_license_key"
632 echo "Maxmind license: (unset)"
636 read -p "ENTER to continue, 'n' to try again, Ctrl+C to exit: " config_ok
639 sed -i -e "s/^ DISCOURSE_HOSTNAME:.*/ DISCOURSE_HOSTNAME: $hostname/w $changelog" $web_file
644 echo "DISCOURSE_HOSTNAME change failed."
648 sed -i -e "s/^ DISCOURSE_DEVELOPER_EMAILS:.*/ DISCOURSE_DEVELOPER_EMAILS: \'$developer_emails\'/w $changelog" $web_file
653 echo "DISCOURSE_DEVELOPER_EMAILS change failed."
657 sed -i -e "s/^ DISCOURSE_SMTP_ADDRESS:.*/ DISCOURSE_SMTP_ADDRESS: $smtp_address/w $changelog" $web_file
662 echo "DISCOURSE_SMTP_ADDRESS change failed."
666 sed -i -e "s/^ #\?DISCOURSE_SMTP_PORT:.*/ DISCOURSE_SMTP_PORT: $smtp_port/w $changelog" $web_file
671 echo "DISCOURSE_SMTP_PORT change failed."
675 sed -i -e "s/^ #\?DISCOURSE_SMTP_USER_NAME:.*/ DISCOURSE_SMTP_USER_NAME: $smtp_user_name/w $changelog" $web_file
680 echo "DISCOURSE_SMTP_USER_NAME change failed."
684 sed -i -e "s/^ #\?DISCOURSE_NOTIFICATION_EMAIL:.*/ DISCOURSE_NOTIFICATION_EMAIL: $notification_email/w $changelog" $web_file
689 echo "DISCOURSE_NOTIFICATION_EMAIL change failed."
693 sed -i -e "s/^ #\?DISCOURSE_SMTP_DOMAIN:.*/ DISCOURSE_SMTP_DOMAIN: $smtp_domain/w $changelog" $web_file
698 echo "DISCOURSE_SMTP_DOMAIN change failed."
702 if [[ "$smtp_password" == *"\""* ]]
705 echo "========================================"
707 echo "Your password contains a quote (\")"
708 echo "Your SMTP Password will not be set. You will need to edit app.yml to enter it."
709 echo "========================================"
713 if [[ "$smtp_password" == *"$SLASH"* ]]
715 if [[ "$smtp_password" == *"$SLASH"* ]]
718 if [[ "$smtp_password" == *"$SLASH"* ]]
721 echo "========================================"
723 echo "Your password contains all available delimiters (+, |, and Q). "
724 echo "Your SMTP Password will not be set. You will need to edit app.yml to enter it."
725 echo "========================================"
731 if [[ "$SLASH" != "BROKEN" ]]
733 sed -i -e "s${SLASH}^ #\?DISCOURSE_SMTP_PASSWORD:.*${SLASH} DISCOURSE_SMTP_PASSWORD: \"${smtp_password}\"${SLASH}w $changelog" $web_file
739 echo "DISCOURSE_SMTP_PASSWORD change failed."
746 echo "Enabling Let's Encrypt"
748 sed -i -e "s/^ #\?LETSENCRYPT_ACCOUNT_EMAIL:.*/ LETSENCRYPT_ACCOUNT_EMAIL: $letsencrypt_account_email/w $changelog" $web_file
753 echo "LETSENCRYPT_ACCOUNT_EMAIL change failed."
756 local src
='^ #\?- "templates\/web.ssl.template.yml"'
757 local dst
=' \- "templates\/web.ssl.template.yml"'
758 sed -i -e "s/$src/$dst/w $changelog" $web_file
763 echo "web.ssl.template.yml enabled"
767 echo "web.ssl.template.yml NOT ENABLED--was it on already?"
769 local src
='^ #\?- "templates\/web.letsencrypt.ssl.template.yml"'
770 local dst
=' - "templates\/web.letsencrypt.ssl.template.yml"'
772 sed -i -e "s/$src/$dst/w $changelog" $web_file
775 echo "letsencrypt.ssl.template.yml enabled"
778 echo "letsencrypt.ssl.template.yml NOT ENABLED -- was it on already?"
782 if [ $maxmind_license_key != "1234567890123456" ]
784 sed -i -e "s/^.*DISCOURSE_MAXMIND_LICENSE_KEY:.*/ DISCOURSE_MAXMIND_LICENSE_KEY: $maxmind_license_key/w $changelog" $web_file
789 echo "DISCOURSE_MAXMIND_LICENSE_KEY change failed."
794 if [ "$update_ok" == "y" ]
796 echo -e "\nConfiguration file at $web_file updated successfully!\n"
798 echo -e "\nUnfortunately, there was an error changing $web_file\n"
799 echo -e "This may happen if you have made unexpected changes."
805 ## is our config file valid? Does it have the required fields set?
811 for x
in DISCOURSE_SMTP_ADDRESS DISCOURSE_SMTP_USER_NAME DISCOURSE_SMTP_PASSWORD \
812 DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME
815 local result
=$read_config_result
817 local default
=$read_default_result
819 if [ ! -z "$result" ]
821 if [[ "$config_line" = *"$default"* ]]
823 echo "$x left at incorrect default of $default"
826 config_val
=`echo $config_line | awk '{print $2}'`
827 if [ -z $config_val ]
829 echo "$x was not configured"
833 echo "$x not present"
838 if [ "$valid_config" != "y" ]; then
839 echo -e "\nSorry, these $web_file settings aren't valid -- can't continue!"
840 echo "If you have unusual requirements, edit $web_file and then: "
841 echo "./launcher bootstrap $app_name"
848 ## template file names
851 if [ "$TWO_CONTAINER" ] ||
[ -f containers
/web_only.yml
]
855 web_template
=samples
/web_only.yml
856 data_template
=samples
/data.yml
857 web_file
=containers
/$app_name.yml
858 data_file
=containers
/$data_name.yml
862 web_template
=samples
/standalone.yml
864 web_file
=containers
/$app_name.yml
865 data_file
=containers
/$app_name.yml
867 changelog
=/tmp
/changelog
870 ## Check requirements before creating a copy of a config file we won't edit
873 check_and_install_docker
874 check_disk_and_memory
876 if [ -a "$web_file" ]
878 echo "The configuration file $web_file already exists!"
880 echo ". . . reconfiguring . . ."
883 DATE
=`date +"%Y-%m-%d-%H%M%S"`
884 BACKUP
=$app_name.yml.
$DATE.bak
885 echo Saving old
file as
$BACKUP
886 install -m0600 $web_file containers
/$BACKUP
887 if [ "$DEBUG" != "1" ]
889 echo "Stopping existing container in 5 seconds or Control-C to cancel."
892 echo "DEBUG MODE ON. Not stopping the container."
894 .
/launcher stop
$app_name
895 assert_maxmind_license_key
896 assert_notification_email
900 if [ "$SKIP_CONNECTION_TEST" != 1 ]
904 install -v -m0600 $web_template $web_file
905 if [ "$data_name" == "data" ]
907 echo "--------------------------------------------------"
908 echo "This two container setup is currently unsupported. Use at your own risk!"
909 echo "--------------------------------------------------"
910 DISCOURSE_DB_PASSWORD
=`date +%s | sha256sum | base64 | head -c 20`
912 sed -i -e "s/DISCOURSE_DB_PASSWORD: SOME_SECRET/DISCOURSE_DB_PASSWORD: $DISCOURSE_DB_PASSWORD/w $changelog" $web_file
917 echo "Problem changing DISCOURSE_DB_PASSWORD" in $web_file
920 install -v -m0600 $data_template $data_file
922 sed -i -e "s/password ${quote}SOME_SECRET${quote}/password '$DISCOURSE_DB_PASSWORD'/w $changelog" $data_file
927 echo "Problem changing DISCOURSE_DB_PASSWORD" in $data_file
937 ## if we reach this point without exiting, OK to proceed
938 ## rebuild won't fail if there's nothing to rebuild and does the restart
940 if [ "$SKIP_REBUILD" ]
942 echo "Updates successful. --skip-rebuild requested. Exiting."
946 echo "Updates successful. Rebuilding in 5 seconds."
947 sleep 5 # Just a chance to ^C in case they were too fast on the draw
949 if [ "$data_name" == "$app_name" ]
951 echo Building
$app_name
952 .
/launcher rebuild
$app_name
954 echo Building
$data_name now . . .
955 .
/launcher rebuild
$data_name
956 echo Building
$app_name now . . .
957 .
/launcher rebuild
$app_name