Advertisement
Guest User

/etc/init.d/functions

a guest
Jan 5th, 2024
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.87 KB | Source Code | 0 0
  1. #!/bin/sh
  2. # -*-Shell-script-*-
  3. #
  4. # functions This file contains functions to be used by most or all
  5. # shell scripts in the /etc/init.d directory.
  6. #
  7.  
  8. TEXTDOMAIN=initscripts
  9.  
  10. # Make sure umask is sane
  11. umask 022
  12.  
  13. # Set up a default search path.
  14. PATH="/sbin:/usr/sbin:/bin:/usr/bin"
  15. export PATH
  16.  
  17. if [ $PPID -ne 1 -a -z "$SYSTEMCTL_SKIP_REDIRECT" ] && \
  18. [ -d /run/systemd/system ] ; then
  19. case "$0" in
  20. /etc/init.d/*|/etc/rc.d/init.d/*)
  21. _use_systemctl=1
  22. ;;
  23. esac
  24. fi
  25.  
  26. systemctl_redirect () {
  27. local s
  28. local prog=${1##*/}
  29. local command=$2
  30. local options=""
  31.  
  32. case "$command" in
  33. start)
  34. s=$"Starting $prog (via systemctl): "
  35. ;;
  36. stop)
  37. s=$"Stopping $prog (via systemctl): "
  38. ;;
  39. reload|try-reload)
  40. s=$"Reloading $prog configuration (via systemctl): "
  41. ;;
  42. restart|try-restart|condrestart)
  43. s=$"Restarting $prog (via systemctl): "
  44. ;;
  45. esac
  46.  
  47. if [ -n "$SYSTEMCTL_IGNORE_DEPENDENCIES" ] ; then
  48. options="--ignore-dependencies"
  49. fi
  50.  
  51. if ! systemctl show "$prog.service" > /dev/null 2>&1 || \
  52. systemctl show -p LoadState "$prog.service" | grep -q 'not-found' ; then
  53. action $"Reloading systemd: " /bin/systemctl daemon-reload
  54. fi
  55.  
  56. action "$s" /bin/systemctl $options $command "$prog.service"
  57. }
  58.  
  59. # Get a sane screen width
  60. [ -z "${COLUMNS:-}" ] && COLUMNS=80
  61.  
  62. if [ -z "${CONSOLETYPE:-}" ]; then
  63. if [ -c "/dev/stderr" ] && [ -r "/dev/stderr" ] && [ -e /sbin/consoletype ]; then
  64. CONSOLETYPE="$(/sbin/consoletype < /dev/stderr 2>/dev/null)"
  65. else
  66. CONSOLETYPE="serial"
  67. fi
  68. fi
  69.  
  70. if [ -z "${NOLOCALE:-}" ] && [ -z "${LANGSH_SOURCED:-}" ] && \
  71. [ -f /etc/sysconfig/i18n -o -f /etc/locale.conf ] ; then
  72. . /etc/profile.d/lang.sh 2>/dev/null
  73. # avoid propagating LANGSH_SOURCED any further
  74. unset LANGSH_SOURCED
  75. fi
  76.  
  77. # Read in our configuration
  78. if [ -z "${BOOTUP:-}" ]; then
  79. if [ -f /etc/sysconfig/init ]; then
  80. . /etc/sysconfig/init
  81. else
  82. # verbose ->> very (very!) old bootup look (prior to RHL-6.0?)
  83. # color ->> default bootup look
  84. # other ->> default bootup look without ANSI colors or positioning
  85. BOOTUP=color
  86. # Column to start "[ OK ]" label in:
  87. RES_COL=60
  88. # terminal sequence to move to that column:
  89. MOVE_TO_COL="echo -en \\033[${RES_COL}G"
  90. # Terminal sequence to set color to a 'success' (bright green):
  91. SETCOLOR_SUCCESS="echo -en \\033[1;32m"
  92. # Terminal sequence to set color to a 'failure' (bright red):
  93. SETCOLOR_FAILURE="echo -en \\033[1;31m"
  94. # Terminal sequence to set color to a 'warning' (bright yellow):
  95. SETCOLOR_WARNING="echo -en \\033[1;33m"
  96. # Terminal sequence to reset to the default color:
  97. SETCOLOR_NORMAL="echo -en \\033[0;39m"
  98.  
  99. # Verbosity of logging:
  100. LOGLEVEL=1
  101. fi
  102. if [ "$CONSOLETYPE" = "serial" ]; then
  103. BOOTUP=serial
  104. MOVE_TO_COL=
  105. SETCOLOR_SUCCESS=
  106. SETCOLOR_FAILURE=
  107. SETCOLOR_WARNING=
  108. SETCOLOR_NORMAL=
  109. fi
  110. fi
  111.  
  112. # Check if any of $pid (could be plural) are running
  113. checkpid() {
  114. local i
  115.  
  116. for i in $* ; do
  117. [ -d "/proc/$i" ] && return 0
  118. done
  119. return 1
  120. }
  121.  
  122. __kill_pids_term_kill_checkpids() {
  123. local base_stime=$1
  124. shift 1
  125. local pid=
  126. local pids=$*
  127. local remaining=
  128. local stat=
  129. local stime=
  130.  
  131. for pid in $pids ; do
  132. [ ! -e "/proc/$pid" ] && continue
  133. read -r line < "/proc/$pid/stat" 2> /dev/null
  134.  
  135. stat=($line)
  136. stime=${stat[21]}
  137.  
  138. [ -n "$stime" ] && [ "$base_stime" -lt "$stime" ] && continue
  139. remaining+="$pid "
  140. done
  141.  
  142. echo "$remaining"
  143. [ -n "$remaining" ] && return 1
  144.  
  145. return 0
  146. }
  147.  
  148. __kill_pids_term_kill() {
  149. local try=0
  150. local delay=3;
  151. local pid=
  152. local stat=($(< /proc/self/stat))
  153. local base_stime=${stat[21]}
  154.  
  155. if [ "$1" = "-d" ]; then
  156. delay=$2
  157. shift 2
  158. fi
  159.  
  160. local kill_list=$*
  161.  
  162. kill_list=$(__kill_pids_term_kill_checkpids $base_stime $kill_list)
  163.  
  164. [ -z "$kill_list" ] && return 0
  165.  
  166. kill -TERM $kill_list >/dev/null 2>&1
  167. sleep 0.1
  168.  
  169. kill_list=$(__kill_pids_term_kill_checkpids $base_stime $kill_list)
  170. if [ -n "$kill_list" ] ; then
  171. while [ $try -lt $delay ] ; do
  172. sleep 1
  173. kill_list=$(__kill_pids_term_kill_checkpids $base_stime $kill_list)
  174. [ -z "$kill_list" ] && break
  175. let try+=1
  176. done
  177. if [ -n "$kill_list" ] ; then
  178. kill -KILL $kill_list >/dev/null 2>&1
  179. sleep 0.1
  180. kill_list=$(__kill_pids_term_kill_checkpids $base_stime $kill_list)
  181. fi
  182. fi
  183.  
  184. [ -n "$kill_list" ] && return 1
  185. return 0
  186. }
  187.  
  188. # __proc_pids {program} [pidfile]
  189. # Set $pid to pids from /run* for {program}. $pid should be declared
  190. # local in the caller.
  191. # Returns LSB exit code for the 'status' action.
  192. __pids_var_run() {
  193. local base=${1##*/}
  194. local pid_file=${2:-/run/$base.pid}
  195. local pid_dir=$(/usr/bin/dirname $pid_file > /dev/null)
  196. local binary=$3
  197.  
  198. [ -d "$pid_dir" ] && [ ! -r "$pid_dir" ] && return 4
  199.  
  200. pid=
  201. if [ -f "$pid_file" ] ; then
  202. local line p
  203.  
  204. [ ! -r "$pid_file" ] && return 4 # "user had insufficient privilege"
  205. while : ; do
  206. read line
  207. [ -z "$line" ] && break
  208. for p in $line ; do
  209. if [ -z "${p//[0-9]/}" ] && [ -d "/proc/$p" ] ; then
  210. if [ -n "$binary" ] ; then
  211. local b=$(readlink /proc/$p/exe | sed -e 's/\s*(deleted)$//')
  212. [ "$b" != "$binary" ] && continue
  213. fi
  214. pid="$pid $p"
  215. fi
  216. done
  217. done < "$pid_file"
  218.  
  219. if [ -n "$pid" ]; then
  220. return 0
  221. fi
  222. return 1 # "Program is dead and /run pid file exists"
  223. fi
  224. return 3 # "Program is not running"
  225. }
  226.  
  227. # Output PIDs of matching processes, found using pidof
  228. __pids_pidof() {
  229. pidof -c -m -o $$ -o $PPID -o %PPID -x "$1" || \
  230. pidof -c -m -o $$ -o $PPID -o %PPID -x "${1##*/}"
  231. }
  232.  
  233.  
  234. # A function to start a program.
  235. daemon() {
  236. # Test syntax.
  237. local gotbase= force= nicelevel corelimit
  238. local pid base= user= nice= bg= pid_file=
  239. local cgroup=
  240. nicelevel=0
  241. while [ "$1" != "${1##[-+]}" ]; do
  242. case $1 in
  243. '')
  244. echo $"$0: Usage: daemon [+/-nicelevel] {program}" "[arg1]..."
  245. return 1
  246. ;;
  247. --check)
  248. base=$2
  249. gotbase="yes"
  250. shift 2
  251. ;;
  252. --check=?*)
  253. base=${1#--check=}
  254. gotbase="yes"
  255. shift
  256. ;;
  257. --user)
  258. user=$2
  259. shift 2
  260. ;;
  261. --user=?*)
  262. user=${1#--user=}
  263. shift
  264. ;;
  265. --pidfile)
  266. pid_file=$2
  267. shift 2
  268. ;;
  269. --pidfile=?*)
  270. pid_file=${1#--pidfile=}
  271. shift
  272. ;;
  273. --force)
  274. force="force"
  275. shift
  276. ;;
  277. [-+][0-9]*)
  278. nice="nice -n $1"
  279. shift
  280. ;;
  281. *)
  282. echo $"$0: Usage: daemon [+/-nicelevel] {program}" "[arg1]..."
  283. return 1
  284. ;;
  285. esac
  286. done
  287.  
  288. # Save basename.
  289. [ -z "$gotbase" ] && base=${1##*/}
  290.  
  291. # See if it's already running. Look *only* at the pid file.
  292. __pids_var_run "$base" "$pid_file"
  293.  
  294. [ -n "$pid" -a -z "$force" ] && return
  295.  
  296. # make sure it doesn't core dump anywhere unless requested
  297. corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
  298.  
  299. # if they set NICELEVEL in /etc/sysconfig/foo, honor it
  300. [ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL"
  301.  
  302. # if they set CGROUP_DAEMON in /etc/sysconfig/foo, honor it
  303. if [ -n "${CGROUP_DAEMON}" ]; then
  304. if [ ! -x /bin/cgexec ]; then
  305. echo -n "Cgroups not installed"; warning
  306. echo
  307. else
  308. cgroup="/bin/cgexec";
  309. for i in $CGROUP_DAEMON; do
  310. cgroup="$cgroup -g $i";
  311. done
  312. fi
  313. fi
  314.  
  315. # Echo daemon
  316. [ "${BOOTUP:-}" = "verbose" -a -z "${LSB:-}" ] && echo -n " $base"
  317.  
  318. # And start it up.
  319. if [ -z "$user" ]; then
  320. $cgroup $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
  321. else
  322. $cgroup $nice runuser -s /bin/bash $user -c "$corelimit >/dev/null 2>&1 ; $*"
  323. fi
  324.  
  325. [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
  326. }
  327.  
  328. # A function to stop a program.
  329. killproc() {
  330. local RC killlevel= base pid pid_file= delay try binary=
  331.  
  332. RC=0; delay=3; try=0
  333. # Test syntax.
  334. if [ "$#" -eq 0 ]; then
  335. echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
  336. return 1
  337. fi
  338. if [ "$1" = "-p" ]; then
  339. pid_file=$2
  340. shift 2
  341. fi
  342. if [ "$1" = "-b" ]; then
  343. if [ -z $pid_file ]; then
  344. echo $"-b option can be used only with -p"
  345. echo $"Usage: killproc -p pidfile -b binary program"
  346. return 1
  347. fi
  348. binary=$2
  349. shift 2
  350. fi
  351. if [ "$1" = "-d" ]; then
  352. delay=$(echo $2 | awk -v RS=' ' -v IGNORECASE=1 '{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} END {printf("%d",delay+0.5)}')
  353. if [ "$?" -eq 1 ]; then
  354. echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
  355. return 1
  356. fi
  357. shift 2
  358. fi
  359.  
  360.  
  361. # check for second arg to be kill level
  362. [ -n "${2:-}" ] && killlevel=$2
  363.  
  364. # Save basename.
  365. base=${1##*/}
  366.  
  367. # Find pid.
  368. __pids_var_run "$1" "$pid_file" "$binary"
  369. RC=$?
  370. if [ -z "$pid" ]; then
  371. if [ -z "$pid_file" ]; then
  372. pid="$(__pids_pidof "$1")"
  373. else
  374. [ "$RC" = "4" ] && { failure $"$base shutdown" ; return $RC ;}
  375. fi
  376. fi
  377.  
  378. # Kill it.
  379. if [ -n "$pid" ] ; then
  380. [ "$BOOTUP" = "verbose" -a -z "${LSB:-}" ] && echo -n "$base "
  381. if [ -z "$killlevel" ] ; then
  382. __kill_pids_term_kill -d $delay $pid
  383. RC=$?
  384. [ "$RC" -eq 0 ] && success $"$base shutdown" || failure $"$base shutdown"
  385. # use specified level only
  386. else
  387. if checkpid $pid; then
  388. kill $killlevel $pid >/dev/null 2>&1
  389. RC=$?
  390. [ "$RC" -eq 0 ] && success $"$base $killlevel" || failure $"$base $killlevel"
  391. elif [ -n "${LSB:-}" ]; then
  392. RC=7 # Program is not running
  393. fi
  394. fi
  395. else
  396. if [ -n "${LSB:-}" -a -n "$killlevel" ]; then
  397. RC=7 # Program is not running
  398. else
  399. failure $"$base shutdown"
  400. RC=0
  401. fi
  402. fi
  403.  
  404. # Remove pid file if any.
  405. if [ -z "$killlevel" ]; then
  406. rm -f "${pid_file:-/run/$base.pid}"
  407. fi
  408. return $RC
  409. }
  410.  
  411. # A function to find the pid of a program. Looks *only* at the pidfile
  412. pidfileofproc() {
  413. local pid
  414.  
  415. # Test syntax.
  416. if [ "$#" = 0 ] ; then
  417. echo $"Usage: pidfileofproc {program}"
  418. return 1
  419. fi
  420.  
  421. __pids_var_run "$1"
  422. [ -n "$pid" ] && echo $pid
  423. return 0
  424. }
  425.  
  426. # A function to find the pid of a program.
  427. pidofproc() {
  428. local RC pid pid_file=
  429.  
  430. # Test syntax.
  431. if [ "$#" = 0 ]; then
  432. echo $"Usage: pidofproc [-p pidfile] {program}"
  433. return 1
  434. fi
  435. if [ "$1" = "-p" ]; then
  436. pid_file=$2
  437. shift 2
  438. fi
  439. fail_code=3 # "Program is not running"
  440.  
  441. # First try "/run/*.pid" files
  442. __pids_var_run "$1" "$pid_file"
  443. RC=$?
  444. if [ -n "$pid" ]; then
  445. echo $pid
  446. return 0
  447. fi
  448.  
  449. [ -n "$pid_file" ] && return $RC
  450. __pids_pidof "$1" || return $RC
  451. }
  452.  
  453. status() {
  454. local base pid lock_file= pid_file= binary=
  455.  
  456. # Test syntax.
  457. if [ "$#" = 0 ] ; then
  458. echo $"Usage: status [-p pidfile] {program}"
  459. return 1
  460. fi
  461. if [ "$1" = "-p" ]; then
  462. pid_file=$2
  463. shift 2
  464. fi
  465. if [ "$1" = "-l" ]; then
  466. lock_file=$2
  467. shift 2
  468. fi
  469. if [ "$1" = "-b" ]; then
  470. if [ -z $pid_file ]; then
  471. echo $"-b option can be used only with -p"
  472. echo $"Usage: status -p pidfile -b binary program"
  473. return 1
  474. fi
  475. binary=$2
  476. shift 2
  477. fi
  478. base=${1##*/}
  479.  
  480. if [ "$_use_systemctl" = "1" ]; then
  481. systemctl status ${0##*/}.service
  482. ret=$?
  483. # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
  484. # lets adjust the reality a little bit
  485. if systemctl show -p ActiveState ${0##*/}.service | grep -q '=active$' && \
  486. systemctl show -p SubState ${0##*/}.service | grep -q '=exited$' ; then
  487. ret=3
  488. fi
  489. return $ret
  490. fi
  491.  
  492. # First try "pidof"
  493. __pids_var_run "$1" "$pid_file" "$binary"
  494. RC=$?
  495. if [ -z "$pid_file" -a -z "$pid" ]; then
  496. pid="$(__pids_pidof "$1")"
  497. fi
  498. if [ -n "$pid" ]; then
  499. echo $"${base} (pid $pid) is running..."
  500. return 0
  501. fi
  502.  
  503. case "$RC" in
  504. 0)
  505. echo $"${base} (pid $pid) is running..."
  506. return 0
  507. ;;
  508. 1)
  509. echo $"${base} dead but pid file exists"
  510. return 1
  511. ;;
  512. 4)
  513. echo $"${base} status unknown due to insufficient privileges."
  514. return 4
  515. ;;
  516. esac
  517. if [ -z "${lock_file}" ]; then
  518. lock_file=${base}
  519. fi
  520. # See if /var/lock/subsys/${lock_file} exists
  521. if [ -f /var/lock/subsys/${lock_file} ]; then
  522. echo $"${base} dead but subsys locked"
  523. return 2
  524. fi
  525. echo $"${base} is stopped"
  526. return 3
  527. }
  528.  
  529. echo_success() {
  530. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  531. echo -n "["
  532. [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
  533. echo -n $" OK "
  534. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  535. echo -n "]"
  536. echo -ne "\r"
  537. return 0
  538. }
  539.  
  540. echo_failure() {
  541. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  542. echo -n "["
  543. [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  544. echo -n $"FAILED"
  545. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  546. echo -n "]"
  547. echo -ne "\r"
  548. return 1
  549. }
  550.  
  551. echo_passed() {
  552. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  553. echo -n "["
  554. [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
  555. echo -n $"PASSED"
  556. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  557. echo -n "]"
  558. echo -ne "\r"
  559. return 1
  560. }
  561.  
  562. echo_warning() {
  563. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  564. echo -n "["
  565. [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
  566. echo -n $"WARNING"
  567. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  568. echo -n "]"
  569. echo -ne "\r"
  570. return 1
  571. }
  572.  
  573. # Inform the graphical boot of our current state
  574. update_boot_stage() {
  575. if [ -x /bin/plymouth ]; then
  576. /bin/plymouth --update="$1"
  577. fi
  578. return 0
  579. }
  580.  
  581. # Log that something succeeded
  582. success() {
  583. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success
  584. return 0
  585. }
  586.  
  587. # Log that something failed
  588. failure() {
  589. local rc=$?
  590. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure
  591. [ -x /bin/plymouth ] && /bin/plymouth --details
  592. return $rc
  593. }
  594.  
  595. # Log that something passed, but may have had errors. Useful for fsck
  596. passed() {
  597. local rc=$?
  598. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_passed
  599. return $rc
  600. }
  601.  
  602. # Log a warning
  603. warning() {
  604. local rc=$?
  605. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_warning
  606. return $rc
  607. }
  608.  
  609. # Run some action. Log its output.
  610. action() {
  611. local STRING rc
  612.  
  613. STRING=$1
  614. echo -n "$STRING "
  615. shift
  616. "$@" && success $"$STRING" || failure $"$STRING"
  617. rc=$?
  618. echo
  619. return $rc
  620. }
  621.  
  622. # returns OK if $1 contains $2
  623. strstr() {
  624. [ "${1#*$2*}" = "$1" ] && return 1
  625. return 0
  626. }
  627.  
  628. # Check whether file $1 is a backup or rpm-generated file and should be ignored
  629. is_ignored_file() {
  630. case "$1" in
  631. *~ | *.bak | *.old | *.orig | *.rpmnew | *.rpmorig | *.rpmsave)
  632. return 0
  633. ;;
  634. esac
  635. return 1
  636. }
  637.  
  638. # Convert the value ${1} of time unit ${2}-seconds into seconds:
  639. convert2sec() {
  640. local retval=""
  641.  
  642. case "${2}" in
  643. deci) retval=$(awk "BEGIN {printf \"%.1f\", ${1} / 10}") ;;
  644. centi) retval=$(awk "BEGIN {printf \"%.2f\", ${1} / 100}") ;;
  645. mili) retval=$(awk "BEGIN {printf \"%.3f\", ${1} / 1000}") ;;
  646. micro) retval=$(awk "BEGIN {printf \"%.6f\", ${1} / 1000000}") ;;
  647. nano) retval=$(awk "BEGIN {printf \"%.9f\", ${1} / 1000000000}") ;;
  648. piko) retval=$(awk "BEGIN {printf \"%.12f\", ${1} / 1000000000000}") ;;
  649. esac
  650.  
  651. echo "${retval}"
  652. }
  653.  
  654. # Evaluate shvar-style booleans
  655. is_true() {
  656. case "$1" in
  657. [tT] | [yY] | [yY][eE][sS] | [oO][nN] | [tT][rR][uU][eE] | 1)
  658. return 0
  659. ;;
  660. esac
  661. return 1
  662. }
  663.  
  664. # Evaluate shvar-style booleans
  665. is_false() {
  666. case "$1" in
  667. [fF] | [nN] | [nN][oO] | [oO][fF][fF] | [fF][aA][lL][sS][eE] | 0)
  668. return 0
  669. ;;
  670. esac
  671. return 1
  672. }
  673.  
  674. # Apply sysctl settings, including files in /etc/sysctl.d
  675. apply_sysctl() {
  676. if [ -x /lib/systemd/systemd-sysctl ]; then
  677. /lib/systemd/systemd-sysctl
  678. else
  679. for file in /usr/lib/sysctl.d/*.conf ; do
  680. is_ignored_file "$file" && continue
  681. [ -f /run/sysctl.d/${file##*/} ] && continue
  682. [ -f /etc/sysctl.d/${file##*/} ] && continue
  683. test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
  684. done
  685. for file in /run/sysctl.d/*.conf ; do
  686. is_ignored_file "$file" && continue
  687. [ -f /etc/sysctl.d/${file##*/} ] && continue
  688. test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
  689. done
  690. for file in /etc/sysctl.d/*.conf ; do
  691. is_ignored_file "$file" && continue
  692. test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
  693. done
  694. sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
  695. fi
  696. }
  697.  
  698. # A sed expression to filter out the files that is_ignored_file recognizes
  699. __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
  700.  
  701. if [ "$_use_systemctl" = "1" ]; then
  702. if [ "x$1" = xstart -o \
  703. "x$1" = xstop -o \
  704. "x$1" = xrestart -o \
  705. "x$1" = xreload -o \
  706. "x$1" = xtry-restart -o \
  707. "x$1" = xforce-reload -o \
  708. "x$1" = xcondrestart ] ; then
  709.  
  710. systemctl_redirect $0 $1
  711. exit $?
  712. fi
  713. fi
  714.  
  715. strstr "$(cat /proc/cmdline)" "rc.debug" && set -x || true
  716. return 0
  717.  
  718.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement