forked from hoytech/strfry
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstrfry.sh
52 lines (39 loc) · 890 Bytes
/
strfry.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
#!/usr/bin/env bash
set -Eeuo pipefail
: ${ROUTER:=''}
: ${STREAMS:=''}
: ${COMPACT:=''}
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
if [ ! -f "/etc/strfry.conf" ]; then
cp /etc/strfry.conf.default /etc/strfry.conf
fi
cd /app
if [[ "$COMPACT" == [Yy1]* ]]; then
db="./strfry-db/data.mdb"
lock="./strfry-db/lock.mdb"
if [ -f "$db" ]; then
./strfry compact - > "$db.compacted"
[ -f "$lock" ] && rm -f "$lock"
mv -f "$db.compacted" "$db"
else
echo "Error: database file $db not found.."
fi
fi
./strfry relay &
PID=$!
if [ -f "$ROUTER" ]; then
sleep 2
./strfry router "$ROUTER" &
fi
if [[ "$ROUTER" == [Yy1]* ]]; then
sleep 2
./strfry router /etc/strfry-router.conf &
fi
for i in $(echo "$STREAMS" | sed "s/,/ /g")
do
if [[ -n "$i" ]]; then
sleep 2
./strfry stream wss://$i --dir down 2> /dev/null &
fi
done
wait "$PID"