blob: 71af53f2b2f1a06fa6b1ad3a126a715ac72394be (
plain) (
blame)
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
40
41
42
43
44
45
|
#!/bin/sh
err() {
echo "$@" >&2
exit 1
}
if [ "$(id -u)" -ne 0 ]; then
err 'Please run as root'
fi
if [ -z "$1" ]
then
err 'Specify path as the first argument'
fi
ensure() {
{ set +x; } 2>/dev/null
[ $# -lt 1 ] && return 0
$@ || err failed executing: "$@"
set -x
}
set -xu
umask 022
ensure export chroot_dir="$(ensure realpath -- "$1")"
if [ "$chroot_dir" = "/" ]
then
err "I don't feel like deleting your root filesystem."
fi
umount "${chroot_dir}/dev"
umount "${chroot_dir}/proc"
umount "${chroot_dir}/sys"
read -p "Really delete ${chroot_dir}? Type 'yes, please!' to confirm: " res
if [ "$res" = "yes, please!" ]
then
rm -rvf "${chroot_dir}"
else
err "Not deleting"
fi
|