Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Adding ZFS Snapshot support #32

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rolling-rhino
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ function fancy_message() {
esac
}

# Take a zfs snapshot if zfs on root
function take_zfs_snapshots() {
ZFS_INSTALLED=$(dpkg-query --show --showformat='${db:Status-Status}\n' 'zfsutils-linux' 2>&1)
ZSYS_INSTALLED=$(dpkg-query --show --showformat='${db:Status-Status}\n' 'zsys' 2>&1)

if [[ $ZFS_INSTALLED == installed && $ZSYS_INSTALLED == installed ]]
then
echo ""
fancy_message info "ZFS on root detected. Taking a snapshot before making any changes:"
zsysctl state save
echo ""
fi
}

echo "Rolling Rhino 🦏"

# Check if the user running the script is root
Expand All @@ -55,6 +69,7 @@ while [ $# -gt 0 ]; do
esac
done


if which lsb_release 1>/dev/null; then
fancy_message info "lsb_release detected."
else
Expand Down Expand Up @@ -113,6 +128,9 @@ fancy_message info "All checks passed."
read -p "Are you sure you want to start tracking the devel series? [y/N]" -n 1 -r

if [[ ${REPLY} =~ ^[Yy]$ ]]; then

take_zfs_snapshots

HOST_ARCH="$(uname --machine)"
if [ "${HOST_ARCH}" == "x86_64" ]; then
ARCHIVE="http://archive.ubuntu.com/ubuntu"
Expand All @@ -121,6 +139,7 @@ if [[ ${REPLY} =~ ^[Yy]$ ]]; then
ARCHIVE="http://ports.ubuntu.com/ubuntu-ports"
SEC_ARCHIVE="http://ports.ubuntu.com/ubuntu-ports"
fi

cp /etc/apt/sources.list /etc/apt/sources.list.${OS_CODENAME}
cat << EOF > /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
Expand Down