-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd-site-to-user
59 lines (37 loc) · 1.36 KB
/
add-site-to-user
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
57
58
59
#!/bin/bash
# Set bash environment error management
set -e
set -u
# Source local functions file
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $script_dir/functions
# Check for root user runtime
check_root
################################################################################
# Source openspace functions file
source_os_functions
################################################################################
os-define_formatting
define_vars
echo
################################################################################
echo "${b}Adding site access to SFTP user...${x}"
echo
choose_local_user
choose_local_site
echo "${b}Adding access to site | ${g}$sel_site${x}${b} | to SFTP user | ${g}$sel_user${x}${b} |...${x}"
echo
sudo -u $sel_user mkdir -p /home/$sel_user/www/$sel_site_name
if ! grep -q "/home/$sel_user/www/$sel_site_name" /etc/fstab
then
echo "${b}Adding line to fstab...${x}"
echo
echo "bindfs#$sel_site /home/$sel_user/www/$sel_site_name fuse force-user=$sel_user,force-group=$sel_user,create-for-user=www-data,create-for-group=www-data,create-with-perms=0770,chgrp-ignore,chown-ignore,chmod-ignore 0 0" >> /etc/fstab
else
echo "${b}Site already present in fstab...${x}"
echo
echo site already added for user to fstab
fi
mount -a &> /dev/null
echo "${b}Finished site access to SFTP user.${x}"
echo