2 Commits

Author SHA1 Message Date
Jay Larson
008c9f186a Attempt at making init scripts container aware 2017-11-26 17:09:27 -06:00
Jay Larson
f977ad5793 Cleaned up init.d/mountfs and added support for ZFS 2017-06-16 10:46:16 -05:00
10 changed files with 95 additions and 96 deletions

View File

@@ -17,7 +17,7 @@ DESC = This package supplies the base system init scripts for sysvinit
ARCHIVE := '' ARCHIVE := ''
SRCDIR := $(PWD)/SRC/initscripts SRCDIR := $(PWD)/SRC/initscripts
PATCHDIR := $(PWD)/SRC/patches PATCHDIR := $(PWD)/SRC/patches
VERSION := 1.1-1 VERSION := 1.3-0
include /usr/share/snap/Makefile.snaplinux include /usr/share/snap/Makefile.snaplinux

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e
@@ -7,25 +7,22 @@ case $1 in
exit 0 exit 0
;; ;;
postinst) postinst)
if [[ ${TARGET} ]]; then update-rc required
chroot ${TARGET} update-rc required
else if [ ! -f /etc/fstab ]; then
update-rc required cp /usr/share/initscripts/fstab /etc/fstab
fi fi
if [ ! -f ${TARGET}/etc/modules.conf ]; then if [ ! -f /etc/modules.conf ]; then
cp ${TARGET}/usr/share/initscripts/modules.conf \ cp /usr/share/initscripts/modules.conf /etc/modules.conf
${TARGET}/etc/modules.conf
fi fi
if [ ! -f ${TARGET}/etc/default/halt ]; then if [ ! -f /etc/default/halt ]; then
cp ${TARGET}/usr/share/initscripts/halt.default \ cp /usr/share/initscripts/halt.default /etc/default/halt
${TARGET}/etc/default/halt
fi fi
if [ ! -f ${TARGET}/etc/default/rcS ]; then if [ ! -f /etc/default/rcS ]; then
cp ${TARGET}/usr/share/initscripts/rcS.default \ cp /usr/share/initscripts/rcS.default /etc/default/rcS
${TARGET}/etc/default/rcS
fi fi
;; ;;
prerm) prerm)

View File

@@ -22,6 +22,8 @@ files:
install -m 755 init.d/swap $(DESTDIR)/etc/init.d/swap 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.d/sysctl $(DESTDIR)/etc/init.d/sysctl
install -m 755 init-functions $(DESTDIR)/lib/lsb/init-functions install -m 755 init-functions $(DESTDIR)/lib/lsb/init-functions
install -m 644 fstab \
$(DESTDIR)/usr/share/initscripts/fstab
install -m 644 halt.default \ install -m 644 halt.default \
$(DESTDIR)/usr/share/initscripts/halt.default $(DESTDIR)/usr/share/initscripts/halt.default
install -m 644 modules.conf \ install -m 644 modules.conf \

4
SRC/initscripts/fstab Normal file
View File

@@ -0,0 +1,4 @@
#
# /etc/fstab - file system mount definitions
#
# <file system> <mount point> <type> <options> <dump> <fsck>

View File

@@ -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" COL52="\\033[52G"
@@ -54,19 +64,19 @@ log_init_msg() {
} }
log_failure_msg() { log_failure_msg() {
echo -e "$COL52[ FAIL ]" echo "$COL52[ FAIL ]"
return return
} }
log_success_msg() { log_success_msg() {
echo -e "$COL52[ OK ]" echo "$COL52[ OK ]"
return return
} }
log_warning_msg() { log_warning_msg() {
echo -e "$COL52[ WARN ]" echo "$COL52[ WARN ]"
return return
} }

View File

@@ -13,6 +13,8 @@
. /lib/lsb/init-functions . /lib/lsb/init-functions
[ -z $container ] || exit 0
case "$1" in case "$1" in
start) start)
if [ -f /fastboot ] || grep -qwi 'fastboot' /proc/cmdline; then if [ -f /fastboot ] || grep -qwi 'fastboot' /proc/cmdline; then

View File

@@ -16,6 +16,8 @@
. /lib/lsb/init-functions . /lib/lsb/init-functions
[ -z $container ] || exit 0
case "$UTC" in case "$UTC" in
0|n|no) 0|n|no)
ZONE="--localtime" ZONE="--localtime"

View File

@@ -1,17 +1,4 @@
#!/bin/sh #!/bin/sh
########################################################################
# Begin mountfs
#
# Description : File System Mount Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: $local_fs # Provides: $local_fs
# Required-Start: udev checkfs # Required-Start: udev checkfs
@@ -20,67 +7,61 @@
# Should-Stop: # Should-Stop:
# Default-Start: S # Default-Start: S
# Default-Stop: 0 6 # Default-Stop: 0 6
# Short-Description: Mounts/unmounts local filesystems defined in /etc/fstab. # Short-Description: Mounts/unmounts local filesystems
# Description: Remounts root filesystem read/write and mounts all # Description: Remounts root filesystem read/write and mounts all
# remaining local filesystems defined in /etc/fstab on # remaining local filesystems defined in /etc/fstab or
# start. Remounts root filesystem read-only and unmounts # in ZFS. Remounts root filesystem read-only and unmounts
# remaining filesystems on stop. # remaining filesystems on stop.
# X-LFS-Provided-By: LFS
# X-Required: true # X-Required: true
### END INIT INFO ### END INIT INFO
. /lib/lsb/init-functions . /lib/lsb/init-functions
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! [ -z $container ] || exit 0
#
# needs work!!
# probably need to split up
# separate scripts for / and
# network filesystems
#
# Ok, so network filesystems
# init scripts should be included
# as part of the package. This
# script should only be for
# standard local filesystems
#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
case "$1" in case "$1" in
start) start)
log_init_msg "Remounting root file system in read-write mode" log_init_msg "Remounting root file system in read-write mode"
mount -o remount,rw / >/dev/null && log_success_msg || log_failure_msg mount -o remount,rw / >/dev/null && log_success_msg || log_failure_msg
# Remove fsck-related file system watermarks. if [ -f /fastboot ]; then
rm -f /fastboot /forcefsck log_init_msg "Clearing /fastboot"
rm /fastboot && log_success_msg || log_failure_msg
fi
# Make sure /dev/pts exists if [ -f /forcefsck ]; then
# mkdir -p /dev/pts log_init_msg "Clearing /forcefsk"
rm /forcefsck && log_success_msg || log_failure_msg
fi
# This will mount all filesystems that do not have _netdev in if [ -x /sbin/zpool ]; then
# their option list. _netdev denotes a network filesystem. if zpool list rpool 2>&1 > /dev/null; then
log_init_msg "Mounting ZFS file systems"
zfs mount -a && log_success_msg || log_failure_msg
fi
fi
log_init_msg "Mounting remaining file systems" log_init_msg "Mounting remaining file systems"
mount -a -O no_netdev >/dev/null && log_success_msg || log_failure_msg mount -a -O no_netdev >/dev/null && log_success_msg || log_failure_msg
exit $failed ;;
;;
stop) stop)
# Don't unmount virtual file systems like /run log_init_msg "Unmounting all file systems"
log_init_msg "Unmounting all file systems" umount -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts \
umount -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts >/dev/null && \ >/dev/null && log_success_msg || log_failure_msg
log_success_msg || log_failure_msg
# Make sure / is mounted read only (umount bug) if [ -x /sbin/zpool ]; then
mount -o remount,ro / if zpool list rpool 2>&1 > /dev/null; then
log_init_msg "Unmounting ZFS file systems"
zfs umount -a && log_success_msg || log_failure_msg
fi
fi
# Make all LVM volume groups unavailable, if appropriate mount -o remount,ro /
# This fails if swap or / are on an LVM partition ;;
#if [ -x /sbin/vgchange ]; then /sbin/vgchange -an > /dev/null; fi
;;
*) *)
echo "Usage: $0 [start|stop]" echo "Usage: $0 [start|stop]"
exit 1 exit 1
;; ;;
esac esac
exit 0 exit 0

View File

@@ -80,14 +80,6 @@ mountrun () {
/run || return 1 /run || return 1
fi 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 return 0
} }
@@ -105,12 +97,21 @@ case "$1" in
start|restart) start|restart)
log_init_msg "Mounting virtual file systems" log_init_msg "Mounting virtual file systems"
for dir in dev pts proc run sys; do if [ -z $container ]; then
mount$dir || error=1 for dir in dev pts proc run sys; do
done 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 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 [ -z $error ] && log_success_msg || log_failure_msg
;; ;;
status) status)

View File

@@ -6,16 +6,16 @@ trap "" INT QUIT TSTP
print_snap() { print_snap() {
echo " echo "
_ _ _ _
| (_) | (_)
___ _ __ __ _ _ __ | |_ _ __ _ _ _ _ ___ _ __ __ _ _ __ | |_ _ __ _ _ _ _
/ __| '_ \ / _' | '_ \| | | '_ \| | | \ \/ / / __| '_ \ / _' | '_ \| | | '_ \| | | \ \/ /
\__ \ | | | (_| | |_) | | | | | | |_| |> < \__ \ | | | (_| | |_) | | | | | | |_| |> <
|___/_| |_|\__,_| .__/|_|_|_| |_|\__,_/_/\_\ |___/_| |_|\__,_| .__/|_|_|_| |_|\__,_/_/\_\
| | | |
|_| |_|
A GNU/Linux System A GNU/Linux System
" "
} }
@@ -26,7 +26,7 @@ case "$1" in
set -a set -a
[ -r /etc/default/rcS ] && . /etc/default/rcS [ -r /etc/default/rcS ] && . /etc/default/rcS
set +a set +a
dmesg -n "${LOGLEVEL:-7}" [ -z $container ] && dmesg -n "${LOGLEVEL:-7}"
print_snap print_snap
fi fi