Skip to content

Commit

Permalink
Exit on errors (#24)
Browse files Browse the repository at this point in the history
* Early exits for Apt, zpool create, and ZVOL create

If these fail, terminate script

* Fixed if statement syntaxes

* Cleaned verbage and added rsync check
  • Loading branch information
ghfields authored Jun 26, 2018
1 parent e7eeff2 commit 1605be9
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions rpooler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi

apt install -y zfsutils &> /dev/null
if !(apt install -y zfsutils &> /dev/null); then
echo "Error installing zfsutils from the internet. Please check your connection."
exit 1
fi

while [[ $exitpoolselect == "" ]]; do
echo -e $green "What do you want to name your pool? " $nocolor
Expand Down Expand Up @@ -71,8 +74,15 @@ while [[ $exitfilesystemselect == "" ]]; do
done
done

zpool create -f $options $pool $layout
zfs create -V 10G $pool/ubuntu-temp
if !(zpool create -f $options $pool $layout); then
echo "Error creating zpool. Terminating Script."
exit 1
fi

if !(zfs create -V 10G $pool/ubuntu-temp); then
echo "Error creating ZVOL. Terminating Script."
exit 1
fi

echo ""
echo "Configuring the Ubiquity Installer"
Expand All @@ -87,11 +97,18 @@ echo -e ' \t' "This install script will continue."
echo ""
read -p "Press any key to launch Ubiquity. These instructions will remain visible in the terminal window."

ubiquity --no-bootloader
if !(ubiquity --no-bootloader); then
echo "Ubiquity Installer failed to complete. Terminating Script."
exit 1
fi

zfs create $pool/ROOT
zfs create $pool/ROOT/ubuntu-1
rsync -avPX /target/. /$pool/ROOT/ubuntu-1/.

if !(rsync -avPX /target/. /$pool/ROOT/ubuntu-1/.); then
echo "Rsync failed to complete. Terminating Script."
exit 1
fi

for d in proc sys dev; do mount --bind /$d /$pool/ROOT/ubuntu-1/$d; done

Expand Down

0 comments on commit 1605be9

Please sign in to comment.