diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index 8f0c3ba..fc0ad95 100644 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -59,40 +59,13 @@ if ! grep -q "^$username:" /etc/passwd; then fi # set userid userid=`awk -F: '{uid[$3]=1}END{for(x=1000; x<=65534; x++) {if(uid[x] != ""){}else{print x; exit;}}}' /etc/passwd` - # cylce thru each node and add user - vhost::set-clusterNodes all - for n in "${clusterNodes[@]}" - do - if [ $n = `hostname -s` ]; then - /usr/local/bin/user-add.sh $username "$password" $userid - else - ssh $n.lan "/usr/local/bin/user-add.sh $username \"$password\" $userid" - fi - done - # if jail option is set cylce thru each node and jail user + # add user + /usr/local/bin/user-add.sh $username "$password" $userid + # if jail option is set then jail user if [[ $jail = true ]]; then - vhost::set-clusterNodes nds - for n in "${clusterNodes[@]}" - do - if [ $n = `hostname -s` ]; then - /usr/local/bin/user-jail.sh $username > /dev/null 2>&1 & - else - ssh $n.lan "/usr/local/bin/user-jail.sh $username > /dev/null 2>&1 &" & - fi - done - # Wait for jails to be created. As of now they take about 30 seconds. - vhost::countdown 60 + /usr/local/bin/user-jail.sh $username > /dev/null 2>&1 & fi fi -# cylce thru each node and add virtualhost -vhost::set-clusterNodes all -for n in "${clusterNodes[@]}" -do - if [ $n = `hostname -s` ]; then - /usr/local/bin/vhost-add.sh $virtualhost $username > /dev/null 2>&1 & - else - ssh $n.lan "/usr/local/bin/vhost-add.sh $virtualhost $username > /dev/null 2>&1 &" - fi -done - +# add virtualhost +/usr/local/bin/vhost-add.sh $virtualhost $username > /dev/null 2>&1 & diff --git a/bin/vhost-destroy.sh b/bin/vhost-destroy.sh index a34b873..3ea5798 100644 --- a/bin/vhost-destroy.sh +++ b/bin/vhost-destroy.sh @@ -28,17 +28,9 @@ if [ -n "$2" ] && [ $2 = "userdel" ]; then username=$(stat -c '%U' /srv/www/$virtualhost) fi -vhost::set-clusterNodes all -for n in "${clusterNodes[@]}" -do - if [ $n = `hostname -s` ]; then - /usr/local/bin/vhost-del.sh $virtualhost - else - ssh $n.lan "/usr/local/bin/vhost-del.sh $virtualhost" - fi -done +/usr/local/bin/vhost-del.sh $virtualhost # check for userdel option if [ -n "$2" ] && [ $2 = "userdel" ] && [ -n $username ]; then - /usr/local/bin/user-destroy.sh $username + /usr/local/bin/vhost-user-del.sh $username fi diff --git a/bin/vhost-disable.sh b/bin/vhost-disable.sh index 47a3bf3..0bf144c 100644 --- a/bin/vhost-disable.sh +++ b/bin/vhost-disable.sh @@ -15,12 +15,6 @@ else exit 1 fi -vhost::set-clusterNodes all -for n in "${clusterNodes[@]}" -do - if [ $n = `hostname -s` ]; then - [[ -h /etc/apache2/sites-enabled/$virtualhost.conf ]] && a2dissite --quiet $virtualhost && systemctl --quiet is-active apache2 && systemctl --quiet reload apache2 - else - ssh $n.lan "[[ -h /etc/apache2/sites-enabled/$virtualhost.conf ]] && a2dissite --quiet $virtualhost && systemctl --quiet is-active apache2 && systemctl --quiet reload apache2" - fi -done +if [[ -h /etc/apache2/sites-enabled/$virtualhost.conf ]]; then + a2dissite --quiet $virtualhost && systemctl --quiet is-active apache2 && systemctl --quiet reload apache2 +fi diff --git a/bin/vhost-user-destroy.sh b/bin/vhost-user-destroy.sh deleted file mode 100644 index 223c47f..0000000 --- a/bin/vhost-user-destroy.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 diff --git a/bin/vhost-user-jails-sync.sh b/bin/vhost-user-jails-sync.sh deleted file mode 100644 index 0ba0f10..0000000 --- a/bin/vhost-user-jails-sync.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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 - -mode=q - -if [ -n "$1" ]; then - if [ "$1" = 'verbose' ] || [ "$1" = 'v' ]; then - mode=i - elif [ "$1" = 'dry-run' ] || [ "$1" = 'n' ]; then - mode=vn - fi -fi - -# check that node is "active" -vhost::set-nodeRole -if [ "$nodeRole" != "active" ]; then - echo "NOTICE: node role not 'active'. bailing out" - exit 1 -fi - -# make sure jails dir exists -if [[ ! -e /usr/jails/ ]]; then - echo "/usr/jails does not exist" - exit 1 -fi - -# check if any jails exist -if [ ! "$(ls -A /usr/jails/)" ]; then - echo "no jails exist" - exit 1 -fi - -# get list of jails -cd /usr/jails/ -jails=(*) - -vhost::set-clusterNodes other - -for jail in "${jails[@]}" -do - for node in "${clusterNodes[@]}" - do - rsync -$mode --archive --no-times --hard-links --exclude=/usr/jails/$jail/home --exclude=/usr/jails/$jail/srv/www --relative --delete --rsh=/usr/bin/ssh /usr/jails/$jail root@$node.lan:/ - done -done