#!/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/var/www --relative --delete --rsh=/usr/bin/ssh /usr/jails/$jail root@$node.lan:/ done done