summaryrefslogtreecommitdiff
path: root/adduser.local
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-10-24 16:21:40 +0200
committerJonas Smedegaard <dr@jones.dk>2010-10-24 16:21:40 +0200
commit6954cf10b82e7bf1f3a8cc243796ab9e30b3be4c (patch)
tree6f6e75aae45b852a0a694c3c8e48b109ca950b50 /adduser.local
parenta0fe32ae0ec701890023ba34f6296aeea3a00dd7 (diff)
Add web extension, asked for human accounts, and auto-added for www-* aux accounts.
Diffstat (limited to 'adduser.local')
-rwxr-xr-xadduser.local53
1 files changed, 53 insertions, 0 deletions
diff --git a/adduser.local b/adduser.local
index a526ab2..1c35450 100755
--- a/adduser.local
+++ b/adduser.local
@@ -44,6 +44,10 @@ add2list() { /bin/echo "$1" | /usr/sbin/add_members -w y -a y -r - "$2"; }
# resolve account profiles
case "$NEWUSERNAME" in
+ www-*)
+ profile_aux=1
+ profile_web=1
+ ;;
*-*)
profile_aux=1
;;
@@ -157,6 +161,55 @@ if [ -z "$profile_aux" ] && [ -n "$VERBOSE" ] && [ "$VERBOSE" -gt 0 ]; then
esac
fi
+if [ -z "$profile_aux" ] && [ -z "$profile_web" ] && [ -n "$VERBOSE" ] && [ "$VERBOSE" -gt 0 ] && [ -d /var/www ]; then
+ echo -n "Setup web hosting for this user (y/N)?"
+ read webuser
+ case $webuser in
+ y|Y)
+ profile_web=1
+ ;;
+ *)
+ ;;
+ esac
+fi
+
+if [ -n "$profile_aux" ] && [ -d /var/www ]; then
+ webroot="$NEWHOMEDIR/public_websites"
+ cgiroot="$NEWHOMEDIR/public_cgi"
+ dataroot="$NEWHOMEDIR/private_webdata"
+ webmount="/var/www/vhosts/$NEWUSERNAME"
+ cgimount="/var/www/cgi-vhosts/$NEWUSERNAME"
+
+ echo >&2 "Adding private and public subdirs in homedir ..."
+ install -d -o "$NEWUID" -g "$NEWGID" "$webroot" "$cgiroot"
+ install -d -o "$NEWUID" -g "$NEWGID" -m 0750 "$dataroot"
+
+ echo >&2 "Adding subdirs below /var/www ..."
+ install -d "$webmount" "$cgimount"
+
+ echo >&2 "Adding bind mount entries to /etc/fstab ..."
+ webroot="$webroot" cgiroot="$cgiroot" webmount="$webmount" cgimount="$cgimount" perl -w -p -0 -i.old \
+ -e 'my $webroot = $ENV{"webroot"};' \
+ -e 'my $cgiroot = $ENV{"cgiroot"};' \
+ -e 'my $webmount = $ENV{"webmount"};' \
+ -e 'my $cgimount = $ENV{"cgimount"};' \
+ -e 'if (s/\n[# ]*($webroot[ \t]+$webmount[ \t]+[^\n]+)/\n$1/) {' \
+ -e '$web_seen++;' \
+ -e 'print STDERR "Using existing web entry in fstab\n";' \
+ -e '};' \
+ -e 'if (s/\n[# ]*($cgiroot[ \t]+$cgimount[ \t]+[^\n]+)/\n$1/) {' \
+ -e '$cgi_seen++;' \
+ -e 'print STDERR "Using existing cgi entry in fstab\n";' \
+ -e '};' \
+ -e 's/$/\n$webroot\t$webmount\tauto\tbind\n/ unless $web_seen;' \
+ -e 's/\n[# ]*($webroot[ \t]+$webmount[ \t]+[^\n]+)/\n$1\n$cgiroot\t$cgimount\tauto\tbind/ unless $cgi_seen;' \
+ /etc/fstab
+
+ echo >&2 "Mount web and cgi subdirs ..."
+ mount "$webmount"
+ mount "$cgimount"
+fi
+
if [ -z "$profile_aux" ] && [ -x /usr/local/sbin/user-init ]; then
/usr/local/sbin/user-init $NEWUSERNAME
fi