This repository has been archived by the owner on Dec 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mswatchdog.sh.in
executable file
·73 lines (65 loc) · 1.88 KB
/
mswatchdog.sh.in
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
##
# Worldforge Next Generation MetaServer
#
# Copyright (C) 2013 Sean Ryan <sryan@evercrack.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
##
# Author: Sean Ryan <sryan@evercrack.com>
# Synopsis: Checks if the MS is running. If not it attempts to start.
#
TIME=$(date)
MSHOME=@prefix@
CONF=@prefix@/etc/metaserver-ng.conf
if [[ -f ~/.metaserver-ng.conf ]]; then
CONF=~/.metaserver-ng.conf;
echo "Local configuration detected";
fi
PIDF=$(grep pidfile $CONF | awk -F= '{ print $2 }');
echo "-----------------------------";
echo "Configuration: $CONF";
echo "MSHOME: $MSHOME";
echo "PID: $PIDF";
echo "Date: $TIME";
echo "-----------------------------";
##
# Check 1 - does pid exist.
# Missing pid means not running because the MS will shutdown
# if the pidfile disappears
##
if [[ ! -f $PIDF ]]; then
echo "RESTART: Missing pidfile";
$MSHOME/bin/metaserver-ng
exit 0;
fi
##
# Check 2 - check if pid contained in pidfile is running
#
##
PP=$(cat $PIDF);
kill -0 $PP
if [[ $? -ne 0 ]]; then
echo "RESTART: pid ($PP) listed in file ($PIDF) is not running";
$MSHOME/bin/metaserver-ng
exit 0;
fi
##
# We must be fine
#
echo "OK: $PP metaserver-ng running";
echo "-----------------------------";
exit 0;