2020-05-26 21:15:31 -07:00
|
|
|
#!/usr/local/bin/bash
|
|
|
|
|
2021-02-13 11:38:38 -08:00
|
|
|
# Copyright (c) 2018-2021, diyIT.org
|
2020-02-25 11:28:31 -08:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# BSD 2-Clause License ("Simplified BSD License" or "FreeBSD License")
|
|
|
|
# https://diyit.org/license/
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2020-04-11 00:46:09 -07:00
|
|
|
update_jail ()
|
|
|
|
{
|
|
|
|
echo "######## ## JAIL:::: $JAIL ##"
|
2020-02-25 11:28:31 -08:00
|
|
|
|
2020-04-11 00:46:09 -07: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
|
|
|
|
2020-04-11 00:46:09 -07:00
|
|
|
iocage exec $JAIL "freebsd-version"
|
2020-02-25 11:28:31 -08:00
|
|
|
|
2021-02-13 11:38:38 -08:00
|
|
|
if [[ $1 == "upgrade" ]]; then
|
|
|
|
iocage upgrade -r 12.2-RELEASE $JAIL
|
|
|
|
# pkgp.conf updated to new release after an upgrade
|
|
|
|
iocage exec $JAIL "[ -f /mnt/config/pkgp.conf ] && cp /mnt/config/pkgp.conf /usr/local/etc/pkg/repos/ || cp /mnt/common/pkgp.conf /usr/local/etc/pkg/repos/"
|
|
|
|
iocage exec $JAIL "pkg-static upgrade -f -y"
|
|
|
|
iocage exec $JAIL "pkg update -f"
|
|
|
|
else
|
|
|
|
iocage update $JAIL
|
|
|
|
iocage exec $JAIL "pkg update"
|
|
|
|
fi
|
2020-04-11 00:46:09 -07:00
|
|
|
|
2021-02-13 11:38:38 -08:00
|
|
|
iocage exec $JAIL "pkg autoremove -y"
|
|
|
|
iocage exec $JAIL "pkg upgrade -y"
|
|
|
|
# iocage exec $JAIL "pkg upgrade -f -y"
|
|
|
|
iocage exec $JAIL "pkg clean -ay"
|
2020-04-11 00:46:09 -07:00
|
|
|
|
2021-04-17 11:05:38 -07:00
|
|
|
# iocage exec $JAIL "rm -rf /var/tmp/temproot*"
|
|
|
|
# iocage exec $JAIL "mergemaster -a"
|
|
|
|
iocage exec $JAIL "etcupdate -t /mnt/common/current-src.bzip2"
|
2020-02-25 11:28:31 -08:00
|
|
|
|
2020-04-11 00:46:09 -07:00
|
|
|
iocage exec $JAIL "freebsd-version"
|
2020-02-25 11:28:31 -08:00
|
|
|
|
2020-04-11 00:46:09 -07:00
|
|
|
echo "######## ####"
|
2021-02-13 11:38:38 -08:00
|
|
|
#read -p "continue, ctrl-c to abort? " RESP
|
2020-04-11 00:46:09 -07:00
|
|
|
}
|
2020-02-25 11:28:31 -08:00
|
|
|
|
2021-02-13 11:38:38 -08:00
|
|
|
iocage fetch -U -r 12.2-RELEASE
|
2020-04-11 00:46:09 -07:00
|
|
|
|
2021-04-17 11:05:38 -07:00
|
|
|
read -p "update pkgp packages first (y/N)? " RESP
|
2020-04-11 00:46:09 -07:00
|
|
|
if [ ! -z $RESP ] && [ $RESP == "y" ]; then
|
2021-04-01 01:23:14 -07:00
|
|
|
/root/FreeBSD/jails/jails-update-pkgs.sh pkgp-only
|
2020-04-11 00:46:09 -07:00
|
|
|
fi
|
2020-02-25 11:28:31 -08:00
|
|
|
|
2020-04-11 00:46:09 -07:00
|
|
|
read -p "update all jails (y/N)? " RESP
|
|
|
|
if [ ! -z $RESP ] && [ $RESP == "y" ]; then
|
2021-02-13 11:38:38 -08:00
|
|
|
# for JAIL in `iocage list -h | cut -f2`;
|
|
|
|
for JAIL in `jls -N | cut -d " " -f 2 | cut -d "-" -f 2- | grep -v JID | sort`;
|
2020-04-11 00:46:09 -07:00
|
|
|
do
|
2021-04-17 11:05:38 -07:00
|
|
|
if [ $JAIL == "test" ] || [ $JAIL == "debian" ]; then
|
2021-02-13 11:38:38 -08:00
|
|
|
continue
|
2020-04-11 00:46:09 -07:00
|
|
|
fi
|
2021-02-13 11:38:38 -08:00
|
|
|
if [[ $1 == "upgrade" ]]; then
|
2021-04-17 11:05:38 -07:00
|
|
|
read -p "upgrade jail $JAIL (Y/n)? " RESP
|
2021-02-13 11:38:38 -08:00
|
|
|
if [ ! -z $RESP ] && [ $RESP == "n" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
update_jail $1
|
2020-04-11 00:46:09 -07:00
|
|
|
done
|
2020-02-25 11:28:31 -08:00
|
|
|
fi
|
|
|
|
|
2020-04-11 00:46:09 -07:00
|
|
|
echo "update base system by running:"
|
|
|
|
echo "freebsd-update fetch"
|
2021-04-17 11:05:38 -07:00
|
|
|
# echo "freebsd-update upgrade -r 13.0-RELEASE"
|
2020-04-11 00:46:09 -07:00
|
|
|
echo "freebsd-update install"
|
2021-04-17 11:05:38 -07:00
|
|
|
# echo "pkg bootstrap -f ; pkg update ; pkg upgrade"
|
2021-02-13 11:38:38 -08:00
|
|
|
echo "cd /usr/src; svn update; make -j8 buildkernel KERNCONF=diyIT && make -j8 installkernel KERNCONF=diyIT"
|
2021-04-17 11:05:38 -07:00
|
|
|
echo "etcupdate build /root/FreeBSD/jails/configs/common/current-src.bzip2"
|
2020-05-26 21:15:31 -07:00
|
|
|
echo "reboot"
|
2020-04-11 00:46:09 -07:00
|
|
|
echo "pkg-static upgrade -f"
|
2021-04-17 11:05:38 -07:00
|
|
|
#echo "rm -rf /var/tmp/temproot*"
|
|
|
|
#echo "mergemaster -a"
|
|
|
|
echo "etcupdate -t /mnt/common/current-src.bzip2"
|
2021-02-13 11:38:38 -08:00
|
|
|
|
|
|
|
echo "/root/FreeBSD/scripts/zfs-prune-snapshots -vn -p 'ioc_update' 1d | grep removing"
|