/etc/init.d/oar-server is in oar-server 2.5.6-2ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | #!/bin/bash
#
# oar-server OAR Server
#
# chkconfig: 2345 90 10
# description: This script starts or stops the OAR resource manager
# processname: Almighty
# config: /etc/oar/oar.conf
# pidfile: /var/run/oar-server.pid
### BEGIN INIT INFO
# Provides: oar-server
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: postgresql mysql-server
# Should-Stop: postgresql mysql-server
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OAR server
# Description: This script starts or stops the OAR resource manager
### END INIT INFO
LANG=C
export LANG
PATH=/usr/sbin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin:$PATH
NAME=oar-server
DESC="OAR server"
DAEMON=/usr/sbin/oar-server
DAEMON_NAME=Almighty
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
SELINUXENABLED_CMD=$(which selinuxenabled 2>/dev/null)
NOLSB=
[ -f /lib/lsb/init-functions ] || NOLSB=yes
if [ -f /etc/debian_version ]; then
system=debian
elif [ -f /etc/redhat-release ]; then
system=redhat
elif [ -f /etc/SuSE-release ]; then
system=suse
elif [ -f /etc/gentoo-release ]; then
system=gentoo
fi
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
if [ -z "$NOLSB" ]; then
. /lib/lsb/init-functions
fail_msg() {
echo ""
log_failure_msg "$@"
}
warn_msg() {
log_warning_msg "$@"
}
succ_msg() {
log_success_msg "$@"
}
begin_msg() {
echo -n "$@:"
}
else
echo "This system doesn't provide the LSB functions. Failing"
exit 1
fi
do_start() {
begin_msg "Starting $DESC"
if [ -n "$SELINUXENABLED_CMD" -a -x "$SELINUXENABLED_CMD" ] && "$SELINUXENABLED_CMD"; then
fail_msg "SELinux is enabled, $DESC cannot be started."
exit 1
fi
CHECK_STRING=$(oar-database --check > /dev/null 2>&1)
if [ "$?" -ne "0" ]; then
fail_msg "OAR database seems not ready. See \`oar-database --check'"
exit 1
fi
if pidofproc -p $PIDFILE $DAEMON > /dev/null; then
warn_msg "$DESC is already running."
exit 0
fi
start_daemon -p "$PIDFILE" "$DAEMON" $DAEMON_ARGS
RET=$?
if [ "$RET" != 0 ]; then
fail_msg "Unable to start $DESC."
exit 1
else
succ_msg
# redhat world
[ -d /var/lock/subsys/ ] && touch /var/lock/subsys/$NAME
fi
}
#
# Function that stops the daemon/service
#
do_stop()
{
begin_msg "Stopping $DESC"
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
killproc -p $PIDFILE
RETVAL="$?"
if [ "$RETVAL" = 2 ]; then
fail_msg "Unable to stop $DESC."
exit 2
fi
# Sarko is often frozed when the database is unreachable
killproc sarko
# Extermination...
killproc $DAEMON_NAME
if [ "$?" = 2 ]; then
fail_msg "Unable to stop $DESC."
exit 2
fi
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
# redhat world
[ -d /var/lock/subsys/ ] && rm -f /var/lock/subsys/$NAME
succ_msg
return 0
}
#
# utility functions to check the status of the daemon
#
__pids_var_run() {
local base=${1##*/}
local pid_file=${2:-/var/run/$base.pid}
pid=
if [ -f "$pid_file" ]; then
local line p
[ ! -r "$pid_file" ] && return 4 # "user had insufficient privilege"
while : ; do
read line
[ -z "$line" ] && break
for p in $line ; do
[ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
done
done < "$pid_file"
if [ -n "$pid" ]; then
return 0
fi
return 1 # "Program is dead and /var/run pid file exists"
fi
return 3 # "Program is not running"
}
__pids_pidof() {
pidof -c -o $$ -o $PPID -o %PPID -x "$1" || \
pidof -c -o $$ -o $PPID -o %PPID -x "${1##*/}"
}
#
# Function that checks the daemon/service
#
status() {
local base pid lock_file pid_file
# Test syntax
if [ "$#" = 0 ] ; then
echo $"Usage: status [-p pidfile] {program}"
return 1
fi
if [ "$1" = "-p" ]; then
pid_file=$2
shift 2
fi
if [ "$1" = "-l" ]; then
lock_file=$2
shift 2
fi
base=${1##*/}
# First try "pidof"
__pids_var_run "$1" "$pid_file"
RC=$?
if [ -z "$pid_file" -a -z "$pid" ]; then
pid="$(__pids_pidof "$1")"
fi
if [ -n "$pid" ]; then
echo $"${base} (pid $pid) is running..."
return 0
fi
case "$RC" in
0)
echo $"${base} (pid $pid) is running..."
return 0
;;
1)
echo $"${base} dead but pid file exists"
return 1
;;
4)
echo $"${base} status unknown due to insufficient privileges."
return 4
;;
esac
if [ -z "${lock_file}" ]; then
lock_file=${base}
fi
# See if /var/lock/subsys/${lock_file} exists
if [ -f /var/lock/subsys/${lock_file} ]; then
echo $"${base} dead but subsys locked"
return 2
fi
echo $"${base} is stopped"
return 3
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
reload|restart|force-reload)
if do_stop; then
sleep 1
do_start
fi
;;
status)
status -p $PIDFILE $NAME
exit $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status|force-reload}" >&2
exit 1
;;
esac
:
|