override CgiAdminUsers only for new installations or env vars set

env vars  BACKUPPC_WEB_USER and BACKUPPC_WEB_PASSWD must be set
This commit is contained in:
Christoph Roeder 2017-06-08 17:52:12 +02:00
parent 7b994d5fef
commit 7483c2a615

View File

@ -20,6 +20,20 @@ if [ -f /firstrun ]; then
tar xf BackupPC-$BACKUPPC_VERSION.tar.gz tar xf BackupPC-$BACKUPPC_VERSION.tar.gz
cd /root/BackupPC-$BACKUPPC_VERSION 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) # Install BackupPC (existing configuration will be reused and upgraded)
perl configure.pl \ perl configure.pl \
--batch \ --batch \
@ -30,16 +44,7 @@ if [ -f /firstrun ]; then
--html-dir /var/www/html/BackupPC \ --html-dir /var/www/html/BackupPC \
--html-dir-url /BackupPC \ --html-dir-url /BackupPC \
--install-dir /usr/local/BackupPC \ --install-dir /usr/local/BackupPC \
--config-override CgiAdminUsers="'${BACKUPPC_WEB_USER:-backuppc}'" $configure_admin
# 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
# Prepare lighttpd # Prepare lighttpd
if [ "$USE_SSL" = true ]; then if [ "$USE_SSL" = true ]; then