-
Notifications
You must be signed in to change notification settings - Fork 124
/
setup.sh
executable file
·64 lines (53 loc) · 1.92 KB
/
setup.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
#!/bin/bash
VERSION="0.102.4"
STATHUB_URL="https://github.com/likexian/stathub-go/releases/download/v${VERSION}/stathub.$(uname -m).tar.gz"
BASEDIR="/usr/local/stathub"
[ $(id -u) -ne 0 ] && sudo="sudo" || sudo=""
id -u nobody >/dev/null 2>&1
if [ $? -ne 0 ]; then
$sudo groupadd nogroup
useradd -g nogroup nobody -s /bin/false
fi
$sudo mkdir -p $BASEDIR
$sudo chown -R $(id -u -n):$(id -g -n) $BASEDIR
if [ ! -d $BASEDIR ]; then
echo "Unable to create dir $BASEDIR and chown to current user, Please manual do it"
exit 1
fi
cd $BASEDIR
command_exists() {
type "$1" &> /dev/null
}
if command_exists wget; then
wget --no-check-certificate $STATHUB_URL
elif command_exists curl; then
curl --insecure -O $STATHUB_URL
else
echo "Unable to find curl or wget, Please install and try again."
exit 1
fi
if [ ! -f stathub.$(uname -m).tar.gz ]; then
echo "Unable to get server file, Please manual download it"
exit 1
fi
tar zxf stathub.$(uname -m).tar.gz
chmod +x stathub service
[ ! -d conf ] && $sudo mkdir $BASEDIR/conf
if [ ! -f conf/stathub.conf ]; then
$sudo ./stathub -c conf/stathub.conf --init-server
fi
$sudo mkdir $BASEDIR/pkgs
mv stathub.*.tar.gz $BASEDIR/pkgs
if [ -z "$(grep stathub /etc/rc.local)" ]; then
$sudo sh -c "echo \"cd $BASEDIR; rm -f log/stathub.pid; ./service start >>$BASEDIR/log/stathub.log 2>&1\" >> /etc/rc.local"
fi
echo "----------------------------------------------------"
echo "| Server install successful, Please start it using |"
echo "| ./service {start|stop|restart} |"
echo "| Now it will automatic start |"
echo "| |"
echo "| Feedback: https://github.com/likexian/stathub-go |"
echo "| Thank you for your using, By Li Kexian |"
echo "| StatHub, Apache License, Version 2.0 |"
echo "----------------------------------------------------"
$sudo ./service start