%PDF- %PDF-
| Direktori : /opt/veeam/deployment/scripts/ |
| Current File : //opt/veeam/deployment/scripts/veeamdeployment |
#! /bin/sh
### BEGIN INIT INFO
# Provides: VeeamDeploymentSvc
# Required-Start: $local_fs $remote_fs $syslog $network
# Required-Stop: $local_fs $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Veeam Linux Deployer service daemon
### END INIT INFO
# Author: Veeam Software Group GmbH <https://www.veeam.com/contacts.html>
# Do NOT "set -e"
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Veeam Linux Deployer service"
NAME=veeamdeployment
DAEMON=/opt/veeam/deployment/veeamdeploymentsvc
PIDFILE=/var/run/$NAME.pid
PIDFILEVCP=/var/run/veeamdeploymentvcpserver.pid
PIDFILESUPER=/var/run/veeamdeploymentsupervisor.pid
SCRIPTNAME=/etc/init.d/$NAME
# 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
# Load the VERBOSE setting and other rcS variables
#. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
#. /lib/lsb/init-functions
#
# Function that gets daemon pid
#
get_pid() {
cat "$1"
}
#
# Function that check whether daemon is running
#
is_running() {
[ -f "$1" ] && ps -p `get_pid $1` > /dev/null 2>&1
}
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
$DAEMON --start-service || return 0
}
#
# Function that stops the daemon/service
#
do_stop()
{
# 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
PID=`get_pid $PIDFILE`
$DAEMON --stop-service
tail --pid=$PID -f /dev/null
RETVAL="$?"
return "$RETVAL"
}
#
# Function returns command line of the process
#
print_process_cmd()
{
PID=$(get_pid $1)
CMD=$(ps -fp $PID | tail -n 1 | tr -s " " | cut -d " " -f 2,8,9)
echo "$CMD" >&2
}
#
# Function that shows a status of the processes daemon/service
#
do_status()
{
echo "$NAME $DESC" >&2
if is_running $PIDFILESUPER; then
echo "Status: (Main PID `get_pid $PIDFILESUPER`) is running..." >&2
print_process_cmd $PIDFILESUPER
print_process_cmd $PIDFILE
print_process_cmd $PIDFILEVCP
else
echo "Status: is stopped" >&2
fi
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
if is_running $PIDFILE; then
do_stop
fi
case "$?" in
0|1)
do_start
case "$?" in
0) #log_end_msg 0
;;
1) #log_end_msg 1
;; # Old process is still running
*) #log_end_msg 1
;; # Failed to start
esac
;;
*)
# Failed to stop
#log_end_msg 1
;;
esac
;;
status)
do_status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 3
;;
esac
: