diff --git a/Makefile b/Makefile index 486c920..2142249 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ DESC = This package supplies the base system init scripts for sysvinit ARCHIVE := '' SRCDIR := $(PWD)/SRC/initscripts PATCHDIR := $(PWD)/SRC/patches -VERSION := 1.2-0 +VERSION := 1.3-0 include /usr/share/snap/Makefile.snaplinux diff --git a/SNAP/usher b/SNAP/usher index dde5d67..1140a91 100755 --- a/SNAP/usher +++ b/SNAP/usher @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e @@ -7,25 +7,22 @@ case $1 in exit 0 ;; postinst) - if [[ ${TARGET} ]]; then - chroot ${TARGET} update-rc required - else - update-rc required + update-rc required + + if [ ! -f /etc/fstab ]; then + cp /usr/share/initscripts/fstab /etc/fstab fi - if [ ! -f ${TARGET}/etc/modules.conf ]; then - cp ${TARGET}/usr/share/initscripts/modules.conf \ - ${TARGET}/etc/modules.conf + if [ ! -f /etc/modules.conf ]; then + cp /usr/share/initscripts/modules.conf /etc/modules.conf fi - if [ ! -f ${TARGET}/etc/default/halt ]; then - cp ${TARGET}/usr/share/initscripts/halt.default \ - ${TARGET}/etc/default/halt + if [ ! -f /etc/default/halt ]; then + cp /usr/share/initscripts/halt.default /etc/default/halt fi - if [ ! -f ${TARGET}/etc/default/rcS ]; then - cp ${TARGET}/usr/share/initscripts/rcS.default \ - ${TARGET}/etc/default/rcS + if [ ! -f /etc/default/rcS ]; then + cp /usr/share/initscripts/rcS.default /etc/default/rcS fi ;; prerm) diff --git a/SRC/initscripts/Makefile b/SRC/initscripts/Makefile index f5e63ab..8b145e6 100644 --- a/SRC/initscripts/Makefile +++ b/SRC/initscripts/Makefile @@ -22,6 +22,8 @@ files: install -m 755 init.d/swap $(DESTDIR)/etc/init.d/swap install -m 755 init.d/sysctl $(DESTDIR)/etc/init.d/sysctl install -m 755 init-functions $(DESTDIR)/lib/lsb/init-functions + install -m 644 fstab \ + $(DESTDIR)/usr/share/initscripts/fstab install -m 644 halt.default \ $(DESTDIR)/usr/share/initscripts/halt.default install -m 644 modules.conf \ diff --git a/SRC/initscripts/fstab b/SRC/initscripts/fstab new file mode 100644 index 0000000..201ab92 --- /dev/null +++ b/SRC/initscripts/fstab @@ -0,0 +1,4 @@ +# +# /etc/fstab - file system mount definitions +# +# diff --git a/SRC/initscripts/init-functions b/SRC/initscripts/init-functions index 2f14f59..e6bfbbd 100644 --- a/SRC/initscripts/init-functions +++ b/SRC/initscripts/init-functions @@ -1,4 +1,14 @@ -#!/bin/sh +# /lib/lsb/init-functions - shell functions and variables for init scripts + +# +# This sets some environment variables that init scripts can use +# to determine if we're running in a container +# +# Most likely just checking for the presence of $container would +# be enough +# + +export $(sed 's/\x0/\n/g' < /proc/1/environ|grep -ia '^container\|^LXC') COL52="\\033[52G" @@ -54,19 +64,19 @@ log_init_msg() { } log_failure_msg() { - echo -e "$COL52[ FAIL ]" + echo "$COL52[ FAIL ]" return } log_success_msg() { - echo -e "$COL52[ OK ]" + echo "$COL52[ OK ]" return } log_warning_msg() { - echo -e "$COL52[ WARN ]" + echo "$COL52[ WARN ]" return } diff --git a/SRC/initscripts/init.d/checkfs b/SRC/initscripts/init.d/checkfs index e715d78..5643454 100755 --- a/SRC/initscripts/init.d/checkfs +++ b/SRC/initscripts/init.d/checkfs @@ -13,6 +13,8 @@ . /lib/lsb/init-functions +[ -z $container ] || exit 0 + case "$1" in start) if [ -f /fastboot ] || grep -qwi 'fastboot' /proc/cmdline; then diff --git a/SRC/initscripts/init.d/hwclock b/SRC/initscripts/init.d/hwclock index 9a0da51..2091450 100755 --- a/SRC/initscripts/init.d/hwclock +++ b/SRC/initscripts/init.d/hwclock @@ -16,6 +16,8 @@ . /lib/lsb/init-functions +[ -z $container ] || exit 0 + case "$UTC" in 0|n|no) ZONE="--localtime" diff --git a/SRC/initscripts/init.d/mountfs b/SRC/initscripts/init.d/mountfs index 6eb4bfd..dc612cd 100755 --- a/SRC/initscripts/init.d/mountfs +++ b/SRC/initscripts/init.d/mountfs @@ -17,6 +17,8 @@ . /lib/lsb/init-functions +[ -z $container ] || exit 0 + case "$1" in start) log_init_msg "Remounting root file system in read-write mode" diff --git a/SRC/initscripts/init.d/mountvirtfs b/SRC/initscripts/init.d/mountvirtfs index 44c258b..dab6773 100755 --- a/SRC/initscripts/init.d/mountvirtfs +++ b/SRC/initscripts/init.d/mountvirtfs @@ -80,14 +80,6 @@ mountrun () { /run || return 1 fi - mkdir -p /run/lock /run/shm || return 1 - chmod 1777 /run/shm || return 1 - - if grep -q '^utmp:' /etc/group; then - chmod 664 /run/utmp >> /run/utmp - chgrp utmp /run/utmp - fi - return 0 } @@ -105,12 +97,21 @@ case "$1" in start|restart) log_init_msg "Mounting virtual file systems" - for dir in dev pts proc run sys; do - mount$dir || error=1 - done + if [ -z $container ]; then + for dir in dev pts proc run sys; do + mount$dir || error=1 + done + fi + mkdir -p /run/lock /run/shm || error=1 + chmod 1777 /run/shm || error=1 ln -sfn /run/shm /dev/shm + if grep -q '^utmp:' /etc/group; then + chmod 664 /run/utmp >> /run/utmp + chgrp utmp /run/utmp + fi + [ -z $error ] && log_success_msg || log_failure_msg ;; status) diff --git a/SRC/initscripts/init.d/rc b/SRC/initscripts/init.d/rc index 120fcda..ab9af1f 100755 --- a/SRC/initscripts/init.d/rc +++ b/SRC/initscripts/init.d/rc @@ -6,16 +6,16 @@ trap "" INT QUIT TSTP print_snap() { echo " - _ _ - | (_) - ___ _ __ __ _ _ __ | |_ _ __ _ _ _ _ - / __| '_ \ / _' | '_ \| | | '_ \| | | \ \/ / - \__ \ | | | (_| | |_) | | | | | | |_| |> < - |___/_| |_|\__,_| .__/|_|_|_| |_|\__,_/_/\_\ - | | - |_| + _ _ + | (_) + ___ _ __ __ _ _ __ | |_ _ __ _ _ _ _ + / __| '_ \ / _' | '_ \| | | '_ \| | | \ \/ / + \__ \ | | | (_| | |_) | | | | | | |_| |> < + |___/_| |_|\__,_| .__/|_|_|_| |_|\__,_/_/\_\ + | | + |_| - A GNU/Linux System + A GNU/Linux System " } @@ -26,7 +26,7 @@ case "$1" in set -a [ -r /etc/default/rcS ] && . /etc/default/rcS set +a - dmesg -n "${LOGLEVEL:-7}" + [ -z $container ] && dmesg -n "${LOGLEVEL:-7}" print_snap fi