From abb1b05519a464564efdec2e700a3d7ca9e5d73e Mon Sep 17 00:00:00 2001 From: Christoph Roeder Date: Thu, 8 Jun 2017 13:20:45 +0200 Subject: [PATCH 1/3] do not overwrite existing htpasswd --- files/entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/files/entrypoint.sh b/files/entrypoint.sh index ebc2c82..049b205 100755 --- a/files/entrypoint.sh +++ b/files/entrypoint.sh @@ -33,7 +33,9 @@ if [ -f /firstrun ]; then --config-override CgiAdminUsers="'${BACKUPPC_WEB_USER:-backuppc}'" # Configure WEB UI access - htpasswd -b -c /etc/backuppc/htpasswd ${BACKUPPC_WEB_USER:-backuppc} ${BACKUPPC_WEB_PASSWD:-password} + if [ ! -f /etc/backuppc/htpasswd ]; then + htpasswd -b -c /etc/backuppc/htpasswd ${BACKUPPC_WEB_USER:-backuppc} ${BACKUPPC_WEB_PASSWD:-password} + fi # Prepare lighttpd if [ "$USE_SSL" = true ]; then @@ -59,8 +61,8 @@ if [ -f /firstrun ]; then echo "host ${SMTP_HOST:-mail.example.org}" >> /etc/msmtprc echo "auto_from on" >> /etc/msmtprc if [ "${SMTP_MAIL_DOMAIN:-}" != "" ]; then - echo "maildomain ${SMTP_MAIL_DOMAIN}" >> /etc/msmtprc - fi + echo "maildomain ${SMTP_MAIL_DOMAIN}" >> /etc/msmtprc + fi # Clean rm -rf /root/BackupPC-$BACKUPPC_VERSION.tar.gz /root/BackupPC-$BACKUPPC_VERSION /firstrun From 7b994d5fefb81bb0dceca5c93a730614225bbd8e Mon Sep 17 00:00:00 2001 From: Christoph Roeder Date: Thu, 8 Jun 2017 14:50:09 +0200 Subject: [PATCH 2/3] keep htpasswd if no env vars given and create a new one when not exist --- files/entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/entrypoint.sh b/files/entrypoint.sh index 049b205..ea53f8e 100755 --- a/files/entrypoint.sh +++ b/files/entrypoint.sh @@ -34,7 +34,11 @@ if [ -f /firstrun ]; then # Configure WEB UI access if [ ! -f /etc/backuppc/htpasswd ]; then - htpasswd -b -c /etc/backuppc/htpasswd ${BACKUPPC_WEB_USER:-backuppc} ${BACKUPPC_WEB_PASSWD:-password} + htpasswd -b -c /etc/backuppc/htpasswd "${BACKUPPC_WEB_USER:-backuppc}" "${BACKUPPC_WEB_PASSWD:-password}" + + elif [ -n "$BACKUPPC_WEB_USER" -a -n "$BACKUPPC_WEB_PASSWD" ]; then + touch /etc/backuppc/htpasswd + htpasswd -b /etc/backuppc/htpasswd "${BACKUPPC_WEB_USER}" "${BACKUPPC_WEB_PASSWD}" fi # Prepare lighttpd From 7483c2a615e36bc53f525bef059b4f932fa6d6dd Mon Sep 17 00:00:00 2001 From: Christoph Roeder Date: Thu, 8 Jun 2017 17:52:12 +0200 Subject: [PATCH 3/3] override CgiAdminUsers only for new installations or env vars set env vars BACKUPPC_WEB_USER and BACKUPPC_WEB_PASSWD must be set --- files/entrypoint.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/files/entrypoint.sh b/files/entrypoint.sh index ea53f8e..3269b85 100755 --- a/files/entrypoint.sh +++ b/files/entrypoint.sh @@ -20,6 +20,20 @@ if [ -f /firstrun ]; then tar xf BackupPC-$BACKUPPC_VERSION.tar.gz cd /root/BackupPC-$BACKUPPC_VERSION + # Configure WEB UI access + configure_admin="" + if [ ! -f /etc/backuppc/htpasswd ]; then + htpasswd -b -c /etc/backuppc/htpasswd "${BACKUPPC_WEB_USER:-backuppc}" "${BACKUPPC_WEB_PASSWD:-password}" + + configure_admin="--config-override CgiAdminUsers='${BACKUPPC_WEB_USER:-backuppc}'" + + elif [ -n "$BACKUPPC_WEB_USER" -a -n "$BACKUPPC_WEB_PASSWD" ]; then + touch /etc/backuppc/htpasswd + htpasswd -b /etc/backuppc/htpasswd "${BACKUPPC_WEB_USER}" "${BACKUPPC_WEB_PASSWD}" + + configure_admin="--config-override CgiAdminUsers='$BACKUPPC_WEB_USER'" + fi + # Install BackupPC (existing configuration will be reused and upgraded) perl configure.pl \ --batch \ @@ -30,16 +44,7 @@ if [ -f /firstrun ]; then --html-dir /var/www/html/BackupPC \ --html-dir-url /BackupPC \ --install-dir /usr/local/BackupPC \ - --config-override CgiAdminUsers="'${BACKUPPC_WEB_USER:-backuppc}'" - - # Configure WEB UI access - if [ ! -f /etc/backuppc/htpasswd ]; then - htpasswd -b -c /etc/backuppc/htpasswd "${BACKUPPC_WEB_USER:-backuppc}" "${BACKUPPC_WEB_PASSWD:-password}" - - elif [ -n "$BACKUPPC_WEB_USER" -a -n "$BACKUPPC_WEB_PASSWD" ]; then - touch /etc/backuppc/htpasswd - htpasswd -b /etc/backuppc/htpasswd "${BACKUPPC_WEB_USER}" "${BACKUPPC_WEB_PASSWD}" - fi + $configure_admin # Prepare lighttpd if [ "$USE_SSL" = true ]; then