Fixes #309, removed hardcoded /home directory to apply the existing configuration options for STORAGE_USER/ROOT if they exist

This commit is contained in:
H8H 2015-02-01 18:01:33 +01:00
parent 82e752395b
commit a811e58a93
1 changed files with 18 additions and 7 deletions

View File

@ -87,17 +87,28 @@ if [ -z "$SKIP_NETWORK_CHECKS" ]; then
. setup/network-checks.sh . setup/network-checks.sh
fi fi
# For the first time (if the config file (/etc/mailinabox.conf) not exists):
# Create the user named "user-data" and store all persistent user # Create the user named "user-data" and store all persistent user
# data (mailboxes, etc.) in that user's home directory. # data (mailboxes, etc.) in that user's home directory.
if [ -z "$STORAGE_ROOT" ]; then #
STORAGE_USER=user-data # If the config file exists:
if [ ! -d /home/$STORAGE_USER ]; then useradd -m $STORAGE_USER; fi # Apply the existing configuration options for STORAGE_USER/ROOT
STORAGE_ROOT=/home/$STORAGE_USER STORAGE_USER=$([[ -z "$DEFAULT_STORAGE_USER" ]] && echo "user-data" || echo "$DEFAULT_STORAGE_USER")
mkdir -p $STORAGE_ROOT STORAGE_ROOT=$([[ -z "$DEFAULT_STORAGE_ROOT" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
echo $(setup/migrate.py --current) > $STORAGE_ROOT/mailinabox.version
chown $STORAGE_USER.$STORAGE_USER $STORAGE_ROOT/mailinabox.version # Create the STORAGE_USER if it not exists
if [ ! $(id -u $STORAGE_USER >/dev/null 2>&1;) ]; then
useradd -m $STORAGE_USER
fi fi
# Create the STORAGE_ROOT if it not exists
if [ ! -d $STORAGE_ROOT ]; then
mkdir -p $STORAGE_ROOT
fi
echo $(setup/migrate.py --current) > $STORAGE_ROOT/mailinabox.version
chown $STORAGE_USER.$STORAGE_USER $STORAGE_ROOT/mailinabox.version
# Save the global options in /etc/mailinabox.conf so that standalone # Save the global options in /etc/mailinabox.conf so that standalone
# tools know where to look for data. # tools know where to look for data.
cat > /etc/mailinabox.conf << EOF; cat > /etc/mailinabox.conf << EOF;