-
Notifications
You must be signed in to change notification settings - Fork 9
/
tinyPortMapper.sh
104 lines (85 loc) · 2.33 KB
/
tinyPortMapper.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
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
#!/bin/bash
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
none='\e[0m'
[[ $(id -u) != 0 ]] && echo -e " \n请使用 ${red}root ${none}用户运行 ${yellow} ${none}\n" && exit 1
cmd="apt-get"
sys_bit=$(uname -m)
# 笨笨的检测方法
if [[ -f /usr/bin/apt-get ]] || [[ -f /usr/bin/yum ]]; then
if [[ -f /usr/bin/yum ]]; then
cmd="yum"
fi
else
echo -e " \n ${red}此脚本${none} 不支持您的系统。 ${yellow}(-_-) ${none}\n" && exit 1
fi
if [[ $sys_bit == "i386" || $sys_bit == "i686" ]]; then
tinymapper="tinymapper_x86"
elif [[ $sys_bit == "x86_64" ]]; then
tinymapper="tinymapper_amd64"
else
echo -e " \n$red毛支持你的系统....$none\n" && exit 1
fi
install() {
$cmd install wget -y
#ver=$(curl -s https://api.github.com/repos/wangyu-/tinyPortMapper/releases/latest | grep 'tag_name' | cut -d\" -f4)
tinyPortMapper_download_link="https://github.com/wangyu-/tinyPortMapper/releases/download/20180224.0/tinymapper_binaries.tar.gz"
mkdir -p /tmp/tinyPortMapper
if ! wget --no-check-certificate --no-cache -O "/tmp/tinyPortMapper.tar.gz" $tinyPortMapper_download_link; then
echo -e "$red 下载 tinyPortMapper 失败!$none" && exit 1
fi
tar zxf /tmp/tinyPortMapper.tar.gz -C /tmp/tinyPortMapper
cp -f /tmp/tinyPortMapper/$tinymapper /usr/bin/tinymapper
chmod +x /usr/bin/tinymapper
if [[ -f /usr/bin/tinymapper ]]; then
clear
echo -e "
$green tinyPortMapper 安装完成!$none
输入$yellow tinymapper $none即可使用.
备注:这个脚本仅负责安装和卸载.
"
else
echo -e " \n$red安装失败!!!$none\n"
fi
rm -rf /tmp/tinyPortMapper
rm -rf /tmp/tinyPortMapper.tar.gz
}
uninstall() {
if [[ -f /usr/bin/tinymapper ]]; then
tinyPortMapper_pid=$(pgrep "tinymapper")
[ $tinyPortMapper_pid ] && kill -9 $tinyPortMapper_pid >/dev/null 2>&1
rm -rf /usr/bin/tinymapper
echo -e " \n$green卸载完成.$none\n" && exit 1
else
echo -e " \n$red未安装tinyPortMapper ? $none\n" && exit 1
fi
}
error() {
echo -e "\n$red 输入错误!$none\n"
}
while :; do
echo
echo "........... tinyPortMapper 快速一键安装 by Reechang .........."
echo
echo "此脚本经Reechang魔改,原作者233boy"
echo
echo " 1. 安装"
echo
echo " 2. 卸载"
echo
read -p "请选择[1-2]:" choose
case $choose in
1)
install
break
;;
2)
uninstall
break
;;
*)
error
;;
esac
done