/etc/init.d/openvas-server is in openvas-server 2.0.3-6.
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 | #!/bin/sh -e
#
# /etc/init.d/openvasd
#
# Originally written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for nessusd by Luca Andreucci <andrew@andrew.org>
# Further changes by Javier Fernandez-Sanguino <jfs@debian.org> for the
# Debian GNU/Linux distribution
# Even more changes for Debian GNU/Linux openvas-server package by
# Tim Brown <timb@nth-dimension.org.uk>
#
### BEGIN INIT INFO
# Provides: openvas-server
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop: 0 6
# Short-Description: Start and stop the OpenVAS daemon
# Description: Controls the main OpenVAS daemon "openvasd".
### END INIT INFO
# daemon options (-D implied, not needed)
DAEMONOPTS="-q"
# time to wait for daemons death, in seconds
# don't set it too low or you might not let openvasd die gracefully
DODTIME=5
[ -r /etc/default/openvas-server ] && . /etc/default/openvas-server
DAEMON=/usr/sbin/openvasd
PIDFILE=/var/run/openvasd.pid
NAME=openvasd
LABEL="OpenVAS daemon"
test -x $DAEMON || exit 0
running()
{
# No pidfile, probably no daemon present
#
[ ! -f "$PIDFILE" ] && return 1
pid=`cat $PIDFILE`
# No pid, probably no daemon present
[ -z "$pid" ] && return 1
[ ! -d /proc/$pid ] && return 1
cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
# No openvasd?
[ "$cmd" != "$NAME" ] && return 1
return 0
}
warn_cert_file() {
echo -n "WARN: The (expected) certificate file $1 is not available." >&2
echo -n "The OpenVAS daemon might not start up." >&2
}
check_certs() {
if [ -z "`grep ^ca_file /etc/openvas/openvasd.conf`" ] ; then
echo -n "WARN: The openvasd configuration file does not contain certificate settings. Have you run openvas-mkcert? (openvasd might not start)" >&2
fi
CERTDIR=/var/lib/openvas/CA/
PRIVCERTDIR=/var/lib/openvas/private/CA/
for cert in cacert.pem servercert.pem; do
[ ! -r "$CERTDIR/$cert" ] && warn_cert_file "$CERTDIR/$cert"
done
for cert in cakey.pem serverkey.pem; do
[ ! -r "$PRIVCERTDIR/$cert" ] && warn_cert_file "$CERTDIR/$cert"
done
}
openvas_start() {
if [ ! -r /etc/openvas/openvasd.conf ] ; then
echo -n "ERROR: Cannot read openvas configuration file, are you root?" >&2
return 1
fi
check_certs
start-stop-daemon --start --exec $DAEMON -- $DAEMONOPTS -D 2>&1 >/dev/null
errcode=$?
# If we don't sleep then running() might not see the pidfile
sleep $DODTIME
return $errcode
}
force_stop() {
[ ! -e "$PIDFILE" ] && return
if running ; then
kill -15 $pid
# Is it really dead?
sleep "$DODTIME"s
if running ; then
kill -9 $pid
sleep "$DODTIME"s
if running ; then
echo "Cannot kill $LABEL (pid=$pid)!"
exit 1
fi
fi
fi
rm -f $PIDFILE
}
case "$1" in
start)
echo -n "Starting $LABEL: "
if openvas_start && running ; then
echo "openvasd."
else
echo "ERROR."
exit 1
fi
;;
stop)
echo -n "Stopping $LABEL: "
if running ; then
start-stop-daemon --stop --pidfile $PIDFILE --quiet --oknodo --exec $DAEMON
sleep "$DODTIME"s
fi
if running; then
force_stop
fi
echo "openvasd."
;;
restart)
echo -n "Restarting $LABEL: "
if running; then
start-stop-daemon --stop --pidfile $PIDFILE --quiet --oknodo --exec $DAEMON
sleep "$DODTIME"s
fi
if running; then
force_stop
fi
if openvas_start && running ; then
echo "openvasd."
else
echo "ERROR."
exit 1
fi
;;
reload|force-reload)
echo -n "Reloading $LABEL configuration files: "
start-stop-daemon --stop --pidfile $PIDFILE --signal 1 --exec $DAEMON
sleep "$DODTIME"s
if running ; then
echo "done."
else
echo "ERROR."
exit 1
fi
;;
status)
echo -n "$LABEL is "
if running ; then
echo "running"
else
echo " not running."
exit 1
fi
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|status}"
exit 1
;;
esac
exit 0
|