-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
80 lines (60 loc) · 1.93 KB
/
install.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
#!/bin/bash
set -e
CHAT_VERSION=0.0.3
GUI_VERSION=0.0.7
TMPD=/tmp/chat-installer
CHAT_URL="https://github.com/Tysonpower/Dreamcatcher-Packet-Tester/releases/download/${CHAT_VERSION}/chat"
GUI_URL="https://github.com/foxbunny/wschat/releases/download/${GUI_VERSION}/wschat-armv7"
error () {
echo "[ERROR]" "$@"
exit 1
}
dl () {
wget -q --no-check-certificate $1
}
echo "[INFO ] Installing Dreamcatcher chat
--------------------------------
chat version: v$CHAT_VERSION
GUI version: v$GUI_VERSION
--------------------------------"
rm -rf "$TMPD"
mkdir -p "$TMPD"
cd "$TMPD"
echo "[INFO ] Downloading chat programs"
dl "$CHAT_URL" >/dev/null || error "Could not download programs"
dl "$GUI_URL" >/dev/null || error "Could not download programs"
echo "[INFO ] Installing chat programs"
install -m755 chat /usr/local/bin/chat \
|| error "Could not install the chat app"
install -m755 wschat-armv7 /usr/local/bin/wschat \
|| error "Could not install the chat app"
echo "[INFO ] Creating chat script"
echo "#!/bin/bash
ip_addr=\`ifconfig | grep 'inet ' | grep -v '127.0.0.1' | tr -s ' ' | cut -d ' ' -f 3\`
echo IP address \$ip_addr
wschat --addr=0.0.0.0:8080 chat" > /usr/local/bin/start-chat \
|| error "Could not install the chat app"
chmod +x /usr/local/bin/start-chat || error "Could not install the chat app"
echo "[INFO ] Installing system service"
echo "[Unit]
Description=Dreamcatcher chat
[Service]
ExecStart=/bin/bash -c '/usr/local/bin/start-chat'
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/chat.service \
|| error "Could not install the chat service"
echo "[INFO ] Reloading daemon list"
systemctl daemon-reload \
|| error "Could not reload the daemon list. Please reboot"
echo "[INFO ] Removing temporary install files"
cd - >/dev/null
rm -rf "$TMPD"
# Make sure files persist
sync
sync
echo "[INFO ] Done
To start the chat server, type:
start-chat
To start the server on boot:
systemctl enable chat
"