all repos — xrxs @ 6864b143f2a3c787f982bd882902bc37d70b7984

experimental networked application/game server with 9p

server/xrxs-srv.sh (raw)

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
#!/bin/sh

if [ -z "${XRXS_PORT}" ]; then
  XRXS_PORT=5460
else

if [ -z "${DISPLAY}" ]; then
  export DISPLAY=:0
fi

seat=$(echo ${DISPLAY} | awk -F. '{print $1}')

debug=""

case $1 in
  start)
    if [ "$2" = "-d" ]; then
      debug="-d"
    fi
    ./xrxs -s xrxs ${debug} & sleep 1
    9pserve -c unix!/tmp/ns.$(whoami).${seat}/xrxs tcp!0.0.0.0!${XRXS_PORT} &
    ;;
  stop)
    killall xrxs
    rm /tmp/ns.$(whoami).${seat}/xrxs
    ;;
  *)
    echo "$0 start|stop"
    echo "  start: run the xrxs service in the background"
    echo "  stop:  terminates xrxs services"
    ;;
esac