-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete-chroot
executable file
·39 lines (35 loc) · 1.2 KB
/
delete-chroot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# File: delete-chroot
# Author: Nicholas Girga
# Purpose: Delete a filesystem created by `create-chroot`.
# do not allow user to delete mounted directories
mountpoint -q ./arch-fs && { echo ERROR\!: Chroot is mounted.; echo If you are positive it is no longer in use, unmount using the \`umount\` command.; echo Type \`man umount\` and press ENTER for more information.; exit; }
# delete lock file
echo Deleting lock file...
[ -f ./arch-fs.lock ] && sudo rm -f ./arch-fs.lock || echo WARNING!: Lock file does not exist!
echo Finished deleting lock file!
echo
# check if filesystem directory exists
if ! [ -d ./arch-fs ];
then
echo ERROR!: The root filesystem for the Arch Linux chroot does not exist.
echo Use \`./create-chroot\` to create a new root filesystem for the Arch Linux chroot.
exit
fi
# delete filesystem
echo Deleting root filesystem for Arch Linux chroot...
echo
for child in ./arch-fs/*;
do
echo " Deleting \"$child\"..."
sudo rm -rf $child
echo " Finished deleting \"$child\"!"
echo
done
echo " Deleting \"./arch-fs\"..."
sudo rm -rf ./arch-fs
echo " Finished deleting \"./arch-fs\"!"
echo
echo Finished deleting root filesystem for Arch Linux chroot!
echo
echo Done!