From 417ab8ce6c830042375da4ded4374a9f30a5387e Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 16 May 2011 13:36:18 +0200 Subject: makefile: do not make functions executable This was a bug in the original conversion to makefile (installing functions twice, the last time with wrong permissions). Signed-off-by: Tom Gundersen --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6923840..4e9f88d 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,10 @@ installdirs: install: minilogd installdirs install -m644 -t $(DESTDIR)/etc inittab rc.conf - install -m644 -t $(DESTDIR)/etc/rc.d functions install -m755 -t $(DESTDIR)/etc rc.local rc.local.shutdown rc.multi rc.shutdown rc.single rc.sysinit install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime - install -m755 -t $(DESTDIR)/etc/rc.d functions hwclock network netfs + install -m644 -t $(DESTDIR)/etc/rc.d functions + install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/sbin minilogd rc.d clean: -- cgit v1.2.3 From 99d64f5789f01243903be4b32078ec38bdce75fa Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 9 May 2011 22:15:43 +0200 Subject: udev: generate blacklist on boot udev will read /etc/modprobe.d/*.conf and blacklist all modules that are listed as blacklist We parse rc.conf at boot and generate such a .conf file. It cannot be written to /etc this early, so we save it to /run. A symlink exists in /etc to get the desired functionality. With this patch (and an analogous one in mkinitcpio) load-modules.sh can be removed from the udev package without loss of significant functionality. Setting MOD_AUTOLOAD will then no longer take effect, nor will kernel parameters. Thouhgh, kernel parameters might still affect the initramfs as the implementation is independent. Original-idea-by: Benjamen Richer Based-on-patch-by: David Reisner Signed-off-by: Tom Gundersen --- Makefile | 5 +++-- modprobe-blacklist | 25 +++++++++++++++++++++++++ rc.conf | 2 +- rc.sysinit | 3 +++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100755 modprobe-blacklist diff --git a/Makefile b/Makefile index 4e9f88d..ad8a058 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VER := $(shell git describe) -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d minilogd: minilogd.o @@ -12,7 +12,8 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime install -m644 -t $(DESTDIR)/etc/rc.d functions install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs - install -m755 -t $(DESTDIR)/sbin minilogd rc.d + install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist + ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf clean: rm -f minilogd minilogd.o diff --git a/modprobe-blacklist b/modprobe-blacklist new file mode 100755 index 0000000..8af5d90 --- /dev/null +++ b/modprobe-blacklist @@ -0,0 +1,25 @@ +#!/bin/bash +# +# /etc/rc.gen-modules-list +# + +. /etc/rc.conf + +declare -a blacklist +for mod in "${MODULES[@]}"; do + case $mod in + !*) blacklist+=("${mod:1}") ;; + *) ;; + esac +done + +# create new module blacklist in /run/initscripts, there should be a symlink in /etc/modprobe.d/ pointing here +if [[ $blacklist ]]; then + /bin/mkdir -p /run/initscripts + echo "# Autogenerated from rc.conf at boot, do not edit" > /run/initscripts/modprobe-blacklist.conf + (( ${#blacklist[@]} )) && printf 'blacklist %s\n' "${blacklist[@]}" >> /run/initscripts/modprobe-blacklist.conf +fi + +unset blacklist + +# vim: set noet ts=2 sw=2: diff --git a/rc.conf b/rc.conf index f09b413..89ea27e 100644 --- a/rc.conf +++ b/rc.conf @@ -36,7 +36,7 @@ VERBOSE="3" # MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed # MODULES: Modules to load at boot-up. Prefix with a ! to blacklist. # -MOD_AUTOLOAD="yes" +MOD_AUTOLOAD="yes" # (DEPRECATED) always leave at "yes" MODULES=() # Udev settle timeout (default to 30) diff --git a/rc.sysinit b/rc.sysinit index d0003ab..2250546 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -83,6 +83,9 @@ if [[ $HWCLOCK_PARAMS ]]; then fi fi +# parse rc.conf and create the blacklist file for use by modprobe +status "Creating UDev blacklist" /sbin/modprobe-blacklist + status "Starting UDev Daemon" /sbin/udevd --daemon run_hook sysinit_udevlaunched -- cgit v1.2.3 From cc1b8a39309fef45d092140fa130d0e82c696a44 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 18 May 2011 23:08:13 +0200 Subject: fixup: also clear /tmp if it is a mountpoint eda191cf78365cc3d1 inadvertently introduced a change so that /tmp was not cleared if it was a mountpoint. This restores the old behaviour. It is strongly adviced to not monut anything but a tmpfs on /tmp. This would avoid the issue. Signed-off-by: Tom Gundersen --- rc.sysinit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.sysinit b/rc.sysinit index 2250546..46f0c9b 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -316,7 +316,7 @@ fi stat_busy "Removing Leftover Files" /bin/rm -rf /etc/{nologin,shutdownpid} /forcefsck &>/dev/null -/bin/mountpoint -q /tmp || /bin/rm -rf /tmp/* /tmp/.* &>/dev/null +/bin/rm -rf /tmp/* /tmp/.* &>/dev/null [[ ! -L /var/lock ]] && /bin/rm -rf /var/lock/* [[ ! -L /var/run && -d /var/run ]] && /usr/bin/find /var/run/ \! -type d -delete [[ ! -L /var/run && ! -L /var/run/daemons ]] && /bin/rm -rf /var/run/daemons \ -- cgit v1.2.3 From aacbe897cc822d1daaa44cb754d56666e4f07e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=A4chler?= Date: Tue, 17 May 2011 20:13:39 +0200 Subject: Fix typo Signed-off-by: Tom Gundersen --- rc.sysinit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.sysinit b/rc.sysinit index 46f0c9b..fb96703 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -13,7 +13,7 @@ printsep run_hook sysinit_start -# export standard PATH (will be overridden later when /etc/profile is sourced, but is usefull for UDev) +# export standard PATH (will be overridden later when /etc/profile is sourced, but is useful for UDev) export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems) -- cgit v1.2.3 From b6e17433c8838acdc48ccfe726325118792a171e Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Wed, 18 May 2011 23:24:38 +0200 Subject: use mount -n for devpts and shm Signed-off-by: Gerardo Exequiel Pozzi Signed-off-by: Tom Gundersen --- rc.sysinit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index fb96703..fa1ba5f 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -29,9 +29,9 @@ if ! /bin/mountpoint -q /dev; then fi /bin/mkdir -p /run/lock /dev/{pts,shm} /bin/chmod 1777 /run/lock -/bin/mountpoint -q /dev/pts || /bin/mount /dev/pts &> /dev/null \ +/bin/mountpoint -q /dev/pts || /bin/mount -n /dev/pts &> /dev/null \ || /bin/mount -n -t devpts devpts /dev/pts -o mode=620,gid=5,nosuid,noexec -/bin/mountpoint -q /dev/shm || /bin/mount /dev/shm &> /dev/null \ +/bin/mountpoint -q /dev/shm || /bin/mount -n /dev/shm &> /dev/null \ || /bin/mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev # remount root ro to allow for fsck later on, we remount now to -- cgit v1.2.3 From e0e1420a3506a5988b8f76139788f0ffea298e0c Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Wed, 18 May 2011 23:32:36 +0200 Subject: add killall5 omit pid functionality (me) Update the offsets so can be merged now without any issues and respect the indentation. Implements FS#10536 - [initscripts] internal: save a pid from killall5 All credits to: Kurt J. Bosch Signed-off-by: Gerardo Exequiel Pozzi Signed-off-by: Tom Gundersen --- functions | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/functions b/functions index fd0928e..6d279cc 100644 --- a/functions +++ b/functions @@ -222,6 +222,14 @@ ck_status() { fi } +# PIDs to be omitted by killall5 +declare -a omit_pids + +add_omit_pids() { + omit_pids+=( $@ ) +} + + kill_everything() { # $1 = where we are being called from. # This is used to determine which hooks to run. @@ -241,12 +249,16 @@ kill_everything() { # Terminate all processes stat_busy "Sending SIGTERM To Processes" run_hook "$1_prekillall" - /sbin/killall5 -15 &> /dev/null + local pid k5args="" + for pid in ${omit_pids[@]}; do + k5args+=" -o $pid" + done + /sbin/killall5 -15 $k5args &> /dev/null /bin/sleep 5 stat_done stat_busy "Sending SIGKILL To Processes" - /sbin/killall5 -9 &> /dev/null + /sbin/killall5 -9 $k5args &> /dev/null /bin/sleep 1 stat_done -- cgit v1.2.3 From 9888b262c2deb32064b30eb637ece9e424356777 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 01:26:44 +0200 Subject: Add syntax to vim modeline in rc.d script With new name of script, vim doesn't reconize correctly file format. We need to set it explicitly. Signed-off-by: Sebastien Luttringer --- rc.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.d b/rc.d index 02c2b6c..49b7c2f 100755 --- a/rc.d +++ b/rc.d @@ -58,4 +58,4 @@ esac exit $ret -# vim: set ts=2 sw=2 noet: +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3 From d1be877eb0ad3be634cee08aada8f8d1265023a4 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 01:42:07 +0200 Subject: Add TERM var to rc.d cleaned env We need to do this to allow a correct detection of terminal colors in functions sourced by rc.d scripts Signed-off-by: Sebastien Luttringer --- rc.d | 1 + 1 file changed, 1 insertion(+) diff --git a/rc.d b/rc.d index 49b7c2f..55871b1 100755 --- a/rc.d +++ b/rc.d @@ -50,6 +50,7 @@ case $1 in ENV+=" PREVLEVEL='${runlevel:0:1}'" ENV+=" RUNLEVEL='${runlevel:2:1}'" ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" + ENV+=" TERM='${TERM}'" for i; do [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" (( ret += !! $? )) # clamp exit value to 0/1 -- cgit v1.2.3 From 1ba11e7f78af5742dbc211d9202db4549558ca44 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Wed, 4 May 2011 23:35:25 +0200 Subject: Improve coloring on light and transparent term This patch improve coloring in light and transparent term. It uses tput if available or default color code. It remplace \033 by \e. It's a kind of rollback from commit 65f410, because initscripts are now in bash, and argument "\e isn't recongized in all shells" is not an issue anymore. This is not done in locale.sh script which can be sourced by others shell, so we try to be the more compliant as possible Signed-off-by: Sebastien Luttringer --- functions | 47 ++++++++++++++++++++++++++++------------------- rc.sysinit | 4 ++-- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/functions b/functions index 6d279cc..27e53d0 100644 --- a/functions +++ b/functions @@ -49,28 +49,37 @@ else export LANG=C fi -# colors: -if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then - C_MAIN="\033[1;37;40m" # main text - - C_OTHER="\033[1;34;40m" # prefix & brackets - C_SEPARATOR="\033[1;30;40m" # separator - - C_BUSY="\033[0;36;40m" # busy - C_FAIL="\033[1;31;40m" # failed - C_DONE="\033[1;37;40m" # completed - C_BKGD="\033[1;35;40m" # backgrounded - - C_H1="\033[1;37;40m" # highlight text 1 - C_H2="\033[1;36;40m" # highlight text 2 - - C_CLEAR="\033[1;0m" +# set colors +if [[ $USECOLOR =~ yes|YES ]]; then + if /bin/tput setaf 0 &>/dev/null; then + C_CLEAR="$(tput sgr0)" # clear text + C_MAIN="${C_CLEAR}$(/bin/tput bold)" # main text + C_OTHER="${C_MAIN}$(/bin/tput setaf 4)" # prefix & brackets + C_SEPARATOR="${C_MAIN}$(/bin/tput setaf 0)" # separator + C_BUSY="${C_CLEAR}$(/bin/tput setaf 6)" # busy + C_FAIL="${C_MAIN}$(/bin/tput setaf 1)" # failed + C_DONE="${C_MAIN}" # completed + C_BKGD="${C_MAIN}$(/bin/tput setaf 5)" # backgrounded + C_H1="${C_MAIN}" # highlight text 1 + C_H2="${C_MAIN}$(/bin/tput setaf 6)" # highlight text 2 + else + C_CLEAR="\e[m" # clear text + C_MAIN="\e[;1m" # main text + C_OTHER="\e[1;34m" # prefix & brackets + C_SEPARATOR="\e[1;30m" # separator + C_BUSY="\e[;36m" # busy + C_FAIL="\e[1;31m" # failed + C_DONE="${C_MAIN}" # completed + C_BKGD="\e[1;35m" # backgrounded + C_H1="${$C_MAIN}" # highlight text 1 + C_H2="\e[1;36m" # highlight text 2 + fi fi if [[ -t 1 ]]; then - SAVE_POSITION="\033[s" - RESTORE_POSITION="\033[u" - DEL_TEXT="\033[$(($STAT_COL+4))G" + SAVE_POSITION="\e[s" + RESTORE_POSITION="\e[u" + DEL_TEXT="\e[$(($STAT_COL+4))G" else SAVE_POSITION="" RESTORE_POSITION="" diff --git a/rc.sysinit b/rc.sysinit index fa1ba5f..e5ed095 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -356,7 +356,7 @@ if [[ ${LOCALE,,} =~ utf ]]; then # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. for i in /dev/tty[0-9]*; do /usr/bin/kbd_mode -u < ${i} - printf "\033%%G" > ${i} + printf "\e%%G" > ${i} done echo 1 > /sys/module/vt/parameters/default_utf8 stat_done @@ -366,7 +366,7 @@ else # make non-UTF-8 consoles work on 2.6.24 and newer kernels for i in /dev/tty[0-9]*; do /usr/bin/kbd_mode -a < ${i} - printf "\033%%@" > ${i} + printf "\e%%@" > ${i} done echo 0 > /sys/module/vt/parameters/default_utf8 stat_done -- cgit v1.2.3 From d4d9f1f97f0fbf798eafbb5c1c1976c342605eb5 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 02:50:11 +0200 Subject: Add rc.d bash completion Signed-off-by: Sebastien Luttringer --- Makefile | 3 ++- bash-completion | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 bash-completion diff --git a/Makefile b/Makefile index ad8a058..25c9b58 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VER := $(shell git describe) -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d minilogd: minilogd.o @@ -14,6 +14,7 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf + install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d clean: rm -f minilogd minilogd.o diff --git a/bash-completion b/bash-completion new file mode 100644 index 0000000..3b0f464 --- /dev/null +++ b/bash-completion @@ -0,0 +1,18 @@ +# rc.d bash completion by Seblu + +_rc.d () +{ + local action="help list start stop reload restart" + local cur="${COMP_WORDS[COMP_CWORD]}" + local caction="${COMP_WORDS[1]}" + if ((${COMP_CWORD} == 1)); then + COMPREPLY=($(compgen -W "${action}" -- "$cur")) + elif [[ "$caction" == "help" || "$caction" == "list" ]]; then + COMPREPLY=() + elif ((${COMP_CWORD} > 1)); then + COMPREPLY=($( compgen -W "$(find /etc/rc.d -maxdepth 1 -type f -executable -printf '%f\n')" -- "$cur" )) + fi +} +complete -F _rc.d rc.d + +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3 From 68c61ed4ce2eddf29c4f047133406d72162fd396 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 28 Apr 2011 22:42:03 -0400 Subject: network/rc.sysinit: remove dead code Signed-off-by: Tom Gundersen --- network | 5 ----- rc.sysinit | 2 -- 2 files changed, 7 deletions(-) diff --git a/network b/network index 5a261b4..9cd6109 100755 --- a/network +++ b/network @@ -210,11 +210,6 @@ case "$1" in fi ;; stop) - #if ck_daemon network; then - # echo "Network is not running. Try 'network start'" - # exit - #fi - if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then status "Skipping Network Shutdown" true exit 0 diff --git a/rc.sysinit b/rc.sysinit index fa1ba5f..5a21539 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -328,8 +328,6 @@ stat_busy "Removing Leftover Files" /bin/mkdir -m1777 /tmp/.{X11,ICE}-unix stat_done -#status "Updating Shared Library Links" /sbin/ldconfig - if [[ $HOSTNAME ]]; then status "Setting Hostname: $HOSTNAME" /bin/hostname "$HOSTNAME" fi -- cgit v1.2.3 From d543c7aa098c214fa5e55a497353dda47b95d3ad Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sat, 21 May 2011 21:12:28 +0200 Subject: rc.d bash completion detect running daemon This patch adds sexy features from Auguste Pop bash completion patch. Mainly, detect if a daemon is running and complete accordingly Signed-off-by: Sebastien Luttringer --- bash-completion | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash-completion b/bash-completion index 3b0f464..5151972 100644 --- a/bash-completion +++ b/bash-completion @@ -7,10 +7,14 @@ _rc.d () local caction="${COMP_WORDS[1]}" if ((${COMP_CWORD} == 1)); then COMPREPLY=($(compgen -W "${action}" -- "$cur")) - elif [[ "$caction" == "help" || "$caction" == "list" ]]; then + elif [[ "$caction" =~ help|list ]]; then COMPREPLY=() + elif [[ "$caction" == start ]]; then + COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) + elif [[ "$caction" =~ stop|restart|reload ]]; then + COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) elif ((${COMP_CWORD} > 1)); then - COMPREPLY=($( compgen -W "$(find /etc/rc.d -maxdepth 1 -type f -executable -printf '%f\n')" -- "$cur" )) + COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) fi } complete -F _rc.d rc.d -- cgit v1.2.3 From 395803ff628e41940bbaaf5f1ffbcf591b007102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9moulins?= Date: Wed, 18 May 2011 22:16:02 +0200 Subject: Add a zsh completion script for the command rc.d. seblu: Fix typo, add vim modeline Signed-off-by: Sebastien Luttringer --- Makefile | 3 ++- zsh-completion | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 zsh-completion diff --git a/Makefile b/Makefile index 25c9b58..968cfb9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VER := $(shell git describe) -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d /usr/share/zsh/site-functions minilogd: minilogd.o @@ -15,6 +15,7 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d + install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d clean: rm -f minilogd minilogd.o diff --git a/zsh-completion b/zsh-completion new file mode 100644 index 0000000..bf8d9d0 --- /dev/null +++ b/zsh-completion @@ -0,0 +1,34 @@ +#compdef rc.d + +_rc.d () { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments "1: :->action" "*: :->service" + + case $state in + action) + _arguments "1:action:(list help start stop restart)" + ;; + service) + local action="$words[2]" + curcontext="${curcontext%:*:*}:rc.d-${action}:" + + case $action in + list) + _arguments "*: :" + ;; + help) + _arguments "*: :" + ;; + *) + _arguments "*: :_services" + ;; + esac + ;; + esac +} + +_rc.d "$@" + +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3 From a3314c769768d8c40b46767d26f9783d4f359358 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 28 Apr 2011 22:42:11 -0400 Subject: network: deprecate net-tools, add iproute2 support Provide large warnings when net-tools functionality is used. Add documentation in rc.conf for the new iproute2 based config. Signed-off-by: Tom Gundersen --- PKGBUILD | 7 ++-- network | 118 +++++++++++++++++++++++++++++++++++++++++++++---------------- rc.conf | 40 ++++++--------------- rc.sysinit | 2 +- 4 files changed, 102 insertions(+), 65 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index c5f2acd..5c9764c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,9 +9,10 @@ groups=('base') conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' - 'net-tools' 'ncurses' 'kbd' 'findutils' 'sysvinit') -optdepends=('bridge-utils: Network bridging support' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' 'iproute2' + 'ncurses' 'kbd' 'findutils' 'sysvinit') +optdepends=('net-tools: legacy networking support' + 'bridge-utils: Network bridging support' 'dhcpcd: DHCP network configuration' 'wireless_tools: Wireless networking') source=() diff --git a/network b/network index 9cd6109..7350149 100755 --- a/network +++ b/network @@ -7,6 +7,49 @@ for s in wireless bonding bridges dhcpcd; do [[ -f /etc/conf.d/$s ]] && . "/etc/conf.d/$s" done +# helper function to determine if legacy network support is needed +need_legacy() { + if [[ -z $interface ]]; then + return 0 # need legacy + fi + + return 1 # enough present for iproute2 support +} + +deprecated() { + printf "${C_FAIL}Warning:${C_CLEAR} This functionality is deprecated.\n" + printf " Please refer to /etc/rc.conf on how to define a single wired\n" + printf " connection, or use a utility such as netcfg.\n" +} + +network_up() { + /usr/sbin/ip link set dev $interface up || return 1 + + if [[ $address ]]; then + for var in netmask gateway; do + if [[ -z ${!var} ]]; then + printf "${C_FAIL}Error: static address defined without $var!\n" + return 1 + fi + done + /usr/sbin/ip addr add $address/$netmask dev $interface || return 1 + /usr/sbin/ip route add default via $gateway || return 1 + else + /sbin/dhcpcd $DHCPCD_ARGS $interface || return 1 + fi +} + +network_down() { + if [[ -f /var/run/dhcpcd-$interface.pid ]]; then + /sbin/dhcpcd -k $interface || return 1 + else + /usr/sbin/ip route del default || return 1 + /usr/sbin/ip addr flush dev $interface || return 1 + fi + + /usr/sbin/ip link set dev $interface down || return 1 +} + ifup() { local ifcfg=${!1} @@ -179,29 +222,34 @@ bridge_down() { case "$1" in start) + # deprecation check + need_legacy && deprecated if ! ck_daemon network; then echo "Network is already running. Try 'network restart'" exit fi - stat_busy "Starting Network" error=0 - # bring up bridge interfaces - bridge_up - # bring up ethernet interfaces - for ifline in ${INTERFACES[@]}; do - if [[ $ifline = ${ifline#!} ]]; then - ifup $ifline || error=1 - fi - done - # bring up bond interfaces - bond_up - # bring up routes - for rtline in "${ROUTES[@]}"; do - if [ "$rtline" = "${rtline#!}" ]; then - rtup $rtline || error=1 - fi - done + if need_legacy; then + # bring up bridge interfaces + bridge_up + # bring up ethernet interfaces + for ifline in ${INTERFACES[@]}; do + if [[ $ifline = ${ifline#!} ]]; then + ifup $ifline || error=1 + fi + done + # bring up bond interfaces + bond_up + # bring up routes + for rtline in "${ROUTES[@]}"; do + if [ "$rtline" = "${rtline#!}" ]; then + rtup $rtline || error=1 + fi + done + else + network_up + fi if ((error == 0)); then add_daemon network stat_done @@ -210,6 +258,8 @@ case "$1" in fi ;; stop) + # deprecation check + need_legacy && deprecated if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then status "Skipping Network Shutdown" true exit 0 @@ -218,20 +268,24 @@ case "$1" in stat_busy "Stopping Network" rm_daemon network error=0 - for rtline in "${ROUTES[@]}"; do - if [[ $rtline = ${rtline#!} ]]; then - rtdown $rtline || error=1 - fi - done - # bring down bond interfaces - bond_down - for ifline in ${INTERFACES[@]}; do - if [[ $ifline = ${ifline#!} ]]; then - ifdown $ifline || error=1 - fi - done - # bring down bridge interfaces - bridge_down + if need_legacy; then + for rtline in "${ROUTES[@]}"; do + if [[ $rtline = ${rtline#!} ]]; then + rtdown $rtline || error=1 + fi + done + # bring down bond interfaces + bond_down + for ifline in ${INTERFACES[@]}; do + if [[ $ifline = ${ifline#!} ]]; then + ifdown $ifline || error=1 + fi + done + # bring down bridge interfaces + bridge_down + else + network_down + fi if ((error == 0)); then stat_done else @@ -244,6 +298,8 @@ case "$1" in $0 start ;; ifup|ifdown|iflist|rtup|rtdown|rtlist) + # deprecation check + need_legacy && deprecated $1 $2 ;; *) diff --git a/rc.conf b/rc.conf index 89ea27e..5ebcd35 100644 --- a/rc.conf +++ b/rc.conf @@ -59,44 +59,24 @@ USELVM="no" # HOSTNAME="myhost" -# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces. +# Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces. # -# Interfaces to start at boot-up (in this order) -# Declare each interface then list in INTERFACES -# - prefix an entry in INTERFACES with a ! to disable it -# - no hyphens in your interface names - Bash doesn't like it +# Wired network setup +# - interface: name of device (required) +# - address: IP address (leave blank for DHCP) +# - netmask: subnet mask (ignored for DHCP) +# - gateway: default route (ignored for DHCP) # -# DHCP: Set your interface to "dhcp" (eth0="dhcp") -# Wireless: See network profiles below -# - -#Static IP example -#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" -eth0="dhcp" -INTERFACES=(eth0) -# Routes to start at boot-up (in this order) -# Declare each route then list in ROUTES -# - prefix an entry in ROUTES with a ! to disable it -# -gateway="default gw 192.168.0.1" -ROUTES=(!gateway) +interface= +address= +netmask= +gateway= # Setting this to "yes" will skip network shutdown. # This is required if your root device is on NFS. NETWORK_PERSIST="no" -# Enable these network profiles at boot-up. These are only useful -# if you happen to need multiple network configurations (ie, laptop users) -# - set to 'menu' to present a menu during boot-up (dialog package required) -# - prefix an entry with a ! to disable it -# -# Network profiles are found in /etc/network.d -# -# This now requires the netcfg package -# -#NETWORKS=(main) - # ----------------------------------------------------------------------- # DAEMONS # ----------------------------------------------------------------------- diff --git a/rc.sysinit b/rc.sysinit index 5a21539..9d30da2 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -115,7 +115,7 @@ run_hook sysinit_udevsettled # bring up the loopback interface [[ -d /sys/class/net/lo ]] && \ - status "Bringing up loopback interface" /sbin/ifconfig lo 127.0.0.1 up + status "Bringing up loopback interface" /usr/sbin/ip link set up dev lo # FakeRAID devices detection if [[ $USEDMRAID =~ yes|YES && -x /sbin/dmraid ]]; then -- cgit v1.2.3 From 18adeacb36967463330060237725ffbdfd47e2a7 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Mon, 23 May 2011 01:13:57 +0200 Subject: rc.d zsh completion detect running daemons This patch adds functionalities of bash completions about running demons Signed-off-by: Sebastien Luttringer --- zsh-completion | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zsh-completion b/zsh-completion index bf8d9d0..f1b7165 100644 --- a/zsh-completion +++ b/zsh-completion @@ -15,14 +15,17 @@ _rc.d () { curcontext="${curcontext%:*:*}:rc.d-${action}:" case $action in - list) + list|help) _arguments "*: :" ;; - help) - _arguments "*: :" + start) + _arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))" + ;; + stop|restart|reload) + _arguments "*: :(/run/daemons/*(N:t))" ;; *) - _arguments "*: :_services" + _arguments "*: :(/etc/rc.d/*(N-*:t))" ;; esac ;; -- cgit v1.2.3 From d0340e988f96f38cfb518d88e1e6d6e8a3b1cf8c Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 27 May 2011 09:09:44 -0400 Subject: rc.d: declare ENV as an array Signed-off-by: Dave Reisner Signed-off-by: Sebastien Luttringer --- rc.d | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rc.d b/rc.d index 55871b1..af29574 100755 --- a/rc.d +++ b/rc.d @@ -46,13 +46,13 @@ case $1 in shift # set same environment variables as init runlevel=$(/sbin/runlevel) - ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'" - ENV+=" PREVLEVEL='${runlevel:0:1}'" - ENV+=" RUNLEVEL='${runlevel:2:1}'" - ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" - ENV+=" TERM='${TERM}'" + ENV=("PATH=/bin:/usr/bin:/sbin:/usr/sbin" + "PREVLEVEL=${runlevel%% *}" + "RUNLEVEL=${runlevel##* }" + "CONSOLE=${CONSOLE:-/dev/console}" + "TERM=$TERM") for i; do - [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" + [[ -x "/etc/rc.d/$i" ]] && cd / && /usr/bin/env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" (( ret += !! $? )) # clamp exit value to 0/1 done esac -- cgit v1.2.3 From a7627c6d0784ca169b14265744ce356a7d740f62 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Tue, 31 May 2011 08:25:28 +0200 Subject: rc.d: Remove cd from the loop Signed-off-by: Sebastien Luttringer --- rc.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rc.d b/rc.d index af29574..3c7fcb9 100755 --- a/rc.d +++ b/rc.d @@ -51,8 +51,9 @@ case $1 in "RUNLEVEL=${runlevel##* }" "CONSOLE=${CONSOLE:-/dev/console}" "TERM=$TERM") + cd / for i; do - [[ -x "/etc/rc.d/$i" ]] && cd / && /usr/bin/env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" + [[ -x "/etc/rc.d/$i" ]] && /usr/bin/env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" (( ret += !! $? )) # clamp exit value to 0/1 done esac -- cgit v1.2.3 From 997f095bf69a4470189e1ccfc345f354899192d8 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Tue, 31 May 2011 08:27:18 +0200 Subject: rc.d: print usage if not enough argument Signed-off-by: Sebastien Luttringer --- rc.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rc.d b/rc.d index 3c7fcb9..9aa5a65 100755 --- a/rc.d +++ b/rc.d @@ -42,6 +42,8 @@ case $1 in done ;; *) + # check min args count + (( $# < 2 )) && usage action=$1 shift # set same environment variables as init -- cgit v1.2.3 From 2b188618291d537c0b5da8c3b84902e53436352a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 31 May 2011 01:11:23 +0200 Subject: Revert "udev: generate blacklist on boot" This reverts commit 99d64f5789f01243903be4b32078ec38bdce75fa. We decided not to provide a compatibility layer, but rather require the user to create blacklist files in /etc/modprobe.d manually. Hence, this is no longer needed. The reason was that the compatibliy would not be 1-to-1, so it might be missleading to pretend that it was. Also, most people should not need the blacklisting in the first place. Conflicts: Makefile Signed-off-by: Tom Gundersen --- Makefile | 5 ++--- modprobe-blacklist | 25 ------------------------- rc.conf | 2 +- rc.sysinit | 3 --- 4 files changed, 3 insertions(+), 32 deletions(-) delete mode 100755 modprobe-blacklist diff --git a/Makefile b/Makefile index 968cfb9..fcabb0e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VER := $(shell git describe) -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d /usr/share/zsh/site-functions +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/bash_completion.d /usr/share/zsh/site-functions minilogd: minilogd.o @@ -12,8 +12,7 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime install -m644 -t $(DESTDIR)/etc/rc.d functions install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs - install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist - ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf + install -m755 -t $(DESTDIR)/sbin minilogd rc.d install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d diff --git a/modprobe-blacklist b/modprobe-blacklist deleted file mode 100755 index 8af5d90..0000000 --- a/modprobe-blacklist +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# -# /etc/rc.gen-modules-list -# - -. /etc/rc.conf - -declare -a blacklist -for mod in "${MODULES[@]}"; do - case $mod in - !*) blacklist+=("${mod:1}") ;; - *) ;; - esac -done - -# create new module blacklist in /run/initscripts, there should be a symlink in /etc/modprobe.d/ pointing here -if [[ $blacklist ]]; then - /bin/mkdir -p /run/initscripts - echo "# Autogenerated from rc.conf at boot, do not edit" > /run/initscripts/modprobe-blacklist.conf - (( ${#blacklist[@]} )) && printf 'blacklist %s\n' "${blacklist[@]}" >> /run/initscripts/modprobe-blacklist.conf -fi - -unset blacklist - -# vim: set noet ts=2 sw=2: diff --git a/rc.conf b/rc.conf index 5ebcd35..f92df20 100644 --- a/rc.conf +++ b/rc.conf @@ -36,7 +36,7 @@ VERBOSE="3" # MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed # MODULES: Modules to load at boot-up. Prefix with a ! to blacklist. # -MOD_AUTOLOAD="yes" # (DEPRECATED) always leave at "yes" +MOD_AUTOLOAD="yes" MODULES=() # Udev settle timeout (default to 30) diff --git a/rc.sysinit b/rc.sysinit index b8553e9..00a328e 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -83,9 +83,6 @@ if [[ $HWCLOCK_PARAMS ]]; then fi fi -# parse rc.conf and create the blacklist file for use by modprobe -status "Creating UDev blacklist" /sbin/modprobe-blacklist - status "Starting UDev Daemon" /sbin/udevd --daemon run_hook sysinit_udevlaunched -- cgit v1.2.3 From 268986e2d39a9ead28b8281fbbcbf79b6ec6c240 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 31 May 2011 01:18:50 +0200 Subject: depraction: MOD_AUTOLOAD and MODULES blacklisting Add comment to note that MOD_AUTOLOAD should always be "yes" and blacklisting is no longer supported in the MODULES array. Signed-off-by: Tom Gundersen --- rc.conf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rc.conf b/rc.conf index f92df20..3c21d4e 100644 --- a/rc.conf +++ b/rc.conf @@ -33,8 +33,12 @@ VERBOSE="3" # HARDWARE # ----------------------------------------------------------------------- # -# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed -# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist. +# MOD_AUTOLOAD: Deprecated. Always leave at "yes". +# MODULES: Modules to load at boot-up. Blacklisting is no longer supported. +# Replace every !module by an entry as on the following line in a file in +# /etc/modprobe.d: +# blacklist module +# See "man modprobe.conf" for details. # MOD_AUTOLOAD="yes" MODULES=() -- cgit v1.2.3 From 017b5a689363aac54313b6e51d0da713f33787b7 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 31 May 2011 10:24:12 +0200 Subject: net: add examples Signed-off-by: Tom Gundersen --- rc.conf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rc.conf b/rc.conf index 3c21d4e..534112f 100644 --- a/rc.conf +++ b/rc.conf @@ -71,6 +71,17 @@ HOSTNAME="myhost" # - netmask: subnet mask (ignored for DHCP) # - gateway: default route (ignored for DHCP) # +# Static IP example +# interface=eth0 +# address=192.168.0.2 +# netmask=255.255.255.0 +# gateway=192.168.0.1 +# +# DHCP example +# interface=eth0 +# address= +# netmask= +# gateway= interface= address= -- cgit v1.2.3 From aac43067a13f1940f8f81f45142463e85ce21de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20B=C3=A9langer?= Date: Thu, 26 May 2011 22:07:23 -0400 Subject: rc.d: Add error message when daemon script is not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric BĂ©langer Signed-off-by: Tom Gundersen --- rc.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rc.d b/rc.d index 55871b1..97f266a 100755 --- a/rc.d +++ b/rc.d @@ -52,7 +52,12 @@ case $1 in ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" ENV+=" TERM='${TERM}'" for i; do - [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" + if [[ -x "/etc/rc.d/$i" ]]; then + cd / + eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" + else + printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script $i does not exist.\n" + fi (( ret += !! $? )) # clamp exit value to 0/1 done esac -- cgit v1.2.3