# update-rc.d (BRINTOS-89) — the /etc/rcN.d symlink manager dpkg maintainer # scripts call. Coverage: presence/usage, the defaults link set, the explicit # start-NN form, remove, and the missing-initscript error path — all against a # scratch root via -r, so the suite never touches the real /etc. # # The tool installs to /usr/sbin; extend PATH in case the runner's shell # carries only the bin dirs. PATH="$PATH:/usr/sbin:/sbin" . "$BST_LIB" require update-rc.d update-rc.d/present # -h prints usage and exits 0 (a bare invocation usages to rc 1) check_out update-rc.d/usage "usage: update-rc.d" update-rc.d -h check_rc update-rc.d/no-args-rc 1 update-rc.d work=${TMPDIR:-/tmp}/bst-update-rc-d.$$ mkdir -p "$work/etc/init.d" 2>/dev/null printf '#!/bin/sh\ntrue\n' > "$work/etc/init.d/bstsvc" chmod 0755 "$work/etc/init.d/bstsvc" 2>/dev/null # defaults: S20 start links in rc2-5.d, K20 stop links in rc0/1/6.d check_out update-rc.d/defaults "Adding system startup" update-rc.d -r "$work" bstsvc defaults check update-rc.d/start-link test -L "$work/etc/rc5.d/S20bstsvc" check update-rc.d/stop-link test -L "$work/etc/rc0.d/K20bstsvc" check_out update-rc.d/link-target "../init.d/bstsvc" readlink "$work/etc/rc5.d/S20bstsvc" # remove (-f: the init.d script still exists) drops every link check update-rc.d/remove update-rc.d -r "$work" -f bstsvc remove check update-rc.d/removed sh -c "! test -e '$work/etc/rc5.d/S20bstsvc'" # explicit form: start 30 in runlevel 3 only check update-rc.d/start-nn update-rc.d -r "$work" bstsvc start 30 3 . check update-rc.d/start-nn-link test -L "$work/etc/rc3.d/S30bstsvc" check update-rc.d/start-nn-scoped sh -c "! test -e '$work/etc/rc5.d/S30bstsvc'" # a basename with no /etc/init.d script is refused check_rc update-rc.d/missing-script 1 update-rc.d -r "$work" bst-nosuch defaults rm -rf "$work"