summarylogtreecommitdiffstats
path: root/starbound_server
blob: 51b1082facab30a6ccfe4e23a3125c0afb285235 (plain)
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
#!/bin/bash

logfile=/var/log/starbound.log
pidfile=/run/starbound.pid

function init_server {
  echo $$ > $pidfile
  
  echo -e "\n[$(date)] starting starbound server" >> $logfile
  chown starbound:starbound $logfile
}

function start_server {
  cd /usr/share/starbound/linux
  ./starbound_server >> "$logfile" &
}

function stop_server {
  pid=$(cat /run/starbound.pid)
  kill $pid
  rm /run/starbound.pid
  echo -e "[$(date)] stopped starbound server" >> $logfile
}

case $1 in
  init)
    init_server
    ;;
  start)
    start_server
    ;;
  stop)
    stop_server
    ;;
esac

exit 0