mirror of
https://github.com/adferrand/docker-backuppc.git
synced 2023-11-05 04:40:26 +01:00
Deals with already existing user/group backuppc
This commit is contained in:
parent
70d186880c
commit
f603a49d1d
@ -10,14 +10,26 @@ if [ -f /firstrun ]; then
|
|||||||
cp /usr/share/zoneinfo/$TZ /etc/localtime
|
cp /usr/share/zoneinfo/$TZ /etc/localtime
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create backuppc user
|
# Create backuppc user/group if needed
|
||||||
addgroup -S -g ${BACKUPPC_GUID:-1000} backuppc
|
BACKUPPC_GROUPNAME=`getent group "${BACKUPPC_GUID:-1000}" | cut -d: -f1`
|
||||||
adduser -D -S -h /home/backuppc -G backuppc -u ${BACKUPPC_UUID:-1000} backuppc
|
if [ -z "$BACKUPPC_GROUPNAME" ]; then
|
||||||
chown backuppc:backuppc /home/backuppc
|
groupadd -r -g "${BACKUPPC_GUID:-1000}" backuppc
|
||||||
|
BACKUPPC_GROUPNAME="backuppc"
|
||||||
|
fi
|
||||||
|
BACKUPPC_USERNAME=`getent group "${BACKUPPC_UUID:-1000}" | cut -d: -f1`
|
||||||
|
if [ -z "$BACKUPPC_USERNAME" ]; then
|
||||||
|
useradd -r -d /home/backuppc -g "${BACKUPPC_GUID:-1000}" -u ${BACKUPPC_UUID:-1000} -M -N backuppc
|
||||||
|
BACKUPPC_USERNAME="backuppc"
|
||||||
|
else
|
||||||
|
usermod -d /home/backuppc "$BACKUPPC_USERNAME"
|
||||||
|
fi
|
||||||
|
chown "$BACKUPPC_USERNAME":"$BACKUPPC_GROUPNAME" /home/backuppc
|
||||||
|
export BACKUPPC_USERNAME
|
||||||
|
export BACKUPPC_GROUPNAME
|
||||||
|
|
||||||
# Generate cryptographic key
|
# Generate cryptographic key
|
||||||
if [ ! -f /home/backuppc/.ssh/id_rsa ]; then
|
if [ ! -f /home/backuppc/.ssh/id_rsa ]; then
|
||||||
su backuppc -s /bin/sh -c "ssh-keygen -t rsa -N '' -f /home/backuppc/.ssh/id_rsa"
|
su "$BACKUPPC_USERNAME" -s /bin/sh -c "ssh-keygen -t rsa -N '' -f /home/backuppc/.ssh/id_rsa"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract BackupPC
|
# Extract BackupPC
|
||||||
@ -59,14 +71,14 @@ if [ -f /firstrun ]; then
|
|||||||
-subj "/C=UK/ST=Warwickshire/L=Leamington/O=OrgName/OU=IT Department/CN=example.com"
|
-subj "/C=UK/ST=Warwickshire/L=Leamington/O=OrgName/OU=IT Department/CN=example.com"
|
||||||
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
|
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
|
||||||
cat server.key server.crt > server.pem
|
cat server.key server.crt > server.pem
|
||||||
chown backuppc:backuppc server.pem
|
chown "$BACKUPPC_USERNAME":"$BACKUPPC_GROUPNAME" server.pem
|
||||||
chmod 0600 server.pem
|
chmod 0600 server.pem
|
||||||
rm -f server.pass.key server.key server.csr server.crt
|
rm -f server.pass.key server.key server.csr server.crt
|
||||||
# Reconfigure lighttpd to use ssl
|
# Reconfigure lighttpd to use ssl
|
||||||
echo "ssl.engine = \"enable\"" >> /etc/lighttpd/lighttpd.conf
|
echo "ssl.engine = \"enable\"" >> /etc/lighttpd/lighttpd.conf
|
||||||
echo "ssl.pemfile = \"/etc/lighttpd/server.pem\"" >> /etc/lighttpd/lighttpd.conf
|
echo "ssl.pemfile = \"/etc/lighttpd/server.pem\"" >> /etc/lighttpd/lighttpd.conf
|
||||||
fi
|
fi
|
||||||
touch /var/log/lighttpd/error.log && chown -R backuppc:backuppc /var/log/lighttpd
|
touch /var/log/lighttpd/error.log && chown -R "$BACKUPPC_USERNAME":"$BACKUPPC_GROUPNAME" /var/log/lighttpd
|
||||||
|
|
||||||
# Configure standard mail delivery parameters (may be overriden by backuppc user-wide config)
|
# Configure standard mail delivery parameters (may be overriden by backuppc user-wide config)
|
||||||
echo "account default" > /etc/msmtprc
|
echo "account default" > /etc/msmtprc
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
server.port = 8080
|
server.port = 8080
|
||||||
server.username = "backuppc"
|
server.username = env.BACKUPPC_USERNAME
|
||||||
server.groupname = "backuppc"
|
server.groupname = env.BACKUPPC_GROUPNAME
|
||||||
server.document-root = "/srv/http"
|
server.document-root = "/srv/http"
|
||||||
server.errorlog = "/var/log/lighttpd/error.log"
|
server.errorlog = "/var/log/lighttpd/error.log"
|
||||||
dir-listing.activate = "enable"
|
dir-listing.activate = "enable"
|
||||||
|
@ -30,4 +30,4 @@ killasgroup = true
|
|||||||
[program:backuppc]
|
[program:backuppc]
|
||||||
command = /usr/local/BackupPC/bin/BackupPC
|
command = /usr/local/BackupPC/bin/BackupPC
|
||||||
redirect_stderr = true
|
redirect_stderr = true
|
||||||
user = backuppc
|
user = %(ENV_BACKUPPC_USERNAME)s
|
||||||
|
Loading…
Reference in New Issue
Block a user