-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
45 lines (37 loc) · 885 Bytes
/
start.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
#!/bin/sh
cd /
if [ ! -d "/motd-menu" ]; then
git clone --recursive https://github.com/Tripperful/motd-menu.git
cd /motd-menu
echo "Installing packages..."
npm ci
echo "Building..."
npm run build
fi
cd /motd-menu
cp ./start.sh /start.sh
echo "Starting the server..."
node ./packages/server/dist/index.js &
while :; do
sleep 10
git fetch
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
if [ $LOCAL != $REMOTE ]; then
echo "Remote changed, pulling changes and re-building"
git reset --hard origin/master
echo "Installing packages..."
npm ci
echo "Building..."
npm run build
echo "Stopping the server..."
pkill node
fi
if ! pgrep -x "node" > /dev/null
then
echo "Starting the server..."
node ./packages/server/dist/index.js &
fi
done