-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remove_JiuWei
executable file
·110 lines (103 loc) · 3.63 KB
/
Remove_JiuWei
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# @name: Remove_JiuWei
# @repo: https://gitee.com/TangYuanMaster/JiuWei
# @author: TangYuanMaster
# @license: See the file 'LICENSE.txt'
#
COLOR_DEFAULT="\e[0m"
COLOR_RED="\e[31m"
COLOR_GREEN="\e[32m"
COLOR_YELLOW="\e[33m"
COLOR_CYAN="\e[36m"
interrupt_handler() {
echo -e "${COLOR_YELLOW}[*] Received Ctrl+C, Do you want to continue running the script? (Y/n)${COLOR_DEFAULT}"
read -r answer
case $answer in
[Nn]) exit 1;;
*) continue;;
esac
}
trap interrupt_handler SIGINT
check_root() {
if [[ $EUID -ne 0 ]]; then
echo -e "${COLOR_RED}[-] This command must be run as root!${COLOR_DEFAULT}"
exit 1
fi
}
if [ ! -n "$TERMUX_VERSION" ]; then
check_root
fi
if [ ! -n "$HOME" ]; then
echo -e "${COLOR_RED}[-]\$HOME variables do not exist, please set the variable \$HOME and try again.${COLOR_DEFAULT}"
exit 1
fi
MAIN_DIR="$HOME/JiuWei"
INED_FILE=".installed" #记录所有已安装的包名(文本文件)
PACKAGES_FILE=".packages" #记录所有的包信息,方便search(文本文件)
CONFIG_FILE="config.list" #放置源URL(文本文件)
FOXINDEX_FILE=".foxindex" #放置FOXINDEX解压后产生的文件(文件夹)
CACHE_FILE=".cache" #放置从源中下载的安装包(文件夹)
BIN_FILE=".bin" #快捷命令存放(文件夹)
INED="$MAIN_DIR/$INED_FILE"
PACKAGES="$MAIN_DIR/$PACKAGES_FILE"
CONFIG="$MAIN_DIR/$CONFIG_FILE"
CACHE="$MAIN_DIR/$CACHE_FILE"
FOXINDEX="$MAIN_DIR/$FOXINDEX_FILE"
BIN="$MAIN_DIR/$BIN_FILE"
main() {
if [ ! -d "$MAIN_DIR" ]; then
remove_all_packages
rm -rf "$MAIN_DIR"
else
echo -e "${COLOR_YELLOW}[WARN] You haven't installed JiuWei, do you need to install?[Y/n]${COLOR_DEFAULT}"
read -r answer
if [[ $answer =~ ^[Nn]$ ]]; then
exit 1
else
wget -O "Setup_JiuWei" https://gitee.com/TangYuanMaster/JiuWei/raw/master/Setup_JiuWei
chmod +x Setup_JiuWei
./Setup_JiuWei
fi
fi
}
remove_all_packages() {
echo -e ""
cat "$INED" | while IFS=':' read -r package _
do
if [ ! -e "$CACHE/$package.fox" ]; then
if ! wget -O "$CACHE/$package.fox" "$source_url/main/$package.fox"; then
if [ -f "$ST" ]; then
if ! wget -O "$CACHE/$package.fox" "$source_url/expand/$package.fox"; then
echo -e "${COLOR_RED}[-] FOX file is lost! It seems that the latest source is no longer supported ...${COLOR_DEFAULT}"
exit 1
fi
else
echo -e "${COLOR_RED}[-] FOX file is lost! It seems that the $package need expand ...${COLOR_DEFAULT}"
exit 1
fi
fi
fi
if grep -q "^$sys_arch:$" "$CACHE/$package.fox"; then
local run=$(grep -A 3 "^$sys_arch:$" "$CACHE/$package.fox" | tail -n 1)
else
grep -q "^$sys_name:$" "$CACHE/$package.fox"
local run=$(grep -A 3 "^$sys_name:$" "$CACHE/$package.fox" | tail -n 1)
fi
update_run
check_code
local run=${run//\"\$BIN\"/$BIN}
local run=${run//\"\$MAIN_DIR\"/$MAIN_DIR}
eval "$run"
sed -i "/^${pattern}$/d" "$INED"
rm "$CACHE/$package.fox"
echo -e "${COLOR_GREEN}[+] Package '$package' has been removed.${COLOR_DEFAULT}"
done
}
echo -e "${COLOR_YELLOW}[*] Are you sure you want to delete JiuWei? It will also delete the tools which you have been installed.[y/N]${COLOR_DEFAULT}"
read -r answer
if [[ $answer =~ ^[Yy]$ ]]; then
main
else
echo -e "${COLOR_YELLOW}[*] Sure enough, you still love me~ Love you too!\(♡\(˃͈ દ ˂͈ ༶ \)${COLOR_DEFAULT}"
fi