-
Notifications
You must be signed in to change notification settings - Fork 103
/
install_fs.sh
157 lines (139 loc) · 3.02 KB
/
install_fs.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#! /bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
install_path=/fs/
package_download_url=https://raw.githubusercontent.com/leesiyang/finalspeed/master/finalspeed_server.zip
package_save_name=finalspeed_server.zip
function checkjava(){
java -version
#echo $?
if [[ $? -le 1 ]] ;then
echo " Run java success"
else
echo " Run java failed"
echo $OS
if [[ $OS = "centos" ]]; then
echo " Install centos java ..."
yum install -y java-1.8.0-openjdk
fi
if [[ $OS = "ubuntu" ]]; then
echo " Install ubuntu java ..."
apt-get install -y openjdk-7-jre
fi
if [[ $OS = "debian" ]]; then
echo " Install debian java ..."
apt-get install -y openjdk-7-jre
fi
fi
# if [[ ! -d "$result" ]]; then
# echo "不存在"
# else
# echo "存在"
# fi
echo $result
}
function checkunzip(){
unzip
#echo $?
if [[ $? -le 1 ]] ;then
echo " Run unzip success"
else
echo " Run unzip failed"
echo $OS
if [[ $OS = "ubuntu" ]]; then
echo " Install ubuntu unzip ..."
apt-get -y install unzip
fi
if [[ $OS = "debian" ]]; then
echo " Install debian unzip ..."
apt-get -y install unzip
fi
if [[ $OS = "centos" ]]; then
echo " Install centos unzip ..."
yum install -y unzip
fi
fi
# if [[ ! -d "$result" ]]; then
# echo "不存在"
# else
# echo "存在"
# fi
echo $result
}
function checkwget(){
wget
#echo $?
if [[ $? -le 1 ]] ;then
echo " Run wget success"
else
echo " Run wget failed"
echo $OS
if [[ $OS = "ubuntu" ]]; then
echo " Install ubuntu wget ..."
apt-get -y install wget
fi
if [[ $OS = "debian" ]]; then
echo " Install debian wget ..."
apt-get -y install wget
fi
if [[ $OS = "centos" ]]; then
echo " Install centos wget ..."
yum install -y wget
fi
fi
echo $result
}
function checkenv(){
if [[ $OS = "ubuntu" ]]; then
apt-get update
apt-get -y install libpcap-dev
apt-get -y install iptables
fi
if [[ $OS = "debian" ]]; then
echo "apt-get updateapt-get updateapt-get update"
apt-get update
apt-get -y install libpcap-dev
apt-get -y install iptables
fi
if [[ $OS = "centos" ]]; then
#yum update
yum -y install libpcap
yum -y install iptables
fi
}
function checkos(){
if [[ -f /etc/redhat-release ]];then
OS=centos
elif [[ ! -z "`cat /etc/issue | grep bian`" ]];then
OS=debian
elif [[ ! -z "`cat /etc/issue | grep Ubuntu`" ]];then
OS=ubuntu
else
echo "Unsupported operating systems!"
exit 1
fi
echo $OS
}
# Install finalspeed
function install_finalspeed(){
rm -f $package_save_name
echo "Download software..."
if ! wget -O $package_save_name $package_download_url ; then
echo "Download software failed!"
exit 1
fi
if [[ ! -d "$install_path" ]]; then
mkdir "$install_path"
else
echo "Update Software..."
fi
unzip -o $package_save_name -d $install_path
sh ${install_path}"restart.sh"
tail -f ${install_path}"server.log"
}
checkos
checkenv
checkwget
checkjava
checkunzip
install_finalspeed