blob: 759cbcb58aeff3468c9bad2d6815651c61741bfe (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/sh
# SPDX-FileCopyrightText: 2024 Markus Uhlin <maxxe@rpblc.net>
# SPDX-License-Identifier: ISC
#
# This script is suitable to be run as a cron job for the dedicated
# chess user.
# You need to change these variables if FICS was built with a
# non-standard home location.
FICS_LOCKFILE=/home/chess/config/fics.pid
FICS_PROG=/home/chess/bin/fics
run_fics()
{
if [ -x ${FICS_PROG} ]; then
${FICS_PROG} -d || exit 1
exit 0
else
echo "cannot find the program"
exit 1
fi
}
if [ -r $FICS_LOCKFILE ]; then
PID="$(cat $FICS_LOCKFILE)"
case "$PID" in
""|*[!0-9]*)
echo "pid not numeric"
exit 1
;;
*)
;;
esac
if [ ${#PID} -gt 20 ]; then
echo "pid too long"
exit 1
fi
if ps -p "$PID" > /dev/null; then
# already running (good)
exit 0
else
echo "$PID not running. restarting..."
rm -f $FICS_LOCKFILE
run_fics
fi
else
run_fics
fi
|