forked from Thornsnake/MCRBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
29 lines (23 loc) · 616 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
#!/bin/sh
# Get the base directory and switch into it
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')");
cd "$basedir";
# Make sure the name file exists
if [ ! -f "bot.name" ]
then
echo "[SETUP] Name file not found! Try running install.sh ...";
exit;
fi
# Get the name of the bot
read -r name < bot.name;
# Check if the bot is in the process list
if pm2 list | grep "$name" >/dev/null 2>&1
then
sh restart.sh
else
# Compile the typescript files to javascript
./node_modules/.bin/tsc;
# Start the bot
pm2 start index.js --name "$name" --time;
echo "[OK] "$name" started!";
fi