#!/bin/zsh # # Ein Skript, das fuer jede Splinenutzerin eine # Subdomain [.userpage].spline[.inf.fu-berlin].de # anlegt. # 2003-04-09 [stb] # 2003-05-25 [yann] Anpassung um Logfiles und cgi-bin # 2005-11-15 [stb] Anpassung an neues Serverlayout # 2005-11-16 [yann] Ergaenzung ohne "userpage" # PHP_VER="7.4" exec 3>&1 if [[ "$1" != "--debug" ]] then exec >/dev/null fi SPLINEUSERS=$(ldapsearch -LLL -x -b "ou=People,dc=spline,dc=inf,dc=fu-berlin,dc=de" uid | grep "^uid" | cut -d" " -f2 | sort) TMPFILEDNS=$(mktemp /tmp/userSubGenerate-dns.XXXXXX) TMPFILEAPACHEVHOSTS=$(mktemp /tmp/userSubGenerate-apache-vhosts.XXXXXX) TMPFILEAPACHEGLOBAL=$(mktemp /tmp/userSubGenerate-apache-global.XXXXXX) TMPFILEPHP=$(mktemp /tmp/userSubGenerate-php-fpm.XXXXXX) cat < $TMPFILEDNS ; Diese Datei wird automatisch generiert! ; Eintragungen von Hand sind sinnlos! ; ; Siehe plonk:/usr/local/bin/userSubGenerate ; ; ; Fuer jede Nutzerin bei spline gibt es eine Subdomain ; [.userpage].spline[.inf.fu-berlin].de, die dann vom ; Apache auf ~ aufgeloest wird. EOF cat < $TMPFILEAPACHEVHOSTS # Diese Datei wird automatisch generiert! # Eintragungen von Hand sind sinnlos! # # Siehe plonk:/usr/local/bin/userSubGenerate # # Fuer jede Nutzerin bei spline gibt es eine Subdomain # [.userpage].spline[.inf.fu-berlin].de, die vom # Apache auf ~ aufgeloest wird. EOF cat < $TMPFILEAPACHEGLOBAL # Diese Datei wird automatisch generiert! # Eintragungen von Hand sind sinnlos! # # Siehe plonk:/usr/local/bin/userSubGenerate # # # Für jeden User gibt es hier spezifische Einstellungen, # die wir im vhost und im /~user/ brauchen. DirectoryIndex index.html index.htm index.php EOF cat < $TMPFILEPHP ; Diese Datei wird automatisch generiert! ; Eintragungen von Hand sind sinnlos! ; ; Siehe plonk:/usr/local/bin/userSubGenerate ; ; ; Hier wird ein php-pool fuer jeden user generiert. EOF echo "Generiere $TMPFILEDNS, $TMPFILEAPACHEVHOSTS, $TMPFILEAPACHEGLOBAL und $TMPFILEPHP..." >&3 for SPLINEUID in $(echo $SPLINEUSERS) do echo $SPLINEUID FULLNAME=$(ldapsearch -LLL -x -b "dc=spline,dc=inf,dc=fu-berlin,dc=de" "(uid=$SPLINEUID)" cn | grep "^cn" | cut -d" " -f2-) cat <> $TMPFILEDNS ; $SPLINEUID.userpage.spline[.inf.fu-berlin].de fuer $FULLNAME $SPLINEUID.userpage IN CNAME userpage.spline.inf.fu-berlin.de. www.$SPLINEUID.userpage IN CNAME userpage.spline.inf.fu-berlin.de. $SPLINEUID IN CNAME userpage.spline.inf.fu-berlin.de. www.$SPLINEUID IN CNAME userpage.spline.inf.fu-berlin.de. EOF if [ -d /var/users/$SPLINEUID/public_html ]; then cat <> $TMPFILEAPACHEGLOBAL # php fuer $SPLINEUID ($FULLNAME) ProxySet disablereuse=off AddHandler proxy:fcgi://php-fpm-$SPLINEUID .php .php3 .php4 .php5 AllowOverride All Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require all granted Options +ExecCGI Require all granted EOF cat <> $TMPFILEAPACHEVHOSTS # http://$SPLINEUID.userpage.spline[.inf.fu-berlin].de fuer $FULLNAME ServerAlias $SPLINEUID.userpage.spline.inf.fu-berlin.de ServerAlias $SPLINEUID.userpage.spline.de ServerAlias $SPLINEUID.spline.de ServerAlias $SPLINEUID.spline.inf.fu-berlin.de ServerAlias www.$SPLINEUID.userpage.spline.inf.fu-berlin.de ServerAlias www.$SPLINEUID.userpage.spline.de ServerAlias www.$SPLINEUID.spline.de ServerAlias www.$SPLINEUID.spline.inf.fu-berlin.de ErrorLog /home/$SPLINEUID/public_html/logs/error.log CustomLog /home/$SPLINEUID/public_html/logs/access.log combined DocumentRoot /home/$SPLINEUID/public_html/webroot SuexecUserGroup $SPLINEUID users SetHandler proxy:fcgi://php-fpm-$SPLINEUID ServerAlias $SPLINEUID.userpage.spline.inf.fu-berlin.de ServerAlias $SPLINEUID.userpage.spline.de ErrorLog /home/$SPLINEUID/public_html/logs/error.log CustomLog /home/$SPLINEUID/public_html/logs/access.log combined DocumentRoot /home/$SPLINEUID/public_html/webroot SuexecUserGroup $SPLINEUID users SetHandler proxy:fcgi://php-fpm-$SPLINEUID EOF cat <> $TMPFILEPHP [$SPLINEUID] user = \$pool group = nogroup listen = /run/php/php$PHP_VER-fpm-\$pool.sock listen.owner = www-data listen.group = nogroup listen.mode = 0600 pm = ondemand pm.max_children = 25 pm.start_servers = 10 pm.min_spare_servers = 5 pm.max_spare_servers = 20 pm.max_requests = 50 pm.process_idle_timeout = 10s pm.status_path = /php-status catch_workers_output = yes security.limit_extensions = .php .php3 .php4 .php5 request_terminate_timeout = 300s EOF fi # -d /var/users/$SPLINEUID/public_html done echo "Kopiere $TMPFILEPHP nach userpage:/etc/php/$PHP_VER/fpm/pool.d/users.conf..." >&3 scp $TMPFILEPHP www-data@userpage.spline.inf.fu-berlin.de:/etc/php/$PHP_VER/fpm/pool.d/users.conf echo "Starte den php-fpm auf userpage neu." >&3 ssh www-data@userpage.spline.inf.fu-berlin.de sudo /etc/init.d/php$PHP_VER-fpm reload echo "Kopiere $TMPFILEAPACHEVHOSTS nach userpage:/etc/apache2/user-site.d/user-vhosts.conf ..." >&3 scp $TMPFILEAPACHEVHOSTS www-data@userpage.spline.inf.fu-berlin.de:/etc/apache2/user-site.d/user-vhosts.conf echo "Kopiere $TMPFILEAPACHEGLOBAL nach userpage:/etc/apache2/user-site.d/globals.conf ..." >&3 scp $TMPFILEAPACHEGLOBAL www-data@userpage.spline.inf.fu-berlin.de:/etc/apache2/user-site.d/globals.conf echo "Starte den Apache auf userpage neu." >&3 ssh www-data@userpage.spline.inf.fu-berlin.de sudo /etc/init.d/apache2 reload echo "Kopiere $TMPFILEDNS nach beep:/etc/bind/dns-sources/common.userpage" >&3 scp $TMPFILEDNS root@vm-dnsintern.spline.inf.fu-berlin.de:/etc/bind/generated/common.userpage echo "Erstelle die DNS-Eintraege neu" >&3 ssh root@vm-dnsintern.spline.inf.fu-berlin.de /usr/bin/make -C /root/dns/zones install || echo "Fehler beim Erstellen der neuen DNS-Eintraege." >&3 # cleanup rm $TMPFILEPHP rm $TMPFILEAPACHEVHOSTS rm $TMPFILEAPACHEGLOBAL rm $TMPFILEDNS