--- /sbin/rc-update 2004-02-09 10:53:47.000000000 +0200 +++ rc-update 2004-03-12 22:47:11.007855168 +0200 @@ -12,9 +12,10 @@ usage() { cat << FOO -usage: rc-update -a|add script runlevel2 [runlevel2...] +usage: rc-update -a|add script runlevel1 [runlevel2...] rc-update -d|del script [runlevel1...] rc-update -s|show [runlevel1...] + rc-update -c|current runlevel note: After rc-update executes, the script dependency cache is automatically @@ -38,6 +39,11 @@ Show all the available scripts and list at which runlevels they will execute. + rc-update current default + Synchornize current running services with the "default" runlevel, + creating "default" it is doesn't exist. + use without any argument to sync to current runlevel. + FOO exit 1 } @@ -159,6 +165,50 @@ done } +current() { + + local x= + local mylevel= + + shift + if [ $# -eq 0 ] + then + mylevel=$(cat /var/lib/init.d/softlevel) + ewarn "Using current runlevel: ${mylevel}" + echo + else + mylevel=$1 + fi + + if [ ! -e "/etc/runlevels/${mylevel}" ] + then + einfo Creating runlevel ${mylevel} + echo + mkdir "/etc/runlevels/${mylevel}" + fi + + # Scan current started services and add them to current runlevel + + for x in $( cd /var/lib/init.d/started/ ; ls ) + do + if [ ! -L "/etc/runlevels/${mylevel}/${x}" ] + then + add shift ${x} ${mylevel} + fi + done + + # Scan current runlevel for non-running services, and remove them + + for x in $( cd /etc/runlevels/${mylevel} ; ls ) + do + if [ ! -L "/var/lib/init.d/started/${x}" ] + then + del shift ${x} ${mylevel} + fi + done + +} + if [ $# -lt 1 ] then usage @@ -177,6 +227,9 @@ show|-s) show "$@" ;; + current|-c) + current "$@" + ;; *) usage exit 1