summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-03-13 15:50:34 +0100
committerTom Gundersen <teg@jklm.no>2012-03-13 15:50:34 +0100
commitb49cc7be1be791318f57d2941999368ae58636b7 (patch)
tree43393eacaa669a4ff09eff9d1fd867c1c089cec1
parentcb18be3f401a2c693d66a9417e479ed74e17c2f0 (diff)
parent9f75591c8a56ba7ec1ea20cfe16dd10a83c65503 (diff)
Merge remote-tracking branch 'seblu/master'
Conflicts: Makefile
-rw-r--r--Makefile4
-rwxr-xr-xarch-binfmt36
-rwxr-xr-xarch-sysctl2
-rw-r--r--functions10
-rwxr-xr-xrc.d1
-rwxr-xr-xrc.multi3
-rwxr-xr-xrc.sysinit5
7 files changed, 47 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index a429ddd..46ce5b0 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,8 @@ DIRS := \
/usr/sbin \
/etc/tmpfiles.d \
/usr/lib/tmpfiles.d \
+ /etc/binfmt.d \
+ /usr/lib/binfmt.d \
/etc/sysctl.d \
/usr/lib/sysctl.d \
/usr/lib/initscripts \
@@ -39,7 +41,7 @@ install: installdirs doc
install -m755 -t $(DESTDIR)/usr/sbin rc.d
install -m644 -t $(DESTDIR)/usr/share/man/man5 $(filter %.5, $(MAN_PAGES))
install -m644 -t $(DESTDIR)/usr/share/man/man8 $(filter %.8, $(MAN_PAGES))
- install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl
+ install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl arch-binfmt
install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.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
diff --git a/arch-binfmt b/arch-binfmt
new file mode 100755
index 0000000..6931843
--- /dev/null
+++ b/arch-binfmt
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# /usr/lib/initscripts/arch-binfmt
+#
+# Configure additional binary formats at boot
+#
+
+shopt -s nullglob
+
+declare -a binfmt_d=(
+ /usr/lib/binfmt.d/*.conf
+ /etc/binfmt.d/*.conf
+ /run/binfmt.d/*.conf
+)
+declare -A fragments
+
+# check binfmt_misc filesystem is mounted
+mountpoint -q /proc/sys/fs/binfmt_misc ||
+ { echo "/proc/sys/fs/binfmt_misc is not mounted"; exit 1;}
+
+# files declared later in the sysctl_d array will override earlier
+# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'.
+for path in "${@:-${binfmt_d[@]}}"; do
+ [[ -f $path ]] && fragments[${path##*/}]=$path
+done
+
+for path in "${fragments[@]}"; do
+ while read -r line; do
+ [[ ${line:0:1} == '#' ]] && continue
+ printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register
+ done < "$path"
+done
+
+:
+
+# vim: set ts=2 sw=2 noet:
diff --git a/arch-sysctl b/arch-sysctl
index 4c54217..e27369d 100755
--- a/arch-sysctl
+++ b/arch-sysctl
@@ -18,7 +18,7 @@ declare -A fragments
# files declared later in the sysctl_d array will override earlier
# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'.
-for path in "${sysctl_d[@]}"; do
+for path in "${@:-${sysctl_d[@]}}"; do
[[ -f $path ]] && fragments[${path##*/}]=$path
done
diff --git a/functions b/functions
index 3593892..f8a7acd 100644
--- a/functions
+++ b/functions
@@ -651,15 +651,5 @@ for f in /etc/rc.d/functions.d/*; do
[[ -e $f ]] && . "$f"
done
-# Exit current shell if user is not root
-need_root() {
- (( EUID )) && printf 'You need to be root.\n' && exit 1
-}
-
-# Quit script if it's not running by root
-# This can be disabled in scripts sourcing functions by setting NEED_ROOT=0
-# A local call to need_root can be done to ensure part of script need root privilege
-(( NEED_ROOT )) && need_root
-
# End of file
# vim: set ts=2 sw=2 noet:
diff --git a/rc.d b/rc.d
index 115dc05..0cfbdaf 100755
--- a/rc.d
+++ b/rc.d
@@ -1,6 +1,5 @@
#!/bin/bash
-NEED_ROOT=0 # this script can be run without be root
. /etc/rc.conf
. /etc/rc.d/functions
diff --git a/rc.multi b/rc.multi
index 19623d8..20ed9bc 100755
--- a/rc.multi
+++ b/rc.multi
@@ -11,6 +11,9 @@ run_hook multi_start
# Load sysctl config files
[[ -x /usr/lib/initscripts/arch-sysctl ]] && /usr/lib/initscripts/arch-sysctl
+# Load additional binary formats
+[[ -x /usr/lib/initscripts/arch-binfmt ]] && /usr/lib/initscripts/arch-binfmt
+
# Start daemons
for daemon in "${DAEMONS[@]}"; do
case ${daemon:0:1} in
diff --git a/rc.sysinit b/rc.sysinit
index b38d350..9880995 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -11,8 +11,11 @@ printhl "Arch Linux\n"
printhl "${C_H2}http://www.archlinux.org"
printsep
-# mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems)
+# mount the api filesystems
+# /proc, /proc/sys/fs/binfmt_misc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm
mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev
+mountpoint -q /proc/sys/fs/binfmt_misc ||
+ mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc
mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev
mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev
mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid