vhost-stack/bin/vhost-user-jails-update.sh

61 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2021-04-04 13:28:22 -07:00
#!/bin/bash
#
# vhost-stack
# https://git.stack-source.com/msb/vhost-stack
2022-08-22 13:22:16 -07:00
# Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
2021-04-04 13:28:22 -07:00
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 "Updates all existing jails."
echo ""
echo "usage: $thisfilename"
echo ""
echo " -h Print this help."
echo ""
echo " Cycles through all existing jails and runs jk_update"
echo " for each one. This updates all software installed in"
echo " the jails to match the latest versions installed on"
echo " the host server. e.g. if php-cli gets update on the"
echo " host this syncs that update to all the jails."
exit
}
2021-10-05 11:33:24 -07:00
vhost:getoptions "$@"
2021-09-16 16:21:35 -07:00
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]}
echo "updating $jail"
2023-08-31 11:26:59 -07:00
/usr/sbin/jk_update -k -j /usr/jails/$jail
/usr/sbin/jk_update -k -j /usr/jails/$jail /lib64/
/usr/sbin/jk_update -k -s /etc/passwd -s /etc/group -s /etc/ld.so.cache -j /usr/jails/$jail /etc/
2021-04-04 13:28:22 -07:00
/sbin/ldconfig.real -r /usr/jails/$jail
done