forked from SherlockChiang/Nethunter_for_KernelSU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
60 lines (48 loc) · 1.43 KB
/
uninstall.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Define Several Variables
[ -z $TMPDIR ] && TMPDIR=/dev/tmp;
NHSYS=/data/local/nhsystem
ROOTFS="$NHSYS/kalifs"
PRECHROOT=`find /data/local/nhsystem -type d -iname kali-* | head -n 1`
# Function to unmount file systems
f_umount_fs() {
if mountpoint -q $PRECHROOT/$1; then
umount -f $PRECHROOT/$1
fi
[ -d $PRECHROOT/$1 ] && rm -rf $PRECHROOT/$1
}
# Function to clean up directories and unmount file systems
do_umount() {
for i in "dev/pts" "dev/shm" dev proc sys system; do
f_umount_fs "$i"
done
umount -l $PRECHROOT/sdcard
rm -rf $PRECHROOT/sdcard
# Final unmount and clean up
if [ -d "$PRECHROOT" ]; then
umount -f $PRECHROOT
rm -rf $PRECHROOT
fi
}
# Function to remove installed apps
pm uninstall com.offsec.nethunter &>/dev/null
pm uninstall com.offsec.nethunter.kex &>/dev/null
pm uninstall com.offsec.nhterm &>/dev/null
pm uninstall com.offsec.nethunter.store &>/dev/null
# Function to restore permissions and SELinux enforcing state
restore_settings() {
[[ "$(getenforce)" == "Enforcing" ]] && ENFORCE=true || ENFORCE=false
settings put global verifier_verify_adb_installs 1
${ENFORCE} && setenforce 1
}
# Unmount and clean up the chroot environment
if [ -d "$PRECHROOT" ]; then
do_umount
fi
# Remove NetHunter system and app files
rm -rf $NHSYS
remove_apps
# Restore system settings
restore_settings
# Remove module files
rm -rf "$MODPATH"