-
Notifications
You must be signed in to change notification settings - Fork 76
/
termux-reset.in
50 lines (40 loc) · 1.51 KB
/
termux-reset.in
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
#!/bin/bash
unset LD_PRELOAD LD_LIBRARY_PATH
echo
echo "You are going to reset your Termux installation."
echo
echo "This script will erase everything under \$PREFIX. All files in that directory will be lost, that includes packages, configuration files, databases, etc."
echo
echo "Termux home directory as well as data in your shared or external storage will not be removed and left as-is."
echo
read -re -p "Do you want to continue ? (y/n) " CHOICE
if ! [[ $CHOICE =~ (Y|y) ]]; then
echo "Leaving \$PREFIX intact."
exit 1
else
HAS_TERMUX_AM=false
if [ -f "@TERMUX_PREFIX@/libexec/termux-am/am.apk" ]; then
HAS_TERMUX_AM=true
echo "Preserving package 'termux-am' for later use..."
if [ -d "@TERMUX_CACHE_DIR@" ]; then
/system/bin/rm -rf "@TERMUX_CACHE_DIR@/termux-am"
/system/bin/mkdir -p "@TERMUX_CACHE_DIR@/termux-am"
/system/bin/cp "@TERMUX_PREFIX@/libexec/termux-am/am.apk" "@TERMUX_CACHE_DIR@/termux-am/am.apk"
# In case copying am.apk failed.
if [ ! -e "@TERMUX_CACHE_DIR@/termux-am/am.apk" ]; then
HAS_TERMUX_AM=false
fi
fi
fi
echo "Erasing '@TERMUX_PREFIX@'..."
/system/bin/chmod -R 700 "@TERMUX_PREFIX@" >/dev/null 2>&1
/system/bin/rm -rf "@TERMUX_PREFIX@"
echo "Done. You need to close Termux application now."
if ! $HAS_TERMUX_AM; then
echo "Terminating all sessions..."
/system/bin/killall -9 "$SHELL"
else
export CLASSPATH="@TERMUX_CACHE_DIR@/termux-am/am.apk"
/system/bin/app_process / @TERMUX_CLASS_NAME@.termuxam.Am stopservice @TERMUX_APP_PACKAGE@/.app.TermuxService
fi
fi