#!/bin/bash # # vhost-stack # https://git.stack-source.com/msb/vhost-stack # MIT License Copyright (c) 2021 Matthew Saunders Brown # load include file source $(dirname $0)/vhost.sh # check for and set username if [ -n "$1" ]; then username=$1 else echo "username not set" exit 1 fi # First run a couple of basic checks. Redundant # as user-del.sh run later does these same checks # but prevents connecting to all nodes unnecessarily if ! /bin/grep -q "^$username:" /etc/passwd; then echo user \"$username\" does not exist exit 1 fi vhost::set-virtualhostArray for v in "${virtualhostArray[@]}" do if [ $(stat -c '%U' /srv/www/$v) = $username ]; then echo "$username has one or more installed virtualhosts ($v)" exit 1 fi done # delete user from each node vhost::set-clusterNodes all for n in "${clusterNodes[@]}" do if [ $n = `hostname -s` ]; then /usr/local/bin/user-del.sh $username else ssh $n.lan "/usr/local/bin/user-del.sh $username" fi done