forked from Har-Kuun/OneClickCDN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
130 lines (119 loc) · 4.09 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
#################################################################
# One-click CDN Installation Script v0.0.4 #
# Written by shc (https://qing.su) #
# Github link: https://github.com/Har-Kuun/OneClickCDN #
# Contact me: https://t.me/hsun94 E-mail: [email protected] #
# #
# This script is distributed in the hope that it will be #
# useful, but ABSOLUTELY WITHOUT ANY WARRANTY. #
# #
# Thank you for using this script. #
#################################################################
#You can change the Traffic Server source file download link here.
#If you changed the download link when installing the script, please also change the link here to match the Traffic Server version you installed.
#If you did not change the download link during the installation, simply leave it as is.
TS_DOWNLOAD_LINK="https://mirrors.ocf.berkeley.edu/apache/trafficserver/trafficserver-8.1.5.tar.bz2"
TS_VERSION="8.1.5"
#########################################################################
# Functions start here. #
# Do not change anything below unless you know what you are doing. #
#########################################################################
function display_license
{
echo
echo '*******************************************************************'
echo '* One-click CDN installation script *'
echo '* Version 0.0.4 *'
echo '* Author: shc (Har-Kuun) https://qing.su *'
echo '* https://github.com/Har-Kuun/OneClickCDN *'
echo '* Thank you for using this script. E-mail: [email protected] *'
echo '*******************************************************************'
}
function say
{
#This function is a colored version of the built-in "echo."
#https://github.com/Har-Kuun/useful-shell-functions/blob/master/colored-echo.sh
echo_content=$1
case $2 in
black | k ) colorf=0 ;;
red | r ) colorf=1 ;;
green | g ) colorf=2 ;;
yellow | y ) colorf=3 ;;
blue | b ) colorf=4 ;;
magenta | m ) colorf=5 ;;
cyan | c ) colorf=6 ;;
white | w ) colorf=7 ;;
* ) colorf=N ;;
esac
case $3 in
black | k ) colorb=0 ;;
red | r ) colorb=1 ;;
green | g ) colorb=2 ;;
yellow | y ) colorb=3 ;;
blue | b ) colorb=4 ;;
magenta | m ) colorb=5 ;;
cyan | c ) colorb=6 ;;
white | w ) colorb=7 ;;
* ) colorb=N ;;
esac
if [ "x${colorf}" != "xN" ] ; then
tput setaf $colorf
fi
if [ "x${colorb}" != "xN" ] ; then
tput setab $colorb
fi
printf "${echo_content}" | sed -e "s/@B/$(tput bold)/g"
tput sgr 0
printf "\n"
}
function uninstall_ts
{
current_dir=$(pwd)
if [ -f ${current_dir}/trafficserver-${TS_VERSION}/configure ] ; then
cd ${current_dir}/trafficserver-${TS_VERSION}/
else
wget $TS_DOWNLOAD_LINK
tar xjf trafficserver-${TS_VERSION}.tar.bz2
rm trafficserver-${TS_VERSION}.tar.bz2
cd ${current_dir}/trafficserver-${TS_VERSION}
./configure
fi
make uninstall
make distclean
cd $current_dir
rm -fr trafficserver-${TS_VERSION}
rm -f /etc/systemd/system/trafficserver.service
rm -fr /etc/trafficserver
rm -fr /usr/local/etc/trafficserver
systemctl daemon-reload
echo
say @B"Traffic Server has been uninstalled!" green
echo "Thank you for using this script!"
echo "Have a nice day!"
echo
}
function main
{
display_license
echo
if [ ! -f /usr/local/bin/trafficserver ] ; then
say @B"Traffic server is NOT installed." red
echo
exit 1
fi
echo "You are about to uninstall Traffic Server CDN."
echo "This will remove all related configurations as well."
say "Please type UNINSTALL to continue.\nType anything else to cancel the uninstallation." yellow blue
read do_uninstall
if [ "x$do_uninstall" = "xUNINSTALL" ] ; then
uninstall_ts
else
echo
say @B"Traffic Server not uninstalled." blue
echo "Have a nice day!"
echo
fi
exit 0
}
main