FreeBSD/jails/update.sh

68 lines
1.6 KiB
Bash
Raw Normal View History

2020-02-25 11:28:31 -08:00
# Copyright (c) 2018-2020, diyIT.org
# All rights reserved.
#
# BSD 2-Clause License ("Simplified BSD License" or "FreeBSD License")
# https://diyit.org/license/
#
#
#!/usr/local/bin/bash
update_jail ()
{
echo "######## ## JAIL:::: $JAIL ##"
2020-02-25 11:28:31 -08:00
## uncomment below to list and remove snapshots
#zfs list -t snapshot -o name | grep ship/iocage/jails/$JAIL | sort
#read -p "remove all $JAIL snapshots (y/N)? " RESP
#if [ ! -z $RESP ] && [ $RESP == "y" ]; then
# zfs list -t snapshot -o name | grep ship/iocage/jails/$JAIL | sort | xargs -n 1 zfs destroy
#fi
2020-02-25 11:28:31 -08:00
iocage exec $JAIL "freebsd-version"
2020-02-25 11:28:31 -08:00
## uncomment below for an upgrade instead of an update
#iocage upgrade -r 12.1-RELEASE $JAIL
iocage update $JAIL
iocage exec $JAIL "pkg upgrade -f -y"
iocage exec $JAIL "mergemaster"
2020-02-25 11:28:31 -08:00
iocage exec $JAIL "freebsd-version"
2020-02-25 11:28:31 -08:00
iocage exec $JAIL "pkg update -f"
iocage exec $JAIL "pkg autoremove -y"
iocage exec $JAIL "pkg upgrade -y"
iocage exec $JAIL "pkg clean -ay"
2020-02-25 11:28:31 -08:00
echo "######## ####"
}
2020-02-25 11:28:31 -08:00
iocage fetch -U -r 12.1-RELEASE
read -p "update pkgp jail (y/N)? " RESP
if [ ! -z $RESP ] && [ $RESP == "y" ]; then
JAIL="pkgp"
update_jail
fi
2020-02-25 11:28:31 -08:00
./jails-update-pkgs.sh
2020-02-25 11:28:31 -08:00
read -p "update all jails (y/N)? " RESP
if [ ! -z $RESP ] && [ $RESP == "y" ]; then
for JAIL in `iocage list -h | cut -f2`;
do
if [ $JAIL == "pkgp" ] || [ $JAIL == "debian"]; then
continue;
fi
update_jail
done
2020-02-25 11:28:31 -08:00
fi
echo "update base system by running:"
echo "freebsd-update fetch"
echo "freebsd-update install"
echo "pkg-static upgrade -f"
echo "mergemaster"