removed cluster code
This commit is contained in:
parent
56f2e89d15
commit
5280467700
|
@ -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
|
||||
# add user
|
||||
/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
|
||||
# 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
|
||||
fi
|
||||
fi
|
||||
|
||||
# cylce thru each node and add virtualhost
|
||||
vhost::set-clusterNodes all
|
||||
for n in "${clusterNodes[@]}"
|
||||
do
|
||||
if [ $n = `hostname -s` ]; then
|
||||
# add virtualhost
|
||||
/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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
# 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
|
||||
|
|
|
@ -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"
|
||||
if [[ -h /etc/apache2/sites-enabled/$virtualhost.conf ]]; then
|
||||
a2dissite --quiet $virtualhost && systemctl --quiet is-active apache2 && systemctl --quiet reload apache2
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user