start-stop-functions 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. #!/bin/bash
  2. # The original version of this file was taken from the CentOS5
  3. # initscripts-8.45.30-2.el5.x86_64 package and as this package is licensensed
  4. # under GPLv2 and GPLv2+ this entire file is provided under those licenses.
  5. # As the CentOS / RedHat version has severe bugs (see for example
  6. # https://bugzilla.redhat.com/show_bug.cgi?id=703426
  7. # we (the BeeGFS team) cannot rely on it and modified the original
  8. # version therefore
  9. #
  10. # 2011/05/10 Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
  11. # -*-Shell-script-*-
  12. #
  13. # functions This file contains functions to be used by most or all
  14. # shell scripts in the /etc/init.d directory.
  15. #
  16. TEXTDOMAIN=initscripts
  17. # Make sure umask is sane
  18. umask 022
  19. # Set up a default search path.
  20. PATH="/sbin:/usr/sbin:/bin:/usr/bin"
  21. export PATH
  22. # Get a sane screen width
  23. [ -z "${COLUMNS:-}" ] && COLUMNS=80
  24. if [ -z "${CONSOLETYPE:-}" -a -x "/sbin/consoletype" ]; then
  25. CONSOLETYPE="`/sbin/consoletype`"
  26. fi
  27. if [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" ] ; then
  28. . /etc/profile.d/lang.sh
  29. fi
  30. # Read in our configuration
  31. if [ -z "${BOOTUP:-}" ]; then
  32. if [ -f /etc/sysconfig/init ]; then
  33. . /etc/sysconfig/init
  34. else
  35. # This all seem confusing? Look in /etc/sysconfig/init,
  36. # or in /usr/doc/initscripts-*/sysconfig.txt
  37. BOOTUP=color
  38. RES_COL=60
  39. MOVE_TO_COL="echo -en \\033[${RES_COL}G"
  40. SETCOLOR_SUCCESS="echo -en \\033[1;32m"
  41. SETCOLOR_FAILURE="echo -en \\033[1;31m"
  42. SETCOLOR_WARNING="echo -en \\033[1;33m"
  43. SETCOLOR_NORMAL="echo -en \\033[0;39m"
  44. LOGLEVEL=1
  45. fi
  46. if [ "$CONSOLETYPE" = "serial" ]; then
  47. BOOTUP=serial
  48. MOVE_TO_COL=
  49. SETCOLOR_SUCCESS=
  50. SETCOLOR_FAILURE=
  51. SETCOLOR_WARNING=
  52. SETCOLOR_NORMAL=
  53. fi
  54. fi
  55. if [ "${BOOTUP:-}" != "verbose" ]; then
  56. INITLOG_ARGS="-q"
  57. else
  58. INITLOG_ARGS=
  59. fi
  60. # Interpret escape sequences in an fstab entry
  61. fstab_decode_str() {
  62. fstab-decode echo "$1"
  63. }
  64. # Check if $pid (could be plural) are running
  65. checkpid() {
  66. local base=$1
  67. shift
  68. local i
  69. local RUNNING_PIDS=`pidof $base`
  70. # pidof told us the daemon is not running, so we do not need to
  71. # do further check
  72. [ -n "$RUNNING_PIDS" ] || return 1
  73. for pid in $* ; do
  74. [ -d "/proc/$pid" ] || continue
  75. for rp in $RUNNING_PIDS; do
  76. # check if `pidof` and provided pid to checkpid() match
  77. # if so we found a running pid with the correct name
  78. [ $rp -eq $pid ] && return 0
  79. done
  80. done
  81. return 1
  82. }
  83. __readlink() {
  84. ls -bl "$@" 2>/dev/null| awk '{ print $NF }'
  85. }
  86. # __umount_loop awk_program fstab_file first_msg retry_msg umount_args
  87. # awk_program should process fstab_file and return a list of fstab-encoded
  88. # paths; it doesn't have to handle comments in fstab_file.
  89. __umount_loop() {
  90. local remaining sig=
  91. local retry=3
  92. remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
  93. while [ -n "$remaining" -a "$retry" -gt 0 ]; do
  94. if [ "$retry" -eq 3 ]; then
  95. action "$3" fstab-decode umount $5 $remaining
  96. else
  97. action "$4" fstab-decode umount $5 $remaining
  98. fi
  99. sleep 2
  100. remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
  101. [ -z "$remaining" ] && break
  102. fstab-decode /sbin/fuser -k -m $sig $remaining >/dev/null
  103. sleep 5
  104. retry=$(($retry -1))
  105. sig=-9
  106. done
  107. }
  108. # Similar to __umount loop above, specialized for loopback devices
  109. __umount_loopback_loop() {
  110. local remaining devremaining sig=
  111. local retry=3
  112. remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts)
  113. devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts)
  114. while [ -n "$remaining" -a "$retry" -gt 0 ]; do
  115. if [ "$retry" -eq 3 ]; then
  116. action $"Unmounting loopback filesystems: " \
  117. fstab-decode umount $remaining
  118. else
  119. action $"Unmounting loopback filesystems (retry):" \
  120. fstab-decode umount $remaining
  121. fi
  122. for dev in $devremaining ; do
  123. losetup $dev > /dev/null 2>&1 && \
  124. action $"Detaching loopback device $dev: " \
  125. losetup -d $dev
  126. done
  127. remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts)
  128. devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts)
  129. [ -z "$remaining" ] && break
  130. fstab-decode /sbin/fuser -k -m $sig $remaining >/dev/null
  131. sleep 5
  132. retry=$(($retry -1))
  133. sig=-9
  134. done
  135. }
  136. # __proc_pids {program} [pidfile]
  137. # Set $pid to pids from /var/run* for {program}. $pid should be declared
  138. # local in the caller.
  139. # Returns LSB exit code for the 'status' action.
  140. __pids_var_run_running() {
  141. local base=${1##*/}
  142. local pid_file=${2:-/var/run/$base.pid}
  143. # checkpid already sets $pid globally, so we can't re-use it for now
  144. local pids=
  145. if [ -f "$pid_file" ]; then
  146. local line=`cat $pid_file | tr '\n' ' '`
  147. for entry in $line; do
  148. checkpid $base $entry
  149. [ $? -eq 0 ] || continue
  150. # found a matching pid
  151. pids="$pids $entry"
  152. done < "$pid_file"
  153. if [ -n "$pids" ]; then
  154. pid=$pids # globally we need $pid
  155. return 0
  156. fi
  157. return 1 # "Program is dead and /var/run pid file exists"
  158. fi
  159. return 3 # "Program is not running"
  160. }
  161. # Output PIDs of matching processes, found using pidof
  162. __pids_pidof() {
  163. pidof -c -o $$ -o $PPID -o %PPID -x "$1" || \
  164. pidof -c -o $$ -o $PPID -o %PPID -x "${1##*/}"
  165. }
  166. # A function to start a program.
  167. daemon() {
  168. # Test syntax.
  169. local gotbase= force= nicelevel corelimit
  170. local pid base= user= nice= bg= pid_file=
  171. nicelevel=0
  172. while [ "$1" != "${1##[-+]}" ]; do
  173. case $1 in
  174. '') echo $"$0: Usage: daemon [+/-nicelevel] {program}"
  175. return 1;;
  176. --check)
  177. base=$2
  178. gotbase="yes"
  179. shift 2
  180. ;;
  181. --check=?*)
  182. base=${1#--check=}
  183. gotbase="yes"
  184. shift
  185. ;;
  186. --user)
  187. user=$2
  188. shift 2
  189. ;;
  190. --user=?*)
  191. user=${1#--user=}
  192. shift
  193. ;;
  194. --pidfile)
  195. pid_file=$2
  196. shift 2
  197. ;;
  198. --pidfile=?*)
  199. pid_file=${1#--pidfile=}
  200. shift
  201. ;;
  202. --force)
  203. force="force"
  204. shift
  205. ;;
  206. [-+][0-9]*)
  207. nice="nice -n $1"
  208. shift
  209. ;;
  210. *) echo $"$0: Usage: daemon [+/-nicelevel] {program}"
  211. return 1;;
  212. esac
  213. done
  214. # Save basename.
  215. [ -z "$gotbase" ] && base=${1##*/}
  216. # See if it's already running. Look *only* at the pid file.
  217. __pids_var_run_running "$base" "$pid_file"
  218. [ -n "$pid" -a -z "$force" ] && return
  219. # make sure it doesn't core dump anywhere unless requested
  220. corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
  221. # if they set NICELEVEL in /etc/sysconfig/foo, honor it
  222. [ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL"
  223. # Echo daemon
  224. [ "${BOOTUP:-}" = "verbose" -a -z "${LSB:-}" ] && echo -n " $base"
  225. # And start it up.
  226. if [ -z "$user" ]; then
  227. $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
  228. else
  229. $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
  230. fi
  231. [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
  232. }
  233. # reall kill here, return 0 if kill succeeded, 1 if not
  234. do_killproc()
  235. {
  236. level=$1
  237. time=$2
  238. kill -${level} $pid >/dev/null 2>&1
  239. RC=0
  240. count_time=0
  241. while [ $RC -eq 0 -a $count_time -lt $time ]; do
  242. checkpid $base $pid
  243. if [ $? -ne 0 ]; then
  244. return 0
  245. fi
  246. sleep 1
  247. count=$(($count_time + 1))
  248. done
  249. return 1
  250. }
  251. remove_pidfile()
  252. {
  253. # Remove pid file if any.
  254. if [ -z "$killlevel" ]; then
  255. rm -f "${pid_file:-/var/run/$base.pid}"
  256. fi
  257. }
  258. # A function to stop a program.
  259. killproc() {
  260. local RC killlevel= base pid pid_file= delay
  261. local pidfile_only=0
  262. RC=0; delay=3
  263. # Test syntax.
  264. if [ "$#" -eq 0 ]; then
  265. echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
  266. return 1
  267. fi
  268. if [ "$1" = "-p" ]; then
  269. pid_file=$2
  270. shift 2
  271. fi
  272. if [ "$1" = "-d" ]; then
  273. delay=$2
  274. shift 2
  275. fi
  276. # check for second arg to be kill level
  277. [ -n "${2:-}" ] && killlevel=$2
  278. # Save basename.
  279. base=${1##*/}
  280. # Find pid.
  281. __pids_var_run_running "$1" "$pid_file"
  282. if [ -z "$pid" ]; then
  283. pid="$(__pids_pidof "$1")"
  284. fi
  285. if [ -z "$pid" ]; then
  286. if [ -n "${LSB:-}" -a -n "$killlevel" ]; then
  287. RC=7 # Program is not running
  288. else
  289. failure $"$base shutdown"
  290. RC=0
  291. fi
  292. remove_pidfile
  293. return $RC
  294. fi
  295. # Kill it.
  296. [ "$BOOTUP" = "verbose" -a -z "${LSB:-}" ] && echo -n "$base "
  297. if [ -z "$killlevel" ] ; then
  298. # TERM first, then KILL if not dead
  299. # use specified level only
  300. do_killproc KILL 30
  301. [ $? -ne 0 ] || do_killproc KILL 5
  302. else
  303. do_killproc $killlevel 30 >/dev/null 2>&1
  304. fi
  305. # determine the exit code here after kill (depends on if kill succeeded)
  306. checkpid $base $pid
  307. RC=$?
  308. [ "$RC" -eq 0 ] && failure $"$base shutdown" || success $"$base shutdown"
  309. RC=$((! $RC))
  310. remove_pidfile
  311. return $RC
  312. }
  313. # A function to find the pid of a program. Looks *only* at the pidfile
  314. pidfileofproc() {
  315. local pid
  316. # Test syntax.
  317. if [ "$#" = 0 ] ; then
  318. echo $"Usage: pidfileofproc {program}"
  319. return 1
  320. fi
  321. __pids_var_run_running "$1"
  322. [ -n "$pid" ] && echo $pid
  323. return 0
  324. }
  325. # A function to find the pid of a program.
  326. pidofproc() {
  327. local RC pid pid_file=
  328. # Test syntax.
  329. if [ "$#" = 0 ]; then
  330. echo $"Usage: pidofproc [-p pidfile] {program}"
  331. return 1
  332. fi
  333. if [ "$1" = "-p" ]; then
  334. pid_file=$2
  335. shift 2
  336. fi
  337. fail_code=3 # "Program is not running"
  338. # First try "/var/run/*.pid" files
  339. __pids_var_run_running "$1" "$pid_file"
  340. RC=$?
  341. if [ -n "$pid" ]; then
  342. echo $pid
  343. return 0
  344. fi
  345. [ -n "$pid_file" ] && return $RC
  346. __pids_pidof "$1" || return $RC
  347. }
  348. status() {
  349. local base pid pid_file=
  350. # Test syntax.
  351. if [ "$#" = 0 ] ; then
  352. echo $"Usage: status [-p pidfile] {program}"
  353. return 1
  354. fi
  355. if [ "$1" = "-p" ]; then
  356. pid_file=$2
  357. shift 2
  358. fi
  359. base=${1##*/}
  360. # First try "pidof"
  361. __pids_var_run_running "$1" "$pid_file"
  362. RC=$?
  363. if [ -z "$pid_file" -a -z "$pid" ]; then
  364. pid="$(__pids_pidof "$1")"
  365. fi
  366. if [ -n "$pid" ]; then
  367. echo $"${base} (pid $pid) is running..."
  368. return 0
  369. fi
  370. case "$RC" in
  371. 0)
  372. echo $"${base} (pid $pid) is running..."
  373. return 0
  374. ;;
  375. 1)
  376. echo $"${base} dead but pid file exists"
  377. return 1
  378. ;;
  379. esac
  380. # See if /var/lock/subsys/${base} exists
  381. if [ -f /var/lock/subsys/${base} ]; then
  382. echo $"${base} dead but subsys locked"
  383. return 2
  384. fi
  385. echo $"${base} is stopped"
  386. return 3
  387. }
  388. status_multi() {
  389. local base pid pid_file=
  390. # Test syntax.
  391. if [ "$#" = 0 ] ; then
  392. echo $"Usage: status [-p pidfile] {program}"
  393. return 1
  394. fi
  395. if [ "$1" = "-p" ]; then
  396. pid_file=$2
  397. shift 2
  398. fi
  399. base=${1##*/}
  400. # First try "pidof"
  401. __pids_var_run_running "$1" "$pid_file"
  402. RC=$?
  403. if [ -z "$pid_file" -a -z "$pid" ]; then
  404. pid="$(__pids_pidof "$1")"
  405. fi
  406. if [ -n "$pid" ]; then
  407. echo $"${base} (pid $pid) is running..."
  408. return 0
  409. fi
  410. case "$RC" in
  411. 0)
  412. echo $"${base} (pid $pid) is running..."
  413. return 0
  414. ;;
  415. 1)
  416. echo $"${base} dead but pid file exists"
  417. return 1
  418. ;;
  419. esac
  420. # See if /var/lock/subsys/${base}-$CONFIG exists
  421. if [ -f /var/lock/subsys/${base}-$CONFIG ]; then
  422. echo $"${base} dead but subsys locked"
  423. return 2
  424. fi
  425. echo $"${base} is stopped"
  426. return 3
  427. }
  428. echo_success() {
  429. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  430. echo -n "["
  431. [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
  432. echo -n $" OK "
  433. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  434. echo -n "]"
  435. echo -ne "\r"
  436. return 0
  437. }
  438. echo_failure() {
  439. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  440. echo -n "["
  441. [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  442. echo -n $"FAILED"
  443. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  444. echo -n "]"
  445. echo -ne "\r"
  446. return 1
  447. }
  448. echo_passed() {
  449. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  450. echo -n "["
  451. [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
  452. echo -n $"PASSED"
  453. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  454. echo -n "]"
  455. echo -ne "\r"
  456. return 1
  457. }
  458. echo_warning() {
  459. [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  460. echo -n "["
  461. [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
  462. echo -n $"WARNING"
  463. [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  464. echo -n "]"
  465. echo -ne "\r"
  466. return 1
  467. }
  468. # Inform the graphical boot of our current state
  469. update_boot_stage() {
  470. if [ "$GRAPHICAL" = "yes" -a -x /usr/bin/rhgb-client ]; then
  471. /usr/bin/rhgb-client --update="$1"
  472. fi
  473. return 0
  474. }
  475. # Log that something succeeded
  476. success() {
  477. #if [ -z "${IN_INITLOG:-}" ]; then
  478. # initlog $INITLOG_ARGS -n $0 -s "$1" -e 1
  479. #fi
  480. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success
  481. return 0
  482. }
  483. # Log that something failed
  484. failure() {
  485. local rc=$?
  486. #if [ -z "${IN_INITLOG:-}" ]; then
  487. # initlog $INITLOG_ARGS -n $0 -s "$1" -e 2
  488. #fi
  489. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure
  490. [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --details=yes
  491. return $rc
  492. }
  493. # Log that something passed, but may have had errors. Useful for fsck
  494. passed() {
  495. local rc=$?
  496. #if [ -z "${IN_INITLOG:-}" ]; then
  497. # initlog $INITLOG_ARGS -n $0 -s "$1" -e 1
  498. #fi
  499. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_passed
  500. return $rc
  501. }
  502. # Log a warning
  503. warning() {
  504. local rc=$?
  505. #if [ -z "${IN_INITLOG:-}" ]; then
  506. # initlog $INITLOG_ARGS -n $0 -s "$1" -e 1
  507. #fi
  508. [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_warning
  509. return $rc
  510. }
  511. # Run some action. Log its output.
  512. action() {
  513. local STRING rc
  514. STRING=$1
  515. echo -n "$STRING "
  516. if [ "${RHGB_STARTED:-}" != "" -a -w /etc/rhgb/temp/rhgb-console ]; then
  517. echo -n "$STRING " > /etc/rhgb/temp/rhgb-console
  518. fi
  519. shift
  520. "$@" && success $"$STRING" || failure $"$STRING"
  521. rc=$?
  522. echo
  523. if [ "${RHGB_STARTED:-}" != "" -a -w /etc/rhgb/temp/rhgb-console ]; then
  524. if [ "$rc" = "0" ]; then
  525. echo_success > /etc/rhgb/temp/rhgb-console
  526. else
  527. echo_failure > /etc/rhgb/temp/rhgb-console
  528. [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --details=yes
  529. fi
  530. echo > /etc/rhgb/temp/rhgb-console
  531. fi
  532. return $rc
  533. }
  534. # returns OK if $1 contains $2
  535. strstr() {
  536. [ "${1#*$2*}" = "$1" ] && return 1
  537. return 0
  538. }
  539. # Confirm whether we really want to run this service
  540. confirm() {
  541. [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --details=yes
  542. while : ; do
  543. echo -n $"Start service $1 (Y)es/(N)o/(C)ontinue? [Y] "
  544. read answer
  545. if strstr $"yY" "$answer" || [ "$answer" = "" ] ; then
  546. return 0
  547. elif strstr $"cC" "$answer" ; then
  548. rm -f /var/run/confirm
  549. [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --details=no
  550. return 2
  551. elif strstr $"nN" "$answer" ; then
  552. return 1
  553. fi
  554. done
  555. }
  556. # resolve a device node to its major:minor numbers in decimal or hex
  557. get_numeric_dev() {
  558. (
  559. fmt="%d:%d"
  560. if [ "$1" == "hex" ]; then
  561. fmt="%x:%x"
  562. fi
  563. ls -lH "$2" | awk '{ sub(/,/, "", $5); printf("'"$fmt"'", $5, $6); }'
  564. ) 2>/dev/null
  565. }
  566. # find the working name for a running dm device with the same table as one
  567. # that dmraid would create
  568. resolve_dm_name() {
  569. (
  570. name="$1"
  571. line=$(/sbin/dmraid -ay -t --ignorelocking | \
  572. egrep -iv "no block devices found|No RAID disks" | \
  573. awk -F ':' "{ if (\$1 ~ /^$name$/) { print \$2; }}")
  574. for x in $line ; do
  575. if [[ "$x" =~ "^/dev/" ]] ; then
  576. majmin=$(get_numeric_dev dec $x)
  577. line=$(echo "$line" | sed -e "s,$x\( \|$\),$majmin\1,g")
  578. fi
  579. done
  580. line=$(echo "$line" | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' \
  581. -e 's/ core [12] [[:digit:]]\+ / core [12] [[:digit:]]\\+ /')
  582. /sbin/dmsetup table | \
  583. sed -n -e "s/.*\(no block devices found\|No devices found\).*//" \
  584. -e "s/\(^[^:]\+\): $line\( \+$\|$\)/\1/p"
  585. ) 2>/dev/null
  586. }
  587. # Check whether file $1 is a backup or rpm-generated file and should be ignored
  588. is_ignored_file() {
  589. case "$1" in
  590. *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave)
  591. return 0
  592. ;;
  593. esac
  594. return 1
  595. }
  596. # A sed expression to filter out the files that is_ignored_file recognizes
  597. __sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'