2021-04-04 13:28:22 -07:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# vhost-stack
|
|
|
|
# https://git.stack-source.com/msb/vhost-stack
|
|
|
|
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
|
|
|
|
2021-04-04 14:15:16 -07:00
|
|
|
# load include file
|
|
|
|
source $(dirname $0)/vhost.sh
|
2021-04-04 13:28:22 -07:00
|
|
|
|
2021-09-16 16:21:35 -07:00
|
|
|
help()
|
|
|
|
{
|
|
|
|
thisfilename=$(basename -- "$0")
|
|
|
|
echo "Rebuilds all existing jails by running vhost-user-jail-reset.sh for each jailed user."
|
|
|
|
echo ""
|
|
|
|
echo "usage: $thisfilename"
|
|
|
|
echo ""
|
|
|
|
echo " -h Print this help."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
if [ $1 == "-h" ]; then
|
|
|
|
help
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-04-04 13:28:22 -07:00
|
|
|
# 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
|
|
|
|
|
|
|
|
# check for /usr/sbin/jk_update
|
|
|
|
if [[ ! -x "/usr/sbin/jk_update" ]]; then
|
|
|
|
echo "/usr/sbin/jk_update does not exist or is not executable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# get list of jails
|
|
|
|
cd /usr/jails/
|
|
|
|
jails=(*)
|
|
|
|
|
|
|
|
for jail in "${!jails[@]}"
|
|
|
|
do
|
|
|
|
jail=${jails[$jail]}
|
2021-10-05 14:03:01 -07:00
|
|
|
echo /usr/local/bin/vhost-user-jail-reset.sh -u $jail
|
2021-04-04 13:28:22 -07:00
|
|
|
done
|