###############################################################################
# Dell Inc. PROPRIETARY INFORMATION
# This software is supplied under the terms of a license agreement or
# nondisclosure agreement with Dell Inc. and may not
# be copied or disclosed except in accordance with the terms of that
# Copyright (c) 2000-2018 Dell Inc. All Rights Reserved.
# This Script will start/stop/restart/status all the services installed
###############################################################################
# ensure sbin utilities are available in path, so that su will also work
export PATH="/usr/kerberos/sbin:/usr/local/sbin:/sbin:/usr/sbin:${PATH}"
# Include CheckSystemType so that support for server generation can be checked
if [ ! -f "/opt/dell/srvadmin/sbin/CheckSystemType" ]; then
echo "File /opt/dell/srvadmin/sbin/CheckSystemType not found"
. "/opt/dell/srvadmin/sbin/CheckSystemType"
# Server Administrator package prefix
SRVADMIN_STR="Server Administrator"
# checks if OS init system is systemd or initd
ps --no-headers -o comm 1 | grep -i systemd >/dev/null 2>&1
# list of services start and status
# Maintain the order of the services
if [ ${IS_SYSTEMD} -eq 1 ]; then
arrayStart=(instsvcdrv dsm_sa_eventmgrd dsm_sa_datamgrd dsm_sa_snmpd dsm_om_connsvc)
arrayStatus=(instsvcdrv dsm_sa_datamgrd dsm_sa_eventmgrd dsm_sa_snmpd dsm_om_connsvc)
arrayStart=(instsvcdrv dataeng dsm_om_connsvc)
arrayStatus=(instsvcdrv dataeng dsm_om_connsvc)
# list of services to stop
arrayStop=($(printf '%s\n' "${arrayStart[@]}" | tac | tr '\n' ' '))
# include DSM SA Shared service in start/stop/status array when it is enabled
if [ ${IS_SYSTEMD} -eq 1 ]; then
systemctl is-enabled dsm_om_shrsvc.service >/dev/null 2>&1
if [ -x /sbin/chkconfig ]; then
/sbin/chkconfig dsm_om_shrsvc >/dev/null 2>&1
arrayStart+=('dsm_om_shrsvc')
arrayStop+=('dsm_om_shrsvc')
arrayStatus+=('dsm_om_shrsvc')
# start/stop/status for multiple services
if [ ${IS_SYSTEMD} -eq 1 ]; then
systemctl list-unit-files $svc.service | grep $svc.service >/dev/null 2>&1
#systemctl is-enabled $svc.service >/dev/null 2>&1
systemctl $action $svc.service
elif [ -e /etc/init.d/$svc ] && [ -x /sbin/chkconfig ]; then
/sbin/chkconfig $svc >/dev/null 2>&1
# status is 1 if any service action exit code is not 0 else 0
# enable/disable multiple services
systemctl $ctl $svc.service >/dev/null 2>&1
/sbin/chkconfig $svc $ctl >/dev/null 2>&1
if [ ${IS_SYSTEMD} -eq 1 ]; then
systemctl is-enabled $svc.service >/dev/null 2>&1
/sbin/chkconfig $svc >/dev/null 2>&1
# status is 1 if any service is disabled else 0
Usage: srvadmin-services.sh {start|stop|status|restart|enable|disable|is-enabled|help}
start : starts ${SRVADMIN_STR} services
stop : stops ${SRVADMIN_STR} services
status : display status of ${SRVADMIN_STR} services
restart : restart ${SRVADMIN_STR} services
enable : enable ${SRVADMIN_STR} services in runlevels 2, 3 and 5
disable : disable ${SRVADMIN_STR} services in runlevels 2, 3 and 5
is-enabled : checks whether ${SRVADMIN_STR} services is enabled or not
help : displays this help text
# make sure services dont busy out any mountpoints
# check for root privileges
if [ ${UID} -ne 0 ]; then
echo "This utility requires root privileges"
# add or remove shared service from list
# Note the ${@:- ... } set up this way so that we either stop/start/etc full
# set of services, or specific service if passed. ${@} is set to cmdline
# params. If these are not set, then the stuff after :- is used as a default.
IsThisSupportedGeneration
echo "Unsupported Server... ${SRVADMIN_STR} Services not started"
serviceAction start ${@:-${arrayStart[*]}}
serviceAction stop ${@:-${arrayStop[*]}}
serviceAction status ${@:-${arrayStatus[*]}}
IsThisSupportedGeneration
echo "Unsupported Server... ${SRVADMIN_STR} Services not restarted"
serviceAction stop ${@:-${arrayStop[*]}}
serviceAction stop ${@:-${arrayStop[*]}}
serviceAction start ${@:-${arrayStart[*]}}
arrayStatus=( "${arrayStatus[*]#dsm_om_shrsvc}" )
if [ ${IS_SYSTEMD} -eq 1 ]; then
serviceCtl enable ${@:-${arrayStatus[*]}}
serviceCtl on ${@:-${arrayStatus[*]}}
arrayStatus=( "${arrayStatus[*]#dsm_om_shrsvc}" )
if [ ${IS_SYSTEMD} -eq 1 ]; then
serviceCtl disable ${@:-${arrayStatus[*]}}
serviceCtl off ${@:-${arrayStatus[*]}}
arrayStatus=( "${arrayStatus[*]#dsm_om_shrsvc}" )
serviceCtl status ${@:-${arrayStatus[*]}}
[ -z "${action}" ] || echo -e "Invalid option '${action}', please see the usage below\n"