Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/dell/srvadmin/sbin
File: srvadmin-services.sh
#!/bin/sh
[0] Fix | Delete
###############################################################################
[1] Fix | Delete
#
[2] Fix | Delete
# Dell Inc. PROPRIETARY INFORMATION
[3] Fix | Delete
# This software is supplied under the terms of a license agreement or
[4] Fix | Delete
# nondisclosure agreement with Dell Inc. and may not
[5] Fix | Delete
# be copied or disclosed except in accordance with the terms of that
[6] Fix | Delete
# agreement.
[7] Fix | Delete
#
[8] Fix | Delete
# Copyright (c) 2000-2018 Dell Inc. All Rights Reserved.
[9] Fix | Delete
#
[10] Fix | Delete
# Abstract/Purpose:
[11] Fix | Delete
#
[12] Fix | Delete
# This Script will start/stop/restart/status all the services installed
[13] Fix | Delete
# by Systems Management.
[14] Fix | Delete
#
[15] Fix | Delete
###############################################################################
[16] Fix | Delete
[17] Fix | Delete
# ensure sbin utilities are available in path, so that su will also work
[18] Fix | Delete
export PATH="/usr/kerberos/sbin:/usr/local/sbin:/sbin:/usr/sbin:${PATH}"
[19] Fix | Delete
exit_status=0
[20] Fix | Delete
[21] Fix | Delete
# Include CheckSystemType so that support for server generation can be checked
[22] Fix | Delete
[23] Fix | Delete
if [ ! -f "/opt/dell/srvadmin/sbin/CheckSystemType" ]; then
[24] Fix | Delete
echo "File /opt/dell/srvadmin/sbin/CheckSystemType not found"
[25] Fix | Delete
exit 1
[26] Fix | Delete
fi
[27] Fix | Delete
[28] Fix | Delete
. "/opt/dell/srvadmin/sbin/CheckSystemType"
[29] Fix | Delete
[30] Fix | Delete
# Server Administrator package prefix
[31] Fix | Delete
SRVADMIN_STR="Server Administrator"
[32] Fix | Delete
[33] Fix | Delete
# checks if OS init system is systemd or initd
[34] Fix | Delete
IS_SYSTEMD=1
[35] Fix | Delete
ps --no-headers -o comm 1 | grep -i systemd >/dev/null 2>&1
[36] Fix | Delete
if [ $? -ne 0 ]; then
[37] Fix | Delete
IS_SYSTEMD=0
[38] Fix | Delete
fi
[39] Fix | Delete
[40] Fix | Delete
# list of services start and status
[41] Fix | Delete
# Maintain the order of the services
[42] Fix | Delete
if [ ${IS_SYSTEMD} -eq 1 ]; then
[43] Fix | Delete
arrayStart=(instsvcdrv dsm_sa_eventmgrd dsm_sa_datamgrd dsm_sa_snmpd dsm_om_connsvc)
[44] Fix | Delete
arrayStatus=(instsvcdrv dsm_sa_datamgrd dsm_sa_eventmgrd dsm_sa_snmpd dsm_om_connsvc)
[45] Fix | Delete
else
[46] Fix | Delete
arrayStart=(instsvcdrv dataeng dsm_om_connsvc)
[47] Fix | Delete
arrayStatus=(instsvcdrv dataeng dsm_om_connsvc)
[48] Fix | Delete
fi
[49] Fix | Delete
[50] Fix | Delete
# list of services to stop
[51] Fix | Delete
arrayStop=($(printf '%s\n' "${arrayStart[@]}" | tac | tr '\n' ' '))
[52] Fix | Delete
[53] Fix | Delete
[54] Fix | Delete
# include DSM SA Shared service in start/stop/status array when it is enabled
[55] Fix | Delete
checkDSMSharedService()
[56] Fix | Delete
{
[57] Fix | Delete
if [ ${IS_SYSTEMD} -eq 1 ]; then
[58] Fix | Delete
systemctl is-enabled dsm_om_shrsvc.service >/dev/null 2>&1
[59] Fix | Delete
else
[60] Fix | Delete
if [ -x /sbin/chkconfig ]; then
[61] Fix | Delete
/sbin/chkconfig dsm_om_shrsvc >/dev/null 2>&1
[62] Fix | Delete
fi
[63] Fix | Delete
fi
[64] Fix | Delete
[65] Fix | Delete
if [ $? -eq 0 ]; then
[66] Fix | Delete
arrayStart+=('dsm_om_shrsvc')
[67] Fix | Delete
arrayStop+=('dsm_om_shrsvc')
[68] Fix | Delete
arrayStatus+=('dsm_om_shrsvc')
[69] Fix | Delete
fi
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
#
[73] Fix | Delete
# start/stop/status for multiple services
[74] Fix | Delete
#
[75] Fix | Delete
serviceAction()
[76] Fix | Delete
{
[77] Fix | Delete
action=$1
[78] Fix | Delete
shift
[79] Fix | Delete
services=$@
[80] Fix | Delete
status=0
[81] Fix | Delete
for svc in $services; do
[82] Fix | Delete
if [ ${IS_SYSTEMD} -eq 1 ]; then
[83] Fix | Delete
systemctl list-unit-files $svc.service | grep $svc.service >/dev/null 2>&1
[84] Fix | Delete
#systemctl is-enabled $svc.service >/dev/null 2>&1
[85] Fix | Delete
if [ $? -eq 0 ]; then
[86] Fix | Delete
systemctl $action $svc.service
[87] Fix | Delete
fi
[88] Fix | Delete
elif [ -e /etc/init.d/$svc ] && [ -x /sbin/chkconfig ]; then
[89] Fix | Delete
/sbin/chkconfig $svc >/dev/null 2>&1
[90] Fix | Delete
if [ $? -eq 0 ]; then
[91] Fix | Delete
/etc/init.d/$svc $action
[92] Fix | Delete
fi
[93] Fix | Delete
fi
[94] Fix | Delete
[95] Fix | Delete
if [ $? -ne 0 ]; then
[96] Fix | Delete
status=1;
[97] Fix | Delete
fi
[98] Fix | Delete
done
[99] Fix | Delete
[100] Fix | Delete
# status is 1 if any service action exit code is not 0 else 0
[101] Fix | Delete
return $status
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
#
[105] Fix | Delete
# enable/disable multiple services
[106] Fix | Delete
#
[107] Fix | Delete
serviceCtl ()
[108] Fix | Delete
{
[109] Fix | Delete
ctl=$1
[110] Fix | Delete
shift
[111] Fix | Delete
services=$@
[112] Fix | Delete
status=0
[113] Fix | Delete
for svc in $services
[114] Fix | Delete
do
[115] Fix | Delete
case $ctl in
[116] Fix | Delete
enable|disable)
[117] Fix | Delete
systemctl $ctl $svc.service >/dev/null 2>&1
[118] Fix | Delete
;;
[119] Fix | Delete
on|off)
[120] Fix | Delete
/sbin/chkconfig $svc $ctl >/dev/null 2>&1
[121] Fix | Delete
;;
[122] Fix | Delete
status)
[123] Fix | Delete
if [ ${IS_SYSTEMD} -eq 1 ]; then
[124] Fix | Delete
systemctl is-enabled $svc.service >/dev/null 2>&1
[125] Fix | Delete
else
[126] Fix | Delete
/sbin/chkconfig $svc >/dev/null 2>&1
[127] Fix | Delete
fi
[128] Fix | Delete
if [ $? -eq 0 ]; then
[129] Fix | Delete
echo "$svc: enabled"
[130] Fix | Delete
else
[131] Fix | Delete
status=1
[132] Fix | Delete
echo "$svc: disabled"
[133] Fix | Delete
fi
[134] Fix | Delete
;;
[135] Fix | Delete
*)
[136] Fix | Delete
;;
[137] Fix | Delete
esac
[138] Fix | Delete
done
[139] Fix | Delete
[140] Fix | Delete
# status is 1 if any service is disabled else 0
[141] Fix | Delete
return $status
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
##
[145] Fix | Delete
## Usage
[146] Fix | Delete
##
[147] Fix | Delete
Usage()
[148] Fix | Delete
{
[149] Fix | Delete
cat << EOF
[150] Fix | Delete
Usage: srvadmin-services.sh {start|stop|status|restart|enable|disable|is-enabled|help}
[151] Fix | Delete
Options:
[152] Fix | Delete
start : starts ${SRVADMIN_STR} services
[153] Fix | Delete
stop : stops ${SRVADMIN_STR} services
[154] Fix | Delete
status : display status of ${SRVADMIN_STR} services
[155] Fix | Delete
restart : restart ${SRVADMIN_STR} services
[156] Fix | Delete
enable : enable ${SRVADMIN_STR} services in runlevels 2, 3 and 5
[157] Fix | Delete
disable : disable ${SRVADMIN_STR} services in runlevels 2, 3 and 5
[158] Fix | Delete
is-enabled : checks whether ${SRVADMIN_STR} services is enabled or not
[159] Fix | Delete
help : displays this help text
[160] Fix | Delete
EOF
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
# make sure services dont busy out any mountpoints
[164] Fix | Delete
pushd / >/dev/null 2>&1
[165] Fix | Delete
[166] Fix | Delete
# check for root privileges
[167] Fix | Delete
if [ ${UID} -ne 0 ]; then
[168] Fix | Delete
echo "This utility requires root privileges"
[169] Fix | Delete
popd >/dev/null 2>&1
[170] Fix | Delete
exit 1
[171] Fix | Delete
fi
[172] Fix | Delete
[173] Fix | Delete
# add or remove shared service from list
[174] Fix | Delete
checkDSMSharedService
[175] Fix | Delete
[176] Fix | Delete
action=$1
[177] Fix | Delete
shift
[178] Fix | Delete
[179] Fix | Delete
# Note the ${@:- ... } set up this way so that we either stop/start/etc full
[180] Fix | Delete
# set of services, or specific service if passed. ${@} is set to cmdline
[181] Fix | Delete
# params. If these are not set, then the stuff after :- is used as a default.
[182] Fix | Delete
case $action in
[183] Fix | Delete
start)
[184] Fix | Delete
IsThisSupportedGeneration
[185] Fix | Delete
retVal=$?
[186] Fix | Delete
if [ $retVal -eq 2 ]
[187] Fix | Delete
then
[188] Fix | Delete
echo "Unsupported Server... ${SRVADMIN_STR} Services not started"
[189] Fix | Delete
exit_status=1
[190] Fix | Delete
else
[191] Fix | Delete
serviceAction start ${@:-${arrayStart[*]}}
[192] Fix | Delete
fi
[193] Fix | Delete
;;
[194] Fix | Delete
stop)
[195] Fix | Delete
serviceAction stop ${@:-${arrayStop[*]}}
[196] Fix | Delete
;;
[197] Fix | Delete
status)
[198] Fix | Delete
serviceAction status ${@:-${arrayStatus[*]}}
[199] Fix | Delete
exit_status=$?
[200] Fix | Delete
;;
[201] Fix | Delete
restart)
[202] Fix | Delete
IsThisSupportedGeneration
[203] Fix | Delete
retVal=$?
[204] Fix | Delete
if [ $retVal -eq 2 ]
[205] Fix | Delete
then
[206] Fix | Delete
echo "Unsupported Server... ${SRVADMIN_STR} Services not restarted"
[207] Fix | Delete
serviceAction stop ${@:-${arrayStop[*]}}
[208] Fix | Delete
exit_status=1
[209] Fix | Delete
else
[210] Fix | Delete
serviceAction stop ${@:-${arrayStop[*]}}
[211] Fix | Delete
serviceAction start ${@:-${arrayStart[*]}}
[212] Fix | Delete
fi
[213] Fix | Delete
;;
[214] Fix | Delete
enable)
[215] Fix | Delete
arrayStatus=( "${arrayStatus[*]#dsm_om_shrsvc}" )
[216] Fix | Delete
if [ ${IS_SYSTEMD} -eq 1 ]; then
[217] Fix | Delete
serviceCtl enable ${@:-${arrayStatus[*]}}
[218] Fix | Delete
else
[219] Fix | Delete
serviceCtl on ${@:-${arrayStatus[*]}}
[220] Fix | Delete
fi
[221] Fix | Delete
;;
[222] Fix | Delete
disable)
[223] Fix | Delete
arrayStatus=( "${arrayStatus[*]#dsm_om_shrsvc}" )
[224] Fix | Delete
if [ ${IS_SYSTEMD} -eq 1 ]; then
[225] Fix | Delete
serviceCtl disable ${@:-${arrayStatus[*]}}
[226] Fix | Delete
else
[227] Fix | Delete
serviceCtl off ${@:-${arrayStatus[*]}}
[228] Fix | Delete
fi
[229] Fix | Delete
;;
[230] Fix | Delete
is-enabled)
[231] Fix | Delete
arrayStatus=( "${arrayStatus[*]#dsm_om_shrsvc}" )
[232] Fix | Delete
serviceCtl status ${@:-${arrayStatus[*]}}
[233] Fix | Delete
exit_status=$?
[234] Fix | Delete
;;
[235] Fix | Delete
help)
[236] Fix | Delete
Usage
[237] Fix | Delete
;;
[238] Fix | Delete
*)
[239] Fix | Delete
[ -z "${action}" ] || echo -e "Invalid option '${action}', please see the usage below\n"
[240] Fix | Delete
Usage
[241] Fix | Delete
exit_status=1
[242] Fix | Delete
;;
[243] Fix | Delete
esac
[244] Fix | Delete
[245] Fix | Delete
popd >/dev/null 2>&1
[246] Fix | Delete
exit $exit_status
[247] Fix | Delete
[248] Fix | Delete
[249] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function