-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·76 lines (56 loc) · 2.6 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/gearlock/bin/bash
## Ready to use mesa uninstallation script by @AXON
## For proper developer documentation, visit https://wiki.supreme-gamers.com/gearlock/developer-guide
# You don't need to modify this `uninstall.sh`.
#
# $UNINS_SCRIPT variable is provided by GXPM which returns
# full path for the locally prepared uninstallation script.
# Define vars
TTY_NUM="$(fgconsole)"
DALVIKDIR="/data/dalvik-cache"
GBSCRIPT="$GBDIR/init/UpdateMesa"
MESA_BACKUP_FILE="$STATDIR/mesa_stock.bak"
# Define functions
handleError ()
{
if [ $? != 0 ]; then
# TODO: Revert back any incomplete changes
geco "\n[!!!] Error: $1" && return ${2:-101}
fi
}
mesa_native()
{
"$CORE/gxpm/mesa-native/job" "$@"
}
# Deny uninstallation from GUI to avoid system crash
if [ "$TERMINAL_EMULATOR" == "yes" ]; then
geco "\n+ You can not uninstall Mesa from Android GUI, it will crash your system."
geco "+ It is not recommended that you uninstall from a live system, best practice is to uninstall from RECOVERY-MODE."
geco "+ You can still run GearLock in ${PURPLE}TTY${RC} and uninstall from there but it's not recommended.\n"
while true
do
read -rn1 -p "$(geco "Do you want to switch to ${BGREEN}TTY${RC} and uninstall from there ? [${GREEN}Y${RC}/n]") " i
case $i in
[Yy] ) geco "\n\n+ Switching to TTY GearLock GXPM ..." && sleep 2
gsudo openvt -s gxpm -u "$UNINS_SCRIPT"; return 101; break ;;
[Nn] ) geco "\n\n+ Okay, uninstallation process will exit"
return 101; break ;;
*) geco "\n- Enter either ${GREEN}Y${RC}es or no" ;;
esac
done
fi
# A workaround to retrun back to initial tty when booted android system crashes and switches to tty7
test "$BOOTCOMP" == "yes" && (while sleep 2; do test "$(fgconsole)" != "$TTY_NUM" && chvt "$TTY_NUM"; done) &
# Check if /system is writable
! touch -c "$SYSTEM_DIR/lib" >/dev/null 2>&1 && geco "[!!!] $SYSTEM_DIR is not writable, did you ${PINK}SuperCharge${RC} it yet ?" && exit 101
# Check for backup archive existence
test -e "$MESA_BACKUP_FILE"; handleError "Mesa backup archive not found"
# Cleanup mesa
geco "\n+ Cleaning up current Mesa dri & dependencies ..." && mesa_native clean
# Restore backup mesa
geco "\n+ Restoring stock Mesa from backup archive ..."
tar --zstd --strip-components=1 --warning=no-timestamp --directory="$SYSTEM_DIR" -xpf "$MESA_BACKUP_FILE"; handleError "Failed to restore stock Mesa from backup archive"
# Clear dalvik-cache
test -d "$DALVIKDIR" && geco "\n+ Clearing dalvik-cache, it may take a bit long on your next boot ..." && rm -rf "$DALVIKDIR"/*
# Remove any existing UpdateMesa job
rm -rf "$GBSCRIPT" "$STATDIR/UpdateMesa"