X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=usr%2Flocal%2Fbin%2Faddsite;h=cc64350d1b6620d8c59209f8557d3be55000fc1e;hb=aeb6a57aa9fd2c6567b85ac4b9ad1c60b7e3f563;hp=c7212ab63b89c44d8a000515af9ed5537485f4ed;hpb=fa0dad57ac8b38969fe2821fa0857fdc13f76e88;p=matthijs%2Fservers%2Fdrsnuggles.git diff --git a/usr/local/bin/addsite b/usr/local/bin/addsite index c7212ab..cc64350 100755 --- a/usr/local/bin/addsite +++ b/usr/local/bin/addsite @@ -1,5 +1,10 @@ #!/bin/sh +if [ "$UID" -eq 0 ]; then + echo "No need to run as root." + exit 1 +fi + if [ "$1" = "-h" -o "$1" = "--help" -o $# -ne 1 ]; then echo "Usage $0 " echo " is the full path to the site, such as /var/www/example.nl" @@ -14,23 +19,32 @@ HTTPD_USERS_GID=1002 # The template to copy TEMPLATE_DIR=/data/www/template # The bases to create users under -USERBASE=ou=Users,dc=drsnuggles,dc=stderr,dc=nl -GROUPBASE=ou=Groups,dc=drsnuggles,dc=stderr,dc=nl +USERBASE="uniqueIdentifier=7,uniqueIdentifier=6,dc=drsnuggles,dc=stderr,dc=nl" +GROUPBASE="uniqueIdentifier=4,uniqueIdentifier=8,dc=drsnuggles,dc=stderr,dc=nl" # PHP config to change the error_log setting in PHP_CONFIG=conf/php.ini.override # PHP error logfile to set error_log to PHP_ERRORLOG=logs/php.log -# Get dir, but make it absolute -cd "$1" -DIR=`pwd` - +# Get dir +DIR="$1" -if [ -e "$DIR" -a ! -d "$DIR" ]; then - echo "$DIR" must be a directory, or not exist yet. - exit 1; +if [ -e "$DIR" ]; then + if [ ! -d "$DIR" ]; then + echo "$DIR" must be a directory, or not exist yet. + exit 1; + fi + echo "Skipping creation of $DIR, it already exists"; +else + # Create $DIR from $TEMPLATE_DIR, if it does not exist yet + echo "Creating $DIR from $TEMPLATE_DIR" + cp -R "$TEMPLATE_DIR" "$DIR" fi +# Make $DIR absolute +cd "$DIR" +DIR=`pwd` + # Strip prefix SITE=`basename $DIR` @@ -54,17 +68,20 @@ else ldapvi --profile bind --add --in --ldapvi <