Compare commits
	
		
			34 Commits
		
	
	
		
			openrc-0.5
			...
			openrc-0.6
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 5ec2efaff2 | ||
|   | 9ca65be42e | ||
|   | a704b97fd2 | ||
|   | 2c0a71172d | ||
|   | cbafcd078d | ||
|   | a165fbe384 | ||
|   | 02c12c1cac | ||
|   | 084f5e12eb | ||
|   | 3b9eaea8ec | ||
|   | dc3ccd8101 | ||
|   | 9476a2e721 | ||
|   | 1d174cc60c | ||
|   | 12af86395f | ||
|   | 5b3e5edda2 | ||
|   | 775d56b877 | ||
|   | 22e2a4f0a1 | ||
|   | ca752a5a2d | ||
|   | 93cecab1ed | ||
|   | baf3b2dd45 | ||
|   | e9e37ad798 | ||
|   | 4df8770a90 | ||
|   | ec38bbbdda | ||
|   | 509e34d425 | ||
|   | 0de1d18d41 | ||
|   | 89a2d76772 | ||
|   | 80d4ce3a11 | ||
|   | d21177e5c7 | ||
|   | d29daf3952 | ||
|   | 1d9ce8e9a1 | ||
|   | bb96dc4e01 | ||
|   | ebb49805fc | ||
|   | 4a892a23ba | ||
|   | 95ee39ab1c | ||
|   | 3c8ea5896a | 
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -4,7 +4,7 @@ | ||||
|  | ||||
| include Makefile.inc | ||||
|  | ||||
| SUBDIR=		conf.d etc init.d man sh src | ||||
| SUBDIR=		conf.d etc init.d man scripts sh src | ||||
|  | ||||
| # Build our old net foo or not | ||||
| _OLDNET_SH=	case "${MKOLDNET}" in \ | ||||
|   | ||||
| @@ -1,3 +1,3 @@ | ||||
| NAME=		openrc | ||||
| VERSION=	0.5.2 | ||||
| VERSION=	0.6.0 | ||||
| PKG=		${NAME}-${VERSION} | ||||
|   | ||||
							
								
								
									
										3
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								README
									
									
									
									
									
								
							| @@ -58,7 +58,8 @@ If you installed OpenRC from your chosen distribution, you should report | ||||
| bugs directly to them. For example, if you use Gentoo and emerged OpenRC | ||||
| then you should reports bugs to http://bugs.gentoo.org. | ||||
|  | ||||
| Otherwise, you can report them directly to me at http://bugs.marples.name | ||||
| Otherwise, you can report them directly to me at | ||||
| http://roy.marples.name/projects/openrc | ||||
|  | ||||
|  | ||||
| History - by Roy Marples | ||||
|   | ||||
| @@ -13,7 +13,7 @@ SOS?=	BSD | ||||
|  | ||||
| network: network.in network.${OS} | ||||
| 	cp $@.in $@ | ||||
| 	[ -e $@.${OS} ] && cat $@.${OS} >> $@ || true | ||||
| 	[ -e $@.${SOS} ] && cat $@.${SOS} >> $@ || true | ||||
|  | ||||
| staticroute: staticroute.${SOS} | ||||
| 	cp $@.${SOS} $@ | ||||
|   | ||||
| @@ -1,3 +1 @@ | ||||
| CONF+=	ipfw moused powerd rarpd savecore syscons | ||||
|  | ||||
| network.${OS}: | ||||
|   | ||||
| @@ -1,3 +1 @@ | ||||
| CONF+=	moused rarpd savecore | ||||
|  | ||||
| network.${OS}: | ||||
|   | ||||
| @@ -13,6 +13,11 @@ | ||||
| #fsck_passno=">1" | ||||
| #fsck_passno="<2" | ||||
|  | ||||
| # Most modern fs's don't require a full fsck on boot, but for those that do | ||||
| # it may be advisable to skip this when running on battery. | ||||
| # WARNING: Do not turn this off if you have any JFS partitions. | ||||
| fsck_on_battery="YES" | ||||
|  | ||||
| # fsck_shutdown causes fsck to trigger during shutdown as well as startup. | ||||
| # The end result of this is that if any periodic non-root filesystem checks are | ||||
| # scheduled, under normal circumstances the actual check will happen during | ||||
|   | ||||
							
								
								
									
										4
									
								
								conf.d/network.BSD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								conf.d/network.BSD
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
|  | ||||
| # You can assign a default route | ||||
| #defaultroute="192.168.0.1" | ||||
| #defaultroute6="2001:a:b:c" | ||||
| @@ -1,8 +1,17 @@ | ||||
|  | ||||
| # You can assign a default route | ||||
| #defaultroute="gw 192.168.0.1" | ||||
| #defaultroute6="gw 2001:a:b:c" | ||||
|  | ||||
| # ifconfig under Linux is not that powerful and doesn't easily handle | ||||
| # multiple addresses | ||||
| # On the other hand, ip (iproute2) is quite powerful and is also supported | ||||
| #ip_eth0="192.168.0.10/24; 192.168.10.10/24" | ||||
|  | ||||
| # You can also use ip to add the default route. | ||||
| #defaultiproute="via 192.168.0.1" | ||||
| #defaultiproute6="via 2001:a:b:c" | ||||
|  | ||||
| # ip doesn't handle MTU like ifconfig, but we can do it like so | ||||
| #ifup_eth0="ip link set \$int mtu 1500" | ||||
|  | ||||
|   | ||||
| @@ -9,8 +9,6 @@ | ||||
| # You should note that we don't stop the network at system shutdown by default. | ||||
| # If you really need this, then set shutdown_network=YES | ||||
|  | ||||
| # You can assign a default route | ||||
| #defaultroute="192.168.0.1" | ||||
| # Lastly, the interfaces variable pulls in virtual interfaces that cannot | ||||
| # be automatically detected. | ||||
| #interfaces="br0 bond0 vlan0" | ||||
|   | ||||
| @@ -1,2 +1,6 @@ | ||||
| # Example static route. See route(8) for syntax. | ||||
| staticroute="net 192.168.0.0 -netmask 255.255.0.0 10.73.1.1" | ||||
| # Separate multiple routes using ; or new lines. | ||||
| # /etc/route.conf(5) takes precedence over this configuration. | ||||
|  | ||||
| # Example static routes. See route(8) for syntax. | ||||
| #staticroute="net 192.168.0.0 -netmask 255.255.255.0 10.73.1.1 | ||||
| #net 192.168.1.0 -netmask 255.255.255.0 10.73.1.1" | ||||
|   | ||||
| @@ -1,2 +1,8 @@ | ||||
| # Example static route. See route(8) for syntax. | ||||
| staticroute="net 192.168.0.0 netmask 255.255.0.0 gw 10.73.1.1" | ||||
| # Separate multiple routes using ; or new lines. | ||||
|  | ||||
| # Example static routes. See route(8) for syntax. | ||||
| #staticroute="net 192.168.0.0 netmask 255.255.255.0 gw 10.73.1.1 | ||||
| #net 192.168.1.0 netmask 255.255.255.0 gw 10.73.1.1" | ||||
|  | ||||
| # Example static routes using iproute2. See ip(8) for syntax. | ||||
| #staticiproute="192.168.0.0/24 via 10.73.1.1; 192.168.1.0/24 via 10.73.1.1" | ||||
|   | ||||
| @@ -43,11 +43,6 @@ | ||||
| #       (eth0:1, eth0:2, etc) | ||||
| #       iproute2 does not do this as there is no need to | ||||
| #config_eth0="192.168.0.2/24 192.168.0.3/24 192.168.0.4/24" | ||||
| # Or you can use sequence expressions | ||||
| #config_eth0="192.168.0.{2..4}/24"  FIXME - may not work with baselayout2 | ||||
| # which does the same as above. Be careful though as if you use this and | ||||
| # fallbacks, you have to ensure that both end up with the same number of | ||||
| # values otherwise your fallback won't work correctly. | ||||
|  | ||||
| # You can also use IPv6 addresses | ||||
| # (you should always specify a prefix length with IPv6 here) | ||||
| @@ -242,12 +237,12 @@ | ||||
|  | ||||
| ################################################## | ||||
| # wpa_supplicant | ||||
| # emerge net-wireless/wpa-supplicant | ||||
| # emerge net-wireless/wpa_supplicant | ||||
| # Wireless options are held in /etc/wpa_supplicant/wpa_supplicant.conf | ||||
| # Console the wpa_supplicant.conf.example that is installed in | ||||
| # Consult the wpa_supplicant.conf.example that is installed in | ||||
| # /usr/share/doc/wpa_supplicant | ||||
|  | ||||
| # By default we don't wait for wpa_suppliant to associate and authenticate. | ||||
| # By default we don't wait for wpa_supplicant to associate and authenticate. | ||||
| # If you would like to, so can specify how long in seconds | ||||
| #associate_timeout_eth0=60 | ||||
| # A value of 0 means wait forever. | ||||
|   | ||||
| @@ -70,11 +70,6 @@ | ||||
| #       iproute2 does not do this as there is no need to | ||||
| #config_eth0="192.168.0.2/24 192.168.0.3/24 192.168.0.4/24" | ||||
| # However, that only works with CIDR addresses, so you can't use netmask. | ||||
| # Or you can use sequence expressions | ||||
| #config_eth0="192.168.0.{2..4}/24" | ||||
| # which does the same as above. Be careful though as if you use this and | ||||
| # fallbacks, you have to ensure that both end up with the same number of | ||||
| # values otherwise your fallback won't work correctly. | ||||
|  | ||||
| # You can also use IPv6 addresses | ||||
| # (you should always specify a prefix length with IPv6 here) | ||||
| @@ -341,16 +336,16 @@ | ||||
|  | ||||
| ############################################################ | ||||
| # wpa_supplicant | ||||
| # emerge net-wireless/wpa-supplicant | ||||
| # emerge net-wireless/wpa_supplicant | ||||
| # Wireless options are held in /etc/wpa_supplicant/wpa_supplicant.conf | ||||
| # Console the wpa_supplicant.conf.example that is installed in | ||||
| # Consult the wpa_supplicant.conf.example that is installed in | ||||
| # /usr/share/doc/wpa_supplicant | ||||
| # To configure wpa_supplicant | ||||
| #wpa_supplicant_ath0="-Dmadwifi" # For Atheros based cards | ||||
| # Consult wpa_supplicant for more drivers - the default is -Dwext which should | ||||
| # work for most cards. | ||||
|  | ||||
| # By default we don't wait for wpa_suppliant to associate and authenticate. | ||||
| # By default we don't wait for wpa_supplicant to associate and authenticate. | ||||
| # If you need to change this behaviour then you don't know how our scripts work | ||||
| # and setting this value could cause strange things to happen. | ||||
| # If you would like to, so can specify how long in seconds. | ||||
|   | ||||
| @@ -95,7 +95,7 @@ start() | ||||
| 		for x in "" $xtra; do | ||||
| 			mkutmp /var/run/utmp$x | ||||
| 		done | ||||
| 		[ -e /var/log/wtmp ] && mkutmp /var/log/wtmp | ||||
| 		[ -e /var/log/wtmp ] || mkutmp /var/log/wtmp | ||||
| 		eend 0 | ||||
|  | ||||
| 		ebegin "Cleaning /var/run" | ||||
|   | ||||
| @@ -9,7 +9,7 @@ _IFS=" | ||||
| depend() | ||||
| { | ||||
| 	use dev clock modules | ||||
| 	keyword -jail -openvz -prefix -timeout -vserver | ||||
| 	keyword -jail -openvz -prefix -timeout -vserver -lxc | ||||
| } | ||||
|  | ||||
| _abort() { | ||||
| @@ -30,38 +30,6 @@ _forcefsck() | ||||
| 	[ -e /forcefsck ] || get_bootparam forcefsck | ||||
| } | ||||
|  | ||||
| _on_ac_power() | ||||
| { | ||||
| 	if [ -f /proc/acpi/ac_adapter/AC*/state ]; then | ||||
| 		cat /proc/acpi/ac_adapter/AC*/state | while read line; do | ||||
| 			case "$line" in | ||||
| 			"state:"*"off-line") return 128;; | ||||
| 			esac | ||||
| 		done | ||||
| 	elif [ -f /proc/pmu/info ]; then | ||||
| 		cat /proc/pmu/info | while read line; do | ||||
| 			case "$line" in | ||||
| 			"AC Power"*": 0") return 128;; | ||||
| 			esac | ||||
| 		done | ||||
| 	elif type envstat >/dev/null 2>&1; then | ||||
| 		# NetBSD has envstat | ||||
| 		envstat -d acpiacad0 2>/dev/null | while read line; do | ||||
| 			case "$line" in | ||||
| 			"connected:"*"OFF") return 128;; | ||||
| 			esac | ||||
| 		done | ||||
| 	elif sysctl -q hw.acpi.acline >/dev/null 2>/dev/null; then | ||||
| 		case $(sysctl -n hw.acpi.acline) in | ||||
| 		0) return 1;; | ||||
| 		*) return 0;; | ||||
| 		esac | ||||
| 	else | ||||
| 		return 0 | ||||
| 	fi | ||||
| 	[ $? != 128 ] | ||||
| } | ||||
|  | ||||
| start() | ||||
| { | ||||
| 	local fsck_opts= p= check_extra= | ||||
| @@ -73,7 +41,7 @@ start() | ||||
| 	if _forcefsck; then | ||||
| 		fsck_opts="$fsck_opts -f" | ||||
| 		check_extra="(check forced)" | ||||
| 	elif ! _on_ac_power; then | ||||
| 	elif ! yesno ${fsck_on_battery:-YES} && ! on_ac_power; then | ||||
| 		ewarn "Skipping fsck due to not being on AC power" | ||||
| 		return 0 | ||||
| 	fi | ||||
|   | ||||
| @@ -28,7 +28,7 @@ depend() | ||||
| 	else | ||||
| 		before * | ||||
| 	fi | ||||
| 	keyword -openvz -prefix -uml -vserver -xenu | ||||
| 	keyword -openvz -prefix -uml -vserver -xenu -lxc | ||||
| } | ||||
|  | ||||
| setupopts() | ||||
|   | ||||
| @@ -15,7 +15,7 @@ start() | ||||
| { | ||||
| 	ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} | ||||
| 	: ${unicode:=$UNICODE} | ||||
| 	: =${keymap:=$KEYMAP} | ||||
| 	: ${keymap:=$KEYMAP} | ||||
| 	: ${extended_keymaps:=$EXTENDED_KEYMAPS} | ||||
| 	: ${windowkeys:=$SET_WINDOWSKEYS}  | ||||
| 	: ${fix_euro:=$FIX_EURO} | ||||
| @@ -34,15 +34,25 @@ start() | ||||
| 		echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes | ||||
| 	fi | ||||
|  | ||||
| 	ebegin "Loading key mappings [$keymap]" | ||||
| 	local loadkeys_uni= wkeys= kmode="-a" msg="ASCII" | ||||
| 	local wkeys= kmode="-a" msg="ASCII" | ||||
| 	if yesno $unicode; then | ||||
| 		loadkeys_uni="--unicode" | ||||
| 		kmode="-u" | ||||
| 		msg="UTF-8" | ||||
| 	fi | ||||
| 	yesno $windowkeys && wkeys="windowkeys" | ||||
| 	loadkeys -q $loadkeys_uni $wkeys $keymap $extended_keymaps | ||||
|  | ||||
| 	# Set terminal encoding to either ASCII or UNICODE. | ||||
| 	# See utf-8(7) for more information. | ||||
| 	ebegin "Setting keyboard mode [$msg]" | ||||
| 	n=1 | ||||
| 	while [ $n -le $ttyn ]; do | ||||
| 		kbd_mode $kmode -C $ttydev$n | ||||
| 		n=$(($n + 1)) | ||||
| 	done | ||||
| 	eend 0 | ||||
|  | ||||
| 	ebegin "Loading key mappings [$keymap]" | ||||
| 	loadkeys -q $wkeys $keymap $extended_keymaps | ||||
| 	eend $? "Error loading key mappings" || return $? | ||||
|  | ||||
| 	if yesno $fix_euro; then | ||||
| @@ -52,20 +62,6 @@ start() | ||||
| 		eend $? | ||||
| 	fi | ||||
|  | ||||
| 	# Set terminal encoding to either ASCII or UNICODE. | ||||
| 	# See utf-8(7) for more information. | ||||
| 	ebegin "Setting keyboard mode [$msg]" | ||||
| 	if yesno $unicode; then | ||||
| 		dumpkeys ${dumpkeys_charset:+-c} \ | ||||
| 			$dumpkeys_charset | loadkeys --unicode | ||||
| 	fi | ||||
| 	n=1 | ||||
| 	while [ $n -le $ttyn ]; do | ||||
| 		kbd_mode $kmode -C $ttydev$n | ||||
| 		n=$(($n + 1)) | ||||
| 	done | ||||
| 	eend 0 | ||||
|  | ||||
| 	# Save the keymapping for use immediately at boot | ||||
| 	if [ -w "$RC_LIBEXECDIR" ]; then | ||||
| 		mkdir -p "$RC_LIBEXECDIR"/console | ||||
|   | ||||
| @@ -8,7 +8,7 @@ depend() | ||||
| { | ||||
| 	need fsck | ||||
| 	use lvm modules mtab | ||||
| 	keyword -jail -openvz -prefix -vserver | ||||
| 	keyword -jail -openvz -prefix -vserver -lxc | ||||
| } | ||||
|  | ||||
| start() | ||||
|   | ||||
| @@ -7,7 +7,7 @@ description="Loads a user defined list of kernel modules." | ||||
| depend() | ||||
| { | ||||
| 	use isapnp | ||||
| 	keyword -openvz -prefix -vserver | ||||
| 	keyword -openvz -prefix -vserver -lxc | ||||
| } | ||||
|  | ||||
| start() | ||||
|   | ||||
| @@ -7,7 +7,7 @@ description="Re-mount filesytems read-only for a clean reboot." | ||||
| depend() | ||||
| { | ||||
| 	need killprocs savecache | ||||
| 	keyword -prefix -openvz -vserver | ||||
| 	keyword -prefix -openvz -vserver -lxc | ||||
| } | ||||
|  | ||||
| start() | ||||
|   | ||||
| @@ -107,13 +107,20 @@ intup=false | ||||
| runip() | ||||
| { | ||||
| 	local int="$1" err= | ||||
|  | ||||
| 	shift | ||||
|  | ||||
| 	# Ensure we have a valid broadcast address | ||||
| 	case "$@" in | ||||
| 	*" broadcast "*|*" brd "*) ;; | ||||
| 	*:*) ;; # Ignore IPv6 | ||||
| 	*) set -- "$@" brd +;; | ||||
| 	esac | ||||
|  | ||||
| 	err=$(LC_ALL=C ip address add "$@" dev "$int" 2>&1) | ||||
| 	if [ -z "$err" ]; then | ||||
| 		# ip does not bring up the interface when adding addresses | ||||
| 		if ! intup; then | ||||
| 			ip set link up dev "$int" | ||||
| 		if ! $intup; then | ||||
| 			ip link set "$int" up | ||||
| 			intup=true | ||||
| 		fi | ||||
| 		return 0 | ||||
| @@ -130,6 +137,7 @@ routeflush() | ||||
| 	if [ "$RC_UNAME" = Linux ]; then | ||||
| 		if [ -x /sbin/ip ]; then | ||||
| 			ip route flush scope global | ||||
| 			ip route delete default 2>/dev/null | ||||
| 		else | ||||
| 			# Sadly we also delete some link routes, but | ||||
| 			# this cannot be helped | ||||
| @@ -149,6 +157,8 @@ routeflush() | ||||
| 				esac | ||||
| 				route del $flags $dest $netmask $xtra | ||||
| 			done | ||||
| 			# Erase any default dev eth0 routes | ||||
| 			route del default 2>/dev/null | ||||
| 		fi | ||||
| 	else | ||||
| 		route -qn flush | ||||
| @@ -174,7 +184,7 @@ start() | ||||
| { | ||||
| 	local cr=0 r= int= intv= cmd= args= upcmd= | ||||
|  | ||||
| 	if [ -z "$domainname" && -s /etc/defaultdomain ]; then | ||||
| 	if [ -z "$domainname" -a -s /etc/defaultdomain ]; then | ||||
| 		domainname=$(cat /etc/defaultdomain) | ||||
| 	fi | ||||
| 	if [ -n "$domainname" ]; then | ||||
| @@ -243,11 +253,26 @@ start() | ||||
|  | ||||
| 	if [ -n "$defaultroute" ]; then | ||||
| 		ebegin "Setting default route $defaultroute" | ||||
| 		route add default $defaultroute | ||||
| 		eend $? | ||||
| 	elif [ -n "$defaultiproute" ]; then | ||||
| 		ebegin "Setting default route $defaultiproute" | ||||
| 		ip route add default $defaultiproute | ||||
| 		eend $? | ||||
| 	fi | ||||
|  | ||||
| 	if [ -n "$defaultroute6" ]; then | ||||
| 		ebegin "Setting default route $defaultroute6" | ||||
| 		if [ "$RC_UNAME" = Linux ]; then | ||||
| 			route add default gw $defaultroute | ||||
| 			routecmd="route -A inet6 add" | ||||
| 		else | ||||
| 			route add default $defaultroute | ||||
| 			routecmd="route -inet6 add" | ||||
| 		fi | ||||
| 		$routecmd default $defaultroute6 | ||||
| 		eend $? | ||||
| 	elif [ -n "$defaultiproute6" ]; then | ||||
| 		ebegin "Setting default route $defaultiproute6" | ||||
| 		ip -f inet6 route add default $defaultiproute6 | ||||
| 		eend $? | ||||
| 	fi | ||||
|  | ||||
| @@ -276,6 +301,11 @@ stop() | ||||
| 		then | ||||
| 			veinfo "$int" | ||||
| 			runargs /etc/ifdown."$int" "$downcmd" | ||||
| 			if [ -x /sbin/ip ]; then | ||||
| 				# We need to do this, otherwise we may | ||||
| 				# fail to add things correctly on restart | ||||
| 				ip address flush dev "$int" 2>/dev/null | ||||
| 			fi | ||||
| 			ifconfig "$int" down 2>/dev/null | ||||
| 			ifconfig "$int" destroy 2>/dev/null | ||||
| 		fi | ||||
|   | ||||
| @@ -9,7 +9,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} | ||||
| depend() | ||||
| { | ||||
| 	need localmount | ||||
| 	keyword -openvz -prefix -vserver | ||||
| 	keyword -openvz -prefix -vserver -lxc | ||||
| } | ||||
|  | ||||
| _setleds() | ||||
|   | ||||
| @@ -8,7 +8,7 @@ depend() | ||||
| { | ||||
| 	use modules devfs | ||||
| 	need localmount | ||||
| 	keyword -openvz -prefix -vserver | ||||
| 	keyword -openvz -prefix -vserver -lxc | ||||
| } | ||||
|  | ||||
| start() | ||||
|   | ||||
| @@ -7,7 +7,7 @@ description="Mount the root fs read/write" | ||||
| depend() | ||||
| { | ||||
| 	need fsck | ||||
| 	keyword -jail -openvz -prefix -vserver | ||||
| 	keyword -jail -openvz -prefix -vserver -lxc | ||||
| } | ||||
|  | ||||
| start() | ||||
|   | ||||
| @@ -15,32 +15,47 @@ depend() | ||||
| 	keyword -jail -prefix -vserver | ||||
| } | ||||
|  | ||||
| pre_flight_checks() | ||||
| { | ||||
| 	route=route | ||||
| 	[ -s /etc/route.conf ] && return 0 | ||||
|  | ||||
| 	if [ -n "$staticiproute" ]; then | ||||
| 		route="ip route" | ||||
| 		staticroute="$staticiproute" | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| dump_args() | ||||
| { | ||||
| 	# Route configuration file, as used by the NetBSD RC system | ||||
| 	if [ -s /etc/route.conf ]; then | ||||
| 		cat /etc/route.conf | ||||
| 	else | ||||
| 		case "$staticroute" in | ||||
| 		*"$__nl"*) | ||||
| 			echo "$staticroute" | ||||
| 			;; | ||||
| 		*) | ||||
| 			( | ||||
| 		 		set -o noglob | ||||
| 				IFS=';'; set -- $staticroute | ||||
| 				IFS="$__nl"; echo "$*" | ||||
| 			) | ||||
| 			;; | ||||
| 		esac | ||||
| 		return $? | ||||
| 	fi | ||||
|  | ||||
| 	case "$staticroute" in | ||||
| 	*"$__nl"*) | ||||
| 		echo "$staticroute" | ||||
| 		;; | ||||
| 	*) | ||||
| 		( | ||||
| 			set -o noglob | ||||
| 			IFS=';'; set -- $staticroute | ||||
| 			IFS="$__nl"; echo "$*" | ||||
| 		) | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| do_routes() | ||||
| { | ||||
| 	local xtra= | ||||
| 	local xtra= family= | ||||
| 	[ "$RC_UNAME" != Linux ] && xtra=-q | ||||
|  | ||||
| 	ebegin "$1 static routes" | ||||
| 	eindent | ||||
| 	pre_flight_checks | ||||
| 	dump_args | while read args; do | ||||
| 		[ -z "$args" ] && continue | ||||
| 		case "$args" in | ||||
| @@ -53,10 +68,26 @@ do_routes() | ||||
| 			[ $2 = "del" -o $2 = "delete" ] && eval ${args#*-} | ||||
| 			;; | ||||
| 		*) | ||||
| 			route $xtra $2 -$args | ||||
| 			;; | ||||
| 			veinfo "$args" | ||||
| 			case "$route" in | ||||
| 			"ip route") | ||||
| 				ip route $2 $args | ||||
| 				;; | ||||
| 			*) | ||||
| 				# Linux route does cannot work it out ... | ||||
| 				if [ "$RC_UNAME" = Linux ]; then | ||||
| 					case "$args" in | ||||
| 					*:*) family="-A inet6";; | ||||
| 					*) family=;; | ||||
| 					esac | ||||
| 				fi | ||||
| 				route $famly $xtra $2 -$args | ||||
| 				;; | ||||
| 			esac | ||||
| 			veend $? | ||||
| 		esac | ||||
| 	done | ||||
| 	eoutdent | ||||
| 	eend 0 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
| depend() | ||||
| { | ||||
| 	need localmount | ||||
| 	keyword -jail -openvz -prefix -vserver | ||||
| 	keyword -jail -openvz -prefix -vserver -lxc | ||||
| } | ||||
|  | ||||
| start() | ||||
|   | ||||
| @@ -8,7 +8,7 @@ depend() | ||||
| { | ||||
| 	before * | ||||
| 	provide clock | ||||
| 	keyword -openvz -prefix -uml -vserver -xenu | ||||
| 	keyword -openvz -prefix -uml -vserver -xenu -lxc | ||||
| } | ||||
|  | ||||
| # swclock is an OpenRC built in | ||||
| @@ -16,7 +16,7 @@ depend() | ||||
| start() | ||||
| { | ||||
| 	ebegin "Setting the local clock based on last shutdown time" | ||||
| 	swclock | ||||
| 	swclock --warn | ||||
| 	eend $? | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -12,13 +12,21 @@ depend() | ||||
| start() | ||||
| { | ||||
| 	[ -e /etc/sysctl.conf ] || return 0 | ||||
| 	local retval=0 var= comments= | ||||
| 	local retval=0 var= comments= conf= | ||||
| 	ebegin "Configuring kernel parameters" | ||||
| 	while read var comments; do | ||||
| 		case "$var" in | ||||
| 			""|"#"*) continue;; | ||||
| 		esac | ||||
| 		sysctl -w "$var" >/dev/null || retval=1 | ||||
| 	done < /etc/sysctl.conf | ||||
| 	eindent | ||||
| 	for conf in /etc/sysctl.d/*.conf /etc/sysctl.conf; do | ||||
| 		if [ -r "$conf" ]; then | ||||
| 			vebegin "applying $conf" | ||||
| 			while read var comments; do | ||||
| 				case "$var" in | ||||
| 				""|"#"*) continue;; | ||||
| 				esac | ||||
| 				sysctl -w "$var" >/dev/null || retval=1 | ||||
| 			done < "$conf" | ||||
| 			veend $retval | ||||
| 		fi | ||||
| 	done | ||||
| 	eoutdent | ||||
| 	eend $retval "Some errors were encountered" | ||||
| } | ||||
|   | ||||
| @@ -11,8 +11,16 @@ depend() | ||||
|  | ||||
| start() | ||||
| { | ||||
| 	[ -e /etc/sysctl.conf ] || return 0 | ||||
| 	local conf= retval=0 | ||||
| 	ebegin "Configuring kernel parameters" | ||||
| 	sysctl -p >/dev/null | ||||
| 	eend $? "Some errors were encountered" | ||||
| 	eindent | ||||
| 	for conf in /etc/sysctl.d/*.conf /etc/sysctl.conf; do | ||||
| 		if [ -r "$conf" ]; then | ||||
| 			vebegin "applying $conf" | ||||
| 			sysctl -p "$conf" >/dev/null | ||||
| 			veend $? || retval=1 | ||||
| 		fi | ||||
| 	done | ||||
| 	eoutdent | ||||
| 	eend $retval "Some errors were encountered" | ||||
| } | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| .\" SUCH DAMAGE. | ||||
| .\" | ||||
| .Dd July 1, 2009 | ||||
| .Dd November 4, 2009 | ||||
| .Dt RUNSCRIPT 8 SMM | ||||
| .Os OpenRC | ||||
| .Sh NAME | ||||
| @@ -143,6 +143,8 @@ When in a jail, exclude this service from any dependencies. The service can | ||||
| still be run directly. | ||||
| .It Dv -openvz | ||||
| Same as -jail, but for OpenVZ systems. | ||||
| .It Dv -lxc | ||||
| Same as -jail, but for Linux Resource Containers (LXC). | ||||
| .It Dv -shutdown | ||||
| Don't stop this service when shutting the system down. | ||||
| This normally quite safe as remaining daemons will be sent a SIGTERM just | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| .\" SUCH DAMAGE. | ||||
| .\" | ||||
| .Dd October 14, 2009 | ||||
| .Dd December 14, 2009 | ||||
| .Dt START-STOP-DAEMON 8 SMM | ||||
| .Os OpenRC | ||||
| .Sh NAME | ||||
| @@ -136,6 +136,10 @@ option. Only useful when used with daemons that run in the foreground and | ||||
| forced into the background with the | ||||
| .Fl -b , -background | ||||
| option. | ||||
| .It Fl I , -ionice Ar class Ns Op : Ns Ar data | ||||
| Modifies the IO scheduling priority of the daemon. | ||||
| Class can be 0 for none, 1 for real time, 2 for best effort and 3 for idle. | ||||
| Data can be from 0 to 7 inclusive. | ||||
| .It Fl N , -nice Ar level | ||||
| Modifies the scheduling priority of the daemon. | ||||
| .It Fl 1 , -stdout Ar logfile | ||||
|   | ||||
| @@ -56,8 +56,11 @@ dhcpcd_start() | ||||
| 		esac | ||||
| 	done | ||||
|  | ||||
| 	# Add our route metric | ||||
| 	[ "${metric:-0}" != "0" ] && args="${args} -m ${metric}" | ||||
| 	# Add our route metric if not given | ||||
| 	case " $args " in | ||||
| 	*" -m "*) ;; | ||||
| 	*) [ "${metric:-0}" != 0 ] && args="$args -m $metric";; | ||||
| 	esac | ||||
|  | ||||
| 	# Bring up DHCP for this interface | ||||
| 	ebegin "Running dhcpcd" | ||||
|   | ||||
| @@ -42,7 +42,8 @@ _ifindex() | ||||
| _is_wireless() | ||||
| { | ||||
| 	# Support new sysfs layout | ||||
| 	[ -d /sys/class/net/"${IFACE}"/wireless ] && return 0 | ||||
| 	[ -d /sys/class/net/"${IFACE}"/wireless -o \ | ||||
| 		-d /sys/class/net/"${IFACE}"/phy80211 ] && return 0 | ||||
|  | ||||
| 	[ ! -e /proc/net/wireless ] && return 1 | ||||
| 	grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless | ||||
|   | ||||
| @@ -43,7 +43,8 @@ _ifindex() | ||||
| _is_wireless() | ||||
| { | ||||
| 	# Support new sysfs layout | ||||
| 	[ -d /sys/class/net/"${IFACE}"/wireless ] && return 0 | ||||
| 	[ -d /sys/class/net/"${IFACE}"/wireless -o \ | ||||
| 		-d /sys/class/net/"${IFACE}"/phy80211 ] && return 0 | ||||
|  | ||||
| 	[ ! -e /proc/net/wireless ] && return 1 | ||||
| 	grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless | ||||
|   | ||||
| @@ -90,7 +90,7 @@ pppd_pre_start() | ||||
| 	eval passwordset=\$\{password_${IFVAR}-x\} | ||||
| 	if [ -n "${username}" ] \ | ||||
| 	&& [ -n "${password}" -o -z "${passwordset}" ]; then | ||||
| 		opts="${opts} plugin passwordfd.so passwordfd 0" | ||||
| 		opts="plugin passwordfd.so ${opts} passwordfd 0" | ||||
| 	fi | ||||
| 	 | ||||
| 	if ! ${hasdefaultmetric}; then | ||||
| @@ -155,7 +155,7 @@ pppd_pre_start() | ||||
| 			opts="${opts} connect true" | ||||
| 			set -- "$@" "${link}" | ||||
| 		fi | ||||
| 		opts="${opts} plugin $1.so" | ||||
| 		opts="plugin $1.so ${opts}" | ||||
| 		shift | ||||
| 		opts="${opts} $@" | ||||
| 	done | ||||
|   | ||||
							
								
								
									
										5
									
								
								scripts/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								scripts/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| DIR=	${LIBEXECDIR}/bin | ||||
| BIN=	on_ac_power | ||||
|  | ||||
| MK=	../mk | ||||
| include ${MK}/scripts.mk | ||||
							
								
								
									
										33
									
								
								scripts/on_ac_power
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								scripts/on_ac_power
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| #!/bin/sh | ||||
| # Detect AC power or not in a portable way | ||||
| # Copyright (c) 2007-2009 Roy Marples <roy@marples.name> | ||||
|  | ||||
| # Exit 0 if on AC power, 1 if not and 255 if we don't know how to work it out | ||||
| if [ -f /proc/acpi/ac_adapter/AC*/state ]; then | ||||
| 	cat /proc/acpi/ac_adapter/AC*/state | while read line; do | ||||
| 		case "$line" in | ||||
| 		"state:"*"off-line") return 128;; | ||||
| 		esac | ||||
| 	done | ||||
| elif [ -f /proc/pmu/info ]; then | ||||
| 	cat /proc/pmu/info | while read line; do | ||||
| 		case "$line" in | ||||
| 		"AC Power"*": 0") return 128;; | ||||
| 		esac | ||||
| 	done | ||||
| elif type envstat >/dev/null 2>&1; then | ||||
| 	# NetBSD has envstat | ||||
| 	envstat -d acpiacad0 2>/dev/null | while read line; do | ||||
| 		case "$line" in | ||||
| 		"connected:"*"OFF") return 128;; | ||||
| 		esac | ||||
| 	done | ||||
| elif sysctl -q hw.acpi.acline >/dev/null 2>/dev/null; then | ||||
| 	case $(sysctl -n hw.acpi.acline) in | ||||
| 	0) return 1;; | ||||
| 	*) return 0;; | ||||
| 	esac | ||||
| else | ||||
| 	exit 255 | ||||
| fi | ||||
| [ $? != 128 ] | ||||
| @@ -8,14 +8,19 @@ | ||||
| # tmpfs and ramfs are easy, so force one or the other. | ||||
| mount_svcdir() | ||||
| { | ||||
| 	# mount from fstab if we can | ||||
| 	fstabinfo --mount "$RC_SVCDIR" && return 0 | ||||
|  | ||||
| 	local fs= fsopts="-o rw,noexec,nodev,nosuid" | ||||
| 	local devdir="rc-svcdir" x= | ||||
| 	local svcsize=${rc_svcsize:-1024} | ||||
|  | ||||
| 	# Some buggy kernels report tmpfs even when not present :( | ||||
| 	if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then | ||||
| 		fs="tmpfs" | ||||
| 		fsopts="$fsopts,mode=0755,size=${svcsize}k" | ||||
| 	elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then | ||||
| 		mount -n -t tmpfs $fsopts,mode=755,size=${svcsize}k \ | ||||
| 			rc-svcdir "$RC_SVCDIR" && return 0 | ||||
| 	fi | ||||
| 	 | ||||
| 	if grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then | ||||
| 		fs="ramfs" | ||||
| 		# ramfs has no special options | ||||
| 	elif [ -e /dev/ram0 ] \ | ||||
| @@ -32,10 +37,7 @@ mount_svcdir() | ||||
| 		return 1 | ||||
| 	fi | ||||
|  | ||||
| 	# If we have no entry in fstab for $RC_SVCDIR, provide our own | ||||
| 	if ! fstabinfo --mount "$RC_SVCDIR"; then | ||||
| 		mount -n -t "$fs" $fsopts "$devdir" "$RC_SVCDIR" | ||||
| 	fi | ||||
| 	mount -n -t "$fs" $fsopts rc-svcdir "$RC_SVCDIR" | ||||
| } | ||||
|  | ||||
| . "$RC_LIBEXECDIR"/sh/functions.sh | ||||
|   | ||||
| @@ -346,8 +346,9 @@ get_provided(const RC_DEPINFO *depinfo, const char *runlevel, int options) | ||||
| 	    get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STOPPED)) | ||||
| 		return providers; | ||||
|  | ||||
| 	/* Still nothing? OK, list all services */ | ||||
| 	TAILQ_FOREACH(service, dt->services, entries) | ||||
| 	/* Still nothing? OK, list our first provided service. */ | ||||
| 	service = TAILQ_FIRST(dt->services); | ||||
| 	if (service != NULL) | ||||
| 		rc_stringlist_add(providers, service->value); | ||||
|  | ||||
| 	return providers; | ||||
|   | ||||
| @@ -233,6 +233,8 @@ rc_sys(void) | ||||
| 		return RC_SYS_VSERVER; | ||||
| 	else if (exists("/proc/vz/veinfo") && !exists("/proc/vz/version")) | ||||
| 		return RC_SYS_OPENVZ; | ||||
| 	else if (file_regex("/proc/self/cgroup", ":/.+$")) | ||||
| 		return RC_SYS_LXC; | ||||
| 	else if (file_regex("/proc/self/status", | ||||
| 		"envID:[[:space:]]*[1-9]")) | ||||
| 		return RC_SYS_OPENVZ; /* old test */ | ||||
|   | ||||
| @@ -268,6 +268,7 @@ bool rc_service_daemons_crashed(const char *); | ||||
|  * Some services cannot work in these systems, or we do something else. */ | ||||
| #define RC_SYS_JAIL    "JAIL" | ||||
| #define RC_SYS_OPENVZ  "OPENVZ" | ||||
| #define RC_SYS_LXC     "LXC" | ||||
| #define RC_SYS_PREFIX  "PREFIX" | ||||
| #define RC_SYS_UML     "UML" | ||||
| #define RC_SYS_VSERVER "VSERVER" | ||||
|   | ||||
| @@ -47,6 +47,10 @@ | ||||
| #include <sys/time.h> | ||||
| #include <sys/wait.h> | ||||
|  | ||||
| #ifdef __linux__ | ||||
| #include <sys/syscall.h> /* For io priority */ | ||||
| #endif | ||||
|  | ||||
| #include <ctype.h> | ||||
| #include <errno.h> | ||||
| #include <fcntl.h> | ||||
| @@ -104,6 +108,13 @@ static char *changeuser, *ch_root, *ch_dir; | ||||
|  | ||||
| extern char **environ; | ||||
|  | ||||
| #ifdef __linux__ | ||||
| static inline int ioprio_set(int which, int who, int ioprio) | ||||
| { | ||||
| 	return syscall(SYS_ioprio_set, which, who, ioprio); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| static void | ||||
| free_schedulelist(void) | ||||
| { | ||||
| @@ -589,8 +600,9 @@ expand_home(const char *home, const char *path) | ||||
| } | ||||
|  | ||||
| #include "_usage.h" | ||||
| #define getoptstring "KN:PR:Sbc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON | ||||
| #define getoptstring "I:KN:PR:Sbc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON | ||||
| static const struct option longopts[] = { | ||||
| 	{ "ionice",       1, NULL, 'I'}, | ||||
| 	{ "stop",         0, NULL, 'K'}, | ||||
| 	{ "nicelevel",    1, NULL, 'N'}, | ||||
| 	{ "retry",        1, NULL, 'R'}, | ||||
| @@ -619,6 +631,7 @@ static const struct option longopts[] = { | ||||
| 	longopts_COMMON | ||||
| }; | ||||
| static const char * const longopts_help[] = { | ||||
| 	"Set an ionice class:data when starting",  | ||||
| 	"Stop daemon", | ||||
| 	"Set a nicelevel when starting", | ||||
| 	"Retry schedule to use when stopping", | ||||
| @@ -675,7 +688,7 @@ start_stop_daemon(int argc, char **argv) | ||||
| 	char *pidfile = NULL; | ||||
| 	char *retry = NULL; | ||||
| 	int sig = -1; | ||||
| 	int nicelevel = 0; | ||||
| 	int nicelevel = 0, ionicec = -1, ioniced = 0; | ||||
| 	bool background = false; | ||||
| 	bool makepidfile = false; | ||||
| 	bool interpreted = false; | ||||
| @@ -738,6 +751,17 @@ start_stop_daemon(int argc, char **argv) | ||||
| 	while ((opt = getopt_long(argc, argv, getoptstring, longopts, | ||||
| 		    (int *) 0)) != -1) | ||||
| 		switch (opt) { | ||||
| 		case 'I': /* --ionice */ | ||||
| 			if (sscanf(optarg, "%d:%d", &ionicec, &ioniced) == 0) | ||||
| 				eerrorx("%s: invalid ionice `%s'", | ||||
| 				    applet, optarg); | ||||
| 			if (ionicec == 0) | ||||
| 				ioniced = 0; | ||||
| 			else if (ionicec == 3) | ||||
| 				ioniced = 7; | ||||
| 			ionicec <<= 13; /* class shift */ | ||||
| 			break; | ||||
|  | ||||
| 		case 'K':  /* --stop */ | ||||
| 			stop = true; | ||||
| 			break; | ||||
| @@ -1121,6 +1145,14 @@ start_stop_daemon(int argc, char **argv) | ||||
| 				    strerror(errno)); | ||||
| 		} | ||||
|  | ||||
| /* Only linux suports setting an IO priority */ | ||||
| #ifdef __linux__ | ||||
| 		if (ionicec != -1 && | ||||
| 		    ioprio_set(1, mypid, ionicec | ioniced) == -1) | ||||
| 			eerrorx("%s: ioprio_set %d %d: %s", applet, | ||||
| 			    ionicec, ioniced, strerror(errno)); | ||||
| #endif | ||||
|  | ||||
| 		if (ch_root && chroot(ch_root) < 0) | ||||
| 			eerrorx("%s: chroot `%s': %s", | ||||
| 			    applet, ch_root, strerror(errno)); | ||||
|   | ||||
| @@ -52,13 +52,15 @@ extern const char *applet; | ||||
|  | ||||
| #include "_usage.h" | ||||
| #define extraopts "file" | ||||
| #define getoptstring "s" getoptstring_COMMON | ||||
| #define getoptstring "sw" getoptstring_COMMON | ||||
| static const struct option longopts[] = { | ||||
| 	{ "save", 0, NULL, 's' }, | ||||
| 	{ "warn", 0, NULL, 'w' }, | ||||
| 	longopts_COMMON | ||||
| }; | ||||
| static const char * const longopts_help[] = { | ||||
| 	"saves the time", | ||||
| 	"no error if no reference file", | ||||
| 	longopts_help_COMMON | ||||
| }; | ||||
| #include "_usage.c" | ||||
| @@ -66,7 +68,7 @@ static const char * const longopts_help[] = { | ||||
| int | ||||
| swclock(int argc, char **argv) | ||||
| { | ||||
| 	int opt, sflag = 0; | ||||
| 	int opt, sflag = 0, wflag = 0; | ||||
| 	const char *file = RC_SHUTDOWNTIME; | ||||
| 	struct stat sb; | ||||
| 	struct timeval tv; | ||||
| @@ -78,6 +80,9 @@ swclock(int argc, char **argv) | ||||
| 		case 's': | ||||
| 			sflag = 1; | ||||
| 			break; | ||||
| 		case 'w': | ||||
| 			wflag = 1; | ||||
| 			break; | ||||
| 		case_RC_COMMON_GETOPT; | ||||
| 		} | ||||
| 	} | ||||
| @@ -97,8 +102,13 @@ swclock(int argc, char **argv) | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	if (stat(file, &sb) == -1) | ||||
| 		eerrorx("swclock: `%s': %s", file, strerror(errno)); | ||||
| 	if (stat(file, &sb) == -1) { | ||||
| 		if (wflag != 0 && errno == ENOENT) | ||||
| 			ewarn("swclock: `%s': %s", file, strerror(errno)); | ||||
| 		else | ||||
| 			eerrorx("swclock: `%s': %s", file, strerror(errno)); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	tv.tv_sec = sb.st_mtime; | ||||
| 	tv.tv_usec = 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user