-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathexisting_user.sh
56 lines (47 loc) · 1.9 KB
/
existing_user.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
################################################################################
# Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
# Updated by Dirty Harry for YiiMP use... #
# This script is intended to be ran from the Yiimp Server Installer #
################################################################################
source /etc/functions.sh
cd ~/yiimpserver/install
clear
# Get logged in user name
whoami=`whoami`
echo -e " Modifying existing user $whoami for yiimp server setup support."
sudo usermod -aG sudo ${whoami}
echo '# yiimp
# It needs passwordless sudo functionality.
'""''"${whoami}"''""' ALL=(ALL) NOPASSWD:ALL
' | sudo -E tee /etc/sudoers.d/${whoami} >/dev/null 2>&1
echo '
cd ~/yiimpserver/install
bash start.sh
' | sudo -E tee /usr/bin/yiimpserver >/dev/null 2>&1
sudo chmod +x /usr/bin/yiimpserver
# Check required files and set global variables
cd $HOME/yiimpserver/install
source pre_setup.sh
# Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist.
if ! id -u $STORAGE_USER >/dev/null 2>&1; then
sudo useradd -m $STORAGE_USER
fi
if [ ! -d $STORAGE_ROOT ]; then
sudo mkdir -p $STORAGE_ROOT
fi
# Save the global options in /etc/yiimpserver.conf so that standalone
# tools know where to look for data.
echo 'STORAGE_USER='"${STORAGE_USER}"'
STORAGE_ROOT='"${STORAGE_ROOT}"'
PUBLIC_IP='"${PUBLIC_IP}"'
PUBLIC_IPV6='"${PUBLIC_IPV6}"'
DISTRO='"${DISTRO}"'
FIRST_TIME_SETUP='"${FIRST_TIME_SETUP}"'
PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpserver.conf >/dev/null 2>&1
cd ~
sudo setfacl -m u:${whoami}:rwx /home/${whoami}/yiimpserver
clear
echo -e " Your User has been modified for yiimp server setup support..."
echo -e "$RED You must reboot the system for the new permissions to update and type$COL_RESET $GREEN yiimpserver$COL_RESET $RED to continue setup...$COL_RESET"
exit 0