Пост #261767 |
сохранен 13.04.2022 10:36
- Редактировать пост
- Печать
- Скачать
- Посты-ответы на этот пост: # 274369
- Посмотреть дерево постов
-
Сравнить с постом
#
Текст поста
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 | #!/bin/sh # # Dr.Web drweb-configd init script # # $Id: 7e07d2ad0adf8734d610911ac40c4c0ca81839ef $ # # chkconfig: 235 20 80 # description: drweb-configd is a Dr.Web Configuration Daemon # processname: drweb-configd # config: /etc/opt/drweb.com/drweb.ini # pidfile: /var/run/drweb-configd.pid ### BEGIN INIT INFO # Provides: drweb-configd # Required-Start: $local_fs $network # Required-Stop: $null # Should-Start: dkms_autoinstaller # Should-Stop: $null # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: drweb-configd is a Dr.Web Configuration Daemon ### END INIT INFO DAEMON=/opt/drweb.com/bin/drweb-configd PIDFILE=/var/run/drweb-configd.pid TIMEOUT=300 PATH=/usr/xpg4/bin:/bin:/usr/bin:/usr/ucb:/sbin:/usr/sbin:${PATH} EXIT_SUCCESS=0 EXIT_FAILURE_NOFILE=1 EXIT_FAILURE_RUNNING=2 EXIT_FAILURE_NOT_RUNNING=3 EXIT_FAILURE_TIMEOUT=4 EXIT_FAILURE_NOARGS=5 EXIT_FAILURE_NOT_ROOT=6 STATUS_NOPID=1 STATUS_ALIVE=0 STATUS_NOT_ALIVE=2 STATUS_WRONG_PID=3 if test -n "$1" -a ! "$1" = "status" ; then case "`id`" in uid=0*) ;; *) echo "$0 $1 must be executed with root privileges" exit $EXIT_FAILURE_NOT_ROOT ;; esac fi ulimit -n 16384 get_pid() { head -1 "$PIDFILE" 2>/dev/null } check_pid() { if test -r "$PIDFILE" ; then pid=`get_pid` if test -n "$pid" ; then if kill -0 "$pid" 2>/dev/null || ps -p "$pid" >/dev/null 2>&1 ; then return $STATUS_ALIVE else return $STATUS_NOT_ALIVE fi else return $STATUS_WRONG_PID fi else return $STATUS_NOPID fi } start_daemon() { if test $USE_SYSTEMCTL -eq 1; then exec /bin/systemctl --job-mode=ignore-dependencies start drweb-configd.service fi die_if_running if test ! -x "$DAEMON" ; then echo "Dr.Web drweb-configd is not installed" exit $EXIT_FAILURE_NOFILE fi add_execaps=0 if type execaps >/dev/null 2>&1 && cat /etc/astra_version | grep '^SE 1.5' >/dev/null 2>&1; then add_execaps=1 fi if test $add_execaps -eq 1; then execaps -c 0x100 -- "$DAEMON" -d -p "$PIDFILE" >/dev/null 2>&1 else "$DAEMON" -d -p "$PIDFILE" >/dev/null 2>&1 fi retval=$? if test $retval -ne 0; then die_if_cant_start fi return $retval } stop_daemon() { if test $USE_SYSTEMCTL -eq 1; then exec /bin/systemctl --job-mode=ignore-dependencies stop drweb-configd.service fi check_if_not_running pid=`get_pid` if test -n "$pid" ; then kill "$pid" fi seconds=0 retval=0 while check_pid ; do sleep 1 printf "." seconds=`expr $seconds + 1` if test "$seconds" -gt "$TIMEOUT" ; then retval=1 break fi done test "$seconds" -gt "0" && echo test $retval -eq 0 && rm -f "$PIDFILE" || die_if_timeout return $retval } reload_daemon() { if test $USE_SYSTEMCTL -eq 1; then exec /bin/systemctl --job-mode=ignore-dependencies reload drweb-configd.service fi check_if_not_running pid=`get_pid` if test -n "$pid" ; then kill -HUP "$pid" fi } restart_daemon() { if test $USE_SYSTEMCTL -eq 1; then exec /bin/systemctl --job-mode=ignore-dependencies restart drweb-configd.service fi if check_pid ; then stop_daemon || die_if_timeout fi start_daemon || die_if_cant_start } condrestart_daemon() { if test $USE_SYSTEMCTL -eq 1; then exec /bin/systemctl --job-mode=ignore-dependencies try-restart drweb-configd.service fi check_if_not_running stop_daemon || die_if_timeout start_daemon || die_if_cant_start } daemon_status() { if test $USE_SYSTEMCTL -eq 1; then exec /bin/systemctl status drweb-configd.service fi check_pid case "$?" in $STATUS_ALIVE) echo "Dr.Web drweb-configd is running" ;; $STATUS_NOPID) echo "Dr.Web drweb-configd is not running" ;; $STATUS_NOT_ALIVE|$STATUS_WRONG_PID) echo "Dr.Web drweb-configd is not running but $PIDFILE exists" ;; esac } die() { echo "$2" && exit $1 } die_if_running() { check_pid && die $EXIT_FAILURE_RUNNING "Dr.Web drweb-configd is already running" } check_if_not_running() { check_pid case "$?" in $STATUS_NOPID) echo "Dr.Web drweb-configd is not running" exit $EXIT_SUCCESS ;; $STATUS_NOT_ALIVE|$STATUS_WRONG_PID) die $EXIT_FAILURE_NOT_RUNNING \ "Dr.Web drweb-configd is not running but $PIDFILE exists" ;; esac } die_if_timeout() { die $EXIT_FAILURE_RUNNING "Dr.Web drweb-configd seems is still running" } die_if_cant_start() { die $EXIT_FAILURE_NOT_RUNNING "Failed to start Dr.Web drweb-configd" } USE_SYSTEMCTL=0 if test -x /bin/systemctl && cat /proc/1/comm 2>/dev/null | grep systemd 1>/dev/null 2>&1; then state=$(/bin/systemctl -p LoadState show drweb-configd.service 2>/dev/null) if test "$state" = "LoadState=not-found"; then USE_SYSTEMCTL=0 elif test "$state" = "LoadState=masked"; then die $EXIT_SUCCESS "Dr.Web drweb-configd is masked" else if test $PPID -ne 1 -a -z "${init:-}" -a -z "${SYSTEMCTL_REDIRECT:-}"; then USE_SYSTEMCTL=1 else export SYSTEMCTL_REDIRECT=1 fi fi fi case "$1" in stop) echo "Shutting down Dr.Web drweb-configd..." stop_daemon ;; reload) echo "Reloading Dr.Web drweb-configd..." reload_daemon ;; restart) echo "Restarting Dr.Web drweb-configd..." restart_daemon ;; condrestart) echo "Restarting Dr.Web drweb-configd..." condrestart_daemon ;; start) echo "Starting Dr.Web drweb-configd..." start_daemon ;; status) daemon_status ;; *) echo "Usage: $0 {start|stop|restart|condrestart|reload|status}" exit $EXIT_FAILURE_NOARGS ;; esac exit $EXIT_SUCCESS |