mirror of
https://github.com/kneutron/ansitest.git
synced 2025-01-16 04:42:55 +08:00
implemented upgrade (uninstall, umount, export)
also included more progress
This commit is contained in:
parent
029210c709
commit
cf3db45b0b
@ -14,13 +14,46 @@ if [ "$1" = "fixit" ]; then
|
||||
exit;
|
||||
fi
|
||||
|
||||
# failexit.mrg
|
||||
function failexit () {
|
||||
echo '! Something failed! Code: '"$1 $2" # code # (and optional description)
|
||||
exit $1
|
||||
}
|
||||
|
||||
if [ "$1" = "upgrade" ]; then
|
||||
systemctl stop zed
|
||||
systemctl stop smb
|
||||
# TODO also do nfs if you use that with zfs
|
||||
|
||||
echo "! Unmounting all ZFS datasets and exporting pools..."
|
||||
zfs umount -a -f
|
||||
zpool export -a -f
|
||||
[ $(df -hT |grep -c zfs) -gt 0 ] && failexit 111 "ZFS pool/dataset found still mounted, lsof may come in handy"
|
||||
# handy REF if you need fuser: https://vander.host/knowledgebase/operating-systems/how-to-deal-with-fuser-command-not-found-on-centos/
|
||||
# yum install -y psmisc
|
||||
|
||||
echo "o Unloading ZFS modules..."
|
||||
modprobe -rv zfs zunicode zzstd zlua zcommon znvpair zavl icp spl
|
||||
if [ $(lsmod |grep -c zfs) -gt 0 ]; then
|
||||
echo "NOTE if you get error here, ' lsof |grep zfs ' and kill the process holding it, then retry"
|
||||
failexit 302 "ZFS module(s) are still loaded!"
|
||||
fi
|
||||
|
||||
yum remove -y zfs zfs-dkms* libnvpair* libuutil* libzfs* libzpool* python3-pyzfs zfs-debug* zfs-dracut zfs-test* \
|
||||
--setopt=clean_requirements_on_remove=false \
|
||||
|| failexit 999 "Failed to uninstall ZFS RPMs"
|
||||
# REF: https://access.redhat.com/solutions/5577491
|
||||
# otherwise it removes ~128 packages and is a big PITA :b
|
||||
fi
|
||||
|
||||
echo "o Installing prereq pkgs..."
|
||||
yum install -y epel-release
|
||||
#yum install -y https://zfsonlinux.org/epel/zfs-release.el8_3.noarch.rpm
|
||||
#gpg --import --import-options show-only /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
|
||||
|
||||
# REF: https://openzfs.github.io/openzfs-docs/Developer%20Resources/Custom%20Packages.html
|
||||
|
||||
yum install -y kernel-devel kernel-headers wget curl
|
||||
yum install -y kernel-devel kernel-headers wget curl lsof
|
||||
yum groupinstall -y "Development Tools"
|
||||
|
||||
dnf install -y gcc make autoconf automake libtool rpm-build kernel-rpm-macros dkms libtirpc-devel \
|
||||
@ -28,6 +61,7 @@ dnf install -y gcc make autoconf automake libtool rpm-build kernel-rpm-macros dk
|
||||
elfutils-libelf-devel kernel-devel-$(uname -r) python3 python3-devel python3-setuptools python3-cffi libffi-devel
|
||||
|
||||
cd /usr/local/src
|
||||
echo "o Downloading ZFS source code"
|
||||
wget --no-clobber https://github.com/openzfs/zfs/releases/download/zfs-$zver/zfs-$zver.tar.gz
|
||||
tar xzf zfs-$zver.tar.gz
|
||||
|
||||
@ -39,7 +73,8 @@ time make -s -j4 rpm-utils rpm-dkms && \
|
||||
mv -v *.src.rpm ..
|
||||
|
||||
echo "$(date) + Installing ZFS RPMs"
|
||||
time yum localinstall -y *.$(uname -p).rpm *.noarch.rpm
|
||||
time yum localinstall -y *.$(uname -p).rpm *.noarch.rpm \
|
||||
|| failexit 666 "Failed to install ZFS packages"
|
||||
|
||||
modprobe zfs
|
||||
dmesg |grep ZFS
|
||||
|
Loading…
x
Reference in New Issue
Block a user