From 321b7dc88878ff24a48065048e01957d440a81c5 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 28 Oct 2008 16:49:38 +0800 Subject: fastboot: initscripts-openmoko: Replacement for initscripts. Move the common files into 'files' dir and keep Openmoko specific files under initscripts-openmoko. 'finish' was renamed to 'finish.sh', so various recipes have to be modified as well. --- packages/initscripts/files/arm/alignment.sh | 6 + packages/initscripts/files/devpts | 5 + packages/initscripts/files/finish.sh | 6 + packages/initscripts/files/functions | 17 ++ packages/initscripts/files/halt | 25 +++ packages/initscripts/files/hostname.sh | 11 + packages/initscripts/files/reboot | 11 + packages/initscripts/files/rmnologin | 14 ++ packages/initscripts/files/save-rtc.sh | 5 + packages/initscripts/files/sendsigs | 17 ++ packages/initscripts/files/umountfs | 18 ++ packages/initscripts/files/umountnfs.sh | 28 +++ packages/initscripts/files/volatiles | 40 ++++ .../initscripts/initscripts-1.0/arm/alignment.sh | 6 - packages/initscripts/initscripts-1.0/devpts | 5 - packages/initscripts/initscripts-1.0/finish | 6 - packages/initscripts/initscripts-1.0/functions | 17 -- packages/initscripts/initscripts-1.0/halt | 25 --- packages/initscripts/initscripts-1.0/hostname.sh | 11 - packages/initscripts/initscripts-1.0/reboot | 11 - packages/initscripts/initscripts-1.0/rmnologin | 14 -- packages/initscripts/initscripts-1.0/save-rtc.sh | 5 - packages/initscripts/initscripts-1.0/sendsigs | 17 -- packages/initscripts/initscripts-1.0/umountfs | 18 -- packages/initscripts/initscripts-1.0/umountnfs.sh | 28 --- packages/initscripts/initscripts-1.0/volatiles | 40 ---- .../initscripts/initscripts-openmoko/bootmisc.sh | 47 ++++ packages/initscripts/initscripts-openmoko/campgsm | 128 +++++++++++ .../initscripts/initscripts-openmoko/checkroot.sh | 43 ++++ .../initscripts-openmoko/led-trigger.sh | 6 + .../initscripts/initscripts-openmoko/mountall.sh | 52 +++++ .../initscripts-openmoko/mountdevsubfs.sh | 14 ++ .../initscripts-openmoko/mountkernfs.sh | 33 +++ .../initscripts/initscripts-openmoko/mountnfs.sh | 87 ++++++++ .../initscripts-openmoko/populate-volatile.sh | 248 +++++++++++++++++++++ packages/initscripts/initscripts-openmoko_1.0.bb | 111 +++++++++ .../initscripts/initscripts-openprotium_1.0.bb | 4 +- packages/initscripts/initscripts-slugos_1.0.bb | 4 +- packages/initscripts/initscripts_1.0.bb | 6 +- 39 files changed, 979 insertions(+), 210 deletions(-) create mode 100644 packages/initscripts/files/arm/alignment.sh create mode 100644 packages/initscripts/files/devpts create mode 100644 packages/initscripts/files/finish.sh create mode 100644 packages/initscripts/files/functions create mode 100644 packages/initscripts/files/halt create mode 100644 packages/initscripts/files/hostname.sh create mode 100644 packages/initscripts/files/reboot create mode 100644 packages/initscripts/files/rmnologin create mode 100644 packages/initscripts/files/save-rtc.sh create mode 100644 packages/initscripts/files/sendsigs create mode 100644 packages/initscripts/files/umountfs create mode 100644 packages/initscripts/files/umountnfs.sh create mode 100644 packages/initscripts/files/volatiles delete mode 100644 packages/initscripts/initscripts-1.0/arm/alignment.sh delete mode 100644 packages/initscripts/initscripts-1.0/devpts delete mode 100755 packages/initscripts/initscripts-1.0/finish delete mode 100644 packages/initscripts/initscripts-1.0/functions delete mode 100755 packages/initscripts/initscripts-1.0/halt delete mode 100755 packages/initscripts/initscripts-1.0/hostname.sh delete mode 100755 packages/initscripts/initscripts-1.0/reboot delete mode 100755 packages/initscripts/initscripts-1.0/rmnologin delete mode 100644 packages/initscripts/initscripts-1.0/save-rtc.sh delete mode 100755 packages/initscripts/initscripts-1.0/sendsigs delete mode 100755 packages/initscripts/initscripts-1.0/umountfs delete mode 100755 packages/initscripts/initscripts-1.0/umountnfs.sh delete mode 100644 packages/initscripts/initscripts-1.0/volatiles create mode 100644 packages/initscripts/initscripts-openmoko/bootmisc.sh create mode 100644 packages/initscripts/initscripts-openmoko/campgsm create mode 100644 packages/initscripts/initscripts-openmoko/checkroot.sh create mode 100644 packages/initscripts/initscripts-openmoko/led-trigger.sh create mode 100644 packages/initscripts/initscripts-openmoko/mountall.sh create mode 100644 packages/initscripts/initscripts-openmoko/mountdevsubfs.sh create mode 100644 packages/initscripts/initscripts-openmoko/mountkernfs.sh create mode 100644 packages/initscripts/initscripts-openmoko/mountnfs.sh create mode 100644 packages/initscripts/initscripts-openmoko/populate-volatile.sh create mode 100644 packages/initscripts/initscripts-openmoko_1.0.bb (limited to 'packages/initscripts') diff --git a/packages/initscripts/files/arm/alignment.sh b/packages/initscripts/files/arm/alignment.sh new file mode 100644 index 0000000000..32a9eaace2 --- /dev/null +++ b/packages/initscripts/files/arm/alignment.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ -e /proc/cpu/alignment ] && ! [ $(uname -m) = "armv7l" ]; then + echo "3" > /proc/cpu/alignment +fi + diff --git a/packages/initscripts/files/devpts b/packages/initscripts/files/devpts new file mode 100644 index 0000000000..e10e371662 --- /dev/null +++ b/packages/initscripts/files/devpts @@ -0,0 +1,5 @@ +# GID of the `tty' group +TTYGRP=5 + +# Set to 600 to have `mesg n' be the default +TTYMODE=620 diff --git a/packages/initscripts/files/finish.sh b/packages/initscripts/files/finish.sh new file mode 100644 index 0000000000..4f9f75f47c --- /dev/null +++ b/packages/initscripts/files/finish.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +if ! test -e /etc/.configured; then + > /etc/.configured +fi + diff --git a/packages/initscripts/files/functions b/packages/initscripts/files/functions new file mode 100644 index 0000000000..fb9a914e4d --- /dev/null +++ b/packages/initscripts/files/functions @@ -0,0 +1,17 @@ +# -*-Shell-script-*- +# +# functions This file contains functions to be used by most or all +# shell scripts in the /etc/init.d directory. +# + +machine_id() { # return the machine ID + awk 'BEGIN { FS=": " } /Hardware/ { gsub(" ", "_", $2); print tolower($2) } ' /etc/timestamp diff --git a/packages/initscripts/files/sendsigs b/packages/initscripts/files/sendsigs new file mode 100644 index 0000000000..c62a5cd37d --- /dev/null +++ b/packages/initscripts/files/sendsigs @@ -0,0 +1,17 @@ +#! /bin/sh +# +# sendsigs Kill all remaining processes. +# +# Version: @(#)sendsigs 2.75 22-Jun-1998 miquels@cistron.nl +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# Kill all processes. +echo "Sending all processes the TERM signal..." +killall5 -15 +sleep 5 +echo "Sending all processes the KILL signal..." +killall5 -9 + +: exit 0 diff --git a/packages/initscripts/files/umountfs b/packages/initscripts/files/umountfs new file mode 100644 index 0000000000..ec75b0c4a4 --- /dev/null +++ b/packages/initscripts/files/umountfs @@ -0,0 +1,18 @@ +#! /bin/sh +# +# umountfs Turn off swap and unmount all local filesystems. +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +echo "Deactivating swap..." +swapoff -a + +# We leave /proc mounted. +echo "Unmounting local filesystems..." +mount -o remount,ro /mnt/ram +umount -f -a -r + +mount -o remount,ro / + +: exit 0 diff --git a/packages/initscripts/files/umountnfs.sh b/packages/initscripts/files/umountnfs.sh new file mode 100644 index 0000000000..f5fe48aa74 --- /dev/null +++ b/packages/initscripts/files/umountnfs.sh @@ -0,0 +1,28 @@ +#! /bin/sh +# +# umountnfs.sh Unmount all network filesystems. +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# Write a reboot record to /var/log/wtmp before unmounting +halt -w + +echo "Unmounting remote filesystems..." + +test -f /etc/fstab && ( + +# +# Read through fstab line by line and unount network file systems +# +while read device mountpt fstype options +do + if test "$fstype" = nfs || test "$fstype" = smbfs || test "$fstype" = ncpfs + then + umount -f $mountpt + fi +done +) < /etc/fstab + +: exit 0 + diff --git a/packages/initscripts/files/volatiles b/packages/initscripts/files/volatiles new file mode 100644 index 0000000000..fbcc858226 --- /dev/null +++ b/packages/initscripts/files/volatiles @@ -0,0 +1,40 @@ +# This configuration file lists filesystem objects that should get verified +# during startup and be created if missing. +# +# Every line must either be a comment starting with # +# or a definition of format: +# +# where the items are separated by whitespace ! +# +# : d|f|l : (d)irectory|(f)ile|(l)ink +# +# A linking example: +# l root root 0777 /var/test /tmp/testfile +# f root root 0644 /var/test none +# +# Understanding links: +# When populate-volatile is to verify/create a directory or file, it will first +# check it's existence. If a link is found to exist in the place of the target, +# the path of the target is replaced with the target the link points to. +# Thus, if a link is in the place to be verified, the object will be created +# in the place the link points to instead. +# This explains the order of "link before object" as in the example above, where +# a link will be created at /var/test pointing to /tmp/testfile and due to this +# link the file defined as /var/test will actually be created as /tmp/testfile. +d root root 0755 /var/volatile/cache none +d root root 1777 /var/volatile/lock none +d root root 0755 /var/volatile/log none +d root root 0755 /var/volatile/run none +d root root 1777 /var/volatile/tmp none +l root root 0755 /var/cache /var/volatile/cache +l root root 1777 /var/lock /var/volatile/lock +l root root 0755 /var/log /var/volatile/log +l root root 0755 /var/run /var/volatile/run +l root root 1777 /var/tmp /var/volatile/tmp +d root root 0755 /var/lock/subsys none +f root root 0664 /var/log/wtmp none +f root root 0644 /var/log/lastlog none +f root root 0664 /var/run/utmp none +l root root 0644 /etc/resolv.conf /var/run/resolv.conf +f root root 0644 /var/run/resolv.conf none + diff --git a/packages/initscripts/initscripts-1.0/arm/alignment.sh b/packages/initscripts/initscripts-1.0/arm/alignment.sh deleted file mode 100644 index 32a9eaace2..0000000000 --- a/packages/initscripts/initscripts-1.0/arm/alignment.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ -e /proc/cpu/alignment ] && ! [ $(uname -m) = "armv7l" ]; then - echo "3" > /proc/cpu/alignment -fi - diff --git a/packages/initscripts/initscripts-1.0/devpts b/packages/initscripts/initscripts-1.0/devpts deleted file mode 100644 index 4a0978b404..0000000000 --- a/packages/initscripts/initscripts-1.0/devpts +++ /dev/null @@ -1,5 +0,0 @@ -# GID of the `tty' group -TTYGRP=5 - -# Set to 600 to have `mesg n' be the default -TTYMODE=620 diff --git a/packages/initscripts/initscripts-1.0/finish b/packages/initscripts/initscripts-1.0/finish deleted file mode 100755 index 4f9f75f47c..0000000000 --- a/packages/initscripts/initscripts-1.0/finish +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if ! test -e /etc/.configured; then - > /etc/.configured -fi - diff --git a/packages/initscripts/initscripts-1.0/functions b/packages/initscripts/initscripts-1.0/functions deleted file mode 100644 index fb9a914e4d..0000000000 --- a/packages/initscripts/initscripts-1.0/functions +++ /dev/null @@ -1,17 +0,0 @@ -# -*-Shell-script-*- -# -# functions This file contains functions to be used by most or all -# shell scripts in the /etc/init.d directory. -# - -machine_id() { # return the machine ID - awk 'BEGIN { FS=": " } /Hardware/ { gsub(" ", "_", $2); print tolower($2) } ' /etc/timestamp diff --git a/packages/initscripts/initscripts-1.0/sendsigs b/packages/initscripts/initscripts-1.0/sendsigs deleted file mode 100755 index c62a5cd37d..0000000000 --- a/packages/initscripts/initscripts-1.0/sendsigs +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/sh -# -# sendsigs Kill all remaining processes. -# -# Version: @(#)sendsigs 2.75 22-Jun-1998 miquels@cistron.nl -# - -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -# Kill all processes. -echo "Sending all processes the TERM signal..." -killall5 -15 -sleep 5 -echo "Sending all processes the KILL signal..." -killall5 -9 - -: exit 0 diff --git a/packages/initscripts/initscripts-1.0/umountfs b/packages/initscripts/initscripts-1.0/umountfs deleted file mode 100755 index ec75b0c4a4..0000000000 --- a/packages/initscripts/initscripts-1.0/umountfs +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/sh -# -# umountfs Turn off swap and unmount all local filesystems. -# - -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -echo "Deactivating swap..." -swapoff -a - -# We leave /proc mounted. -echo "Unmounting local filesystems..." -mount -o remount,ro /mnt/ram -umount -f -a -r - -mount -o remount,ro / - -: exit 0 diff --git a/packages/initscripts/initscripts-1.0/umountnfs.sh b/packages/initscripts/initscripts-1.0/umountnfs.sh deleted file mode 100755 index f5fe48aa74..0000000000 --- a/packages/initscripts/initscripts-1.0/umountnfs.sh +++ /dev/null @@ -1,28 +0,0 @@ -#! /bin/sh -# -# umountnfs.sh Unmount all network filesystems. -# - -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -# Write a reboot record to /var/log/wtmp before unmounting -halt -w - -echo "Unmounting remote filesystems..." - -test -f /etc/fstab && ( - -# -# Read through fstab line by line and unount network file systems -# -while read device mountpt fstype options -do - if test "$fstype" = nfs || test "$fstype" = smbfs || test "$fstype" = ncpfs - then - umount -f $mountpt - fi -done -) < /etc/fstab - -: exit 0 - diff --git a/packages/initscripts/initscripts-1.0/volatiles b/packages/initscripts/initscripts-1.0/volatiles deleted file mode 100644 index fbcc858226..0000000000 --- a/packages/initscripts/initscripts-1.0/volatiles +++ /dev/null @@ -1,40 +0,0 @@ -# This configuration file lists filesystem objects that should get verified -# during startup and be created if missing. -# -# Every line must either be a comment starting with # -# or a definition of format: -# -# where the items are separated by whitespace ! -# -# : d|f|l : (d)irectory|(f)ile|(l)ink -# -# A linking example: -# l root root 0777 /var/test /tmp/testfile -# f root root 0644 /var/test none -# -# Understanding links: -# When populate-volatile is to verify/create a directory or file, it will first -# check it's existence. If a link is found to exist in the place of the target, -# the path of the target is replaced with the target the link points to. -# Thus, if a link is in the place to be verified, the object will be created -# in the place the link points to instead. -# This explains the order of "link before object" as in the example above, where -# a link will be created at /var/test pointing to /tmp/testfile and due to this -# link the file defined as /var/test will actually be created as /tmp/testfile. -d root root 0755 /var/volatile/cache none -d root root 1777 /var/volatile/lock none -d root root 0755 /var/volatile/log none -d root root 0755 /var/volatile/run none -d root root 1777 /var/volatile/tmp none -l root root 0755 /var/cache /var/volatile/cache -l root root 1777 /var/lock /var/volatile/lock -l root root 0755 /var/log /var/volatile/log -l root root 0755 /var/run /var/volatile/run -l root root 1777 /var/tmp /var/volatile/tmp -d root root 0755 /var/lock/subsys none -f root root 0664 /var/log/wtmp none -f root root 0644 /var/log/lastlog none -f root root 0664 /var/run/utmp none -l root root 0644 /etc/resolv.conf /var/run/resolv.conf -f root root 0644 /var/run/resolv.conf none - diff --git a/packages/initscripts/initscripts-openmoko/bootmisc.sh b/packages/initscripts/initscripts-openmoko/bootmisc.sh new file mode 100644 index 0000000000..4511e12fc1 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/bootmisc.sh @@ -0,0 +1,47 @@ +# +# bootmisc.sh Miscellaneous things to be done during bootup. +# + +. /etc/default/rcS +# +# Put a nologin file in /etc to prevent people from logging in before +# system startup is complete. +# +if test "$DELAYLOGIN" = yes +then + echo "System bootup in progress - please wait" > /etc/nologin + cp /etc/nologin /etc/nologin.boot +fi + +# +# Update /etc/motd. +# +if test "$EDITMOTD" != no +then + uname -a > /etc/motd.tmp + sed 1d /etc/motd >> /etc/motd.tmp + mv /etc/motd.tmp /etc/motd +fi + +# +# Update dynamic library cache +# +#/sbin/ldconfig + +# Set the system clock from hardware clock +# If the timestamp is 1 day or more recent than the current time, +# use the timestamp instead. +[ "$UTC" = yes ] || /etc/init.d/hwclock.sh start + +if ! test -f /etc/.configured && test -e /etc/timestamp +then + SYSTEMDATE=`date "+%Y%m%d"` + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'` + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)` + if [ $NEEDUPDATE -eq 1 ]; then + date `cat /etc/timestamp` + /etc/init.d/hwclock.sh stop + fi +fi + +: exit 0 diff --git a/packages/initscripts/initscripts-openmoko/campgsm b/packages/initscripts/initscripts-openmoko/campgsm new file mode 100644 index 0000000000..5be67086c2 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/campgsm @@ -0,0 +1,128 @@ +#!/bin/sh + +VERBOSE=no + +PIDS=`pidof -x "$0"` + +# make sure pidof sees us +if [ -z "$PIDS" ]; then + exec "$0" + exit 1 +fi + +GSM_DEVICE="/dev/ttySAC0" +GSM_POWER="/sys/devices/platform/neo1973-pm-gsm.0/power_on" +GSM_RESET="/sys/devices/platform/neo1973-pm-gsm.0/reset" + +GSM_COMMANDS="Z E0V1 +CFUN=1 +COPS=0" + +gsm_running () { + if [ "$PIDS" != "$$" ]; then + return 0 + else + return 1 + fi +} + +gsm_send () { + cmd="$1" + echo -ne "AT${cmd}\r" > "$GSM_DEVICE" +} + +# this function might block forever +gsm_wait () { + ret="UNKNOWN" + + while read status; do + case "$status" in + OK*) + ret="OK" + ;; + ERROR*) + ret="ERROR" + ;; + *) + ret="UNKNOWN" + ;; + esac + if [ "x$ret" != "xUNKNOWN" ]; then + break + fi + done < "$GSM_DEVICE" + + if [ "x$ret" != "xOK" ]; then + return 1 + fi + + return 0 +} + +gsm_setup () { + [ $VERBOSE == "yes" ] && echo -n "Powering up GSM modem..." + echo 0 > "$GSM_POWER"; sleep 1 + echo 1 > "$GSM_POWER"; sleep 1 + echo 1 > "$GSM_RESET"; sleep 1 + echo 0 > "$GSM_RESET"; sleep 4 + [ $VERBOSE == "yes" ] && echo "done" + + stty -F "$GSM_DEVICE" cooked -opost -echo crtscts 115200 +} + +gsm_wakeup () { + [ $VERBOSE == "yes" ] && echo "Waking up GSM modem" + + # there is at most one OK/ERROR even if we send multiple commands + gsm_send "" + gsm_send "" + gsm_send "" + + if gsm_wait; then + [ $VERBOSE == "yes" ] && echo "GSM modem awake" + return 0 + else + echo "failed to wake up GSM modem" + return 1 + fi +} + +start () { + gsm_setup + + if gsm_wakeup; then + for cmd in $GSM_COMMANDS + do + [ $VERBOSE == "yes" ] && echo "Sending AT$cmd" + gsm_send "$cmd" + + if ! gsm_wait; then + echo "AT$cmd failed" + break + fi + done + fi +} + +set -e + +case "$1" in + start) + if gsm_running; then + echo "Another instance is already running" + exit 1 + fi + + start & + ;; + stop) + if gsm_running; then + PIDS=`pidof -x -o "$$" "$0"` + echo -n "Stopping other instances..." + kill $PIDS + echo "done" + fi + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 + ;; +esac diff --git a/packages/initscripts/initscripts-openmoko/checkroot.sh b/packages/initscripts/initscripts-openmoko/checkroot.sh new file mode 100644 index 0000000000..029ae9b405 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/checkroot.sh @@ -0,0 +1,43 @@ +# +# checkroot.sh Check to root filesystem. +# +# Version: @(#)checkroot.sh 2.84 25-Jan-2002 miquels@cistron.nl +# + +. /etc/default/rcS + +# +# Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to be spawned +# from this script *before anything else* with a timeout, like SCO does. +# +test "$SULOGIN" = yes && sulogin -t 30 $CONSOLE + +# +# If the root filesystem was not marked as read-only in /etc/fstab, +# remount the rootfs rw but do not try to change mtab because it +# is on a ro fs until the remount succeeded. Then clean up old mtabs +# and finally write the new mtab. +# This part is only needed if the rootfs was mounted ro. +# +ROOTFSDEV="/dev/root" +if grep -q "^$ROOTFSDEV .* rw" /proc/mounts; then + echo "Root filesystem already read-write, not remounting" +else + rootmode=rw + + echo "Remounting root file system..." + mount -n -o remount,noatime,$rootmode / + if test "$rootmode" = rw + then + if test ! -L /etc/mtab + then + rm -f /etc/mtab~ /etc/nologin + : > /etc/mtab + fi + mount -f -o remount / + mount -f /proc + test "$devfs" && grep -q '^devfs /dev' /proc/mounts && mount -f "$devfs" + fi +fi + +: exit 0 diff --git a/packages/initscripts/initscripts-openmoko/led-trigger.sh b/packages/initscripts/initscripts-openmoko/led-trigger.sh new file mode 100644 index 0000000000..9583ce9331 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/led-trigger.sh @@ -0,0 +1,6 @@ +#! /bin/sh +sys_led_trigger="/sys/devices/platform/gta02-led.0/leds/gta02-aux:red/trigger" +if test -e $sys_led_trigger ;then + echo bat-charging > $sys_led_trigger +fi + diff --git a/packages/initscripts/initscripts-openmoko/mountall.sh b/packages/initscripts/initscripts-openmoko/mountall.sh new file mode 100644 index 0000000000..4bd7bbb02c --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/mountall.sh @@ -0,0 +1,52 @@ +# +# mountall.sh Mount all filesystems. +# +# Version: @(#)mountall.sh 2.83-2 01-Nov-2001 miquels@cistron.nl +# +. /etc/default/rcS +if test -f /etc/default/mountall; then + . /etc/default/mountall +fi + +# +# Mount local filesystems in /etc/fstab. For some reason, people +# might want to mount "proc" several times, and mount -v complains +# about this. So we mount "proc" filesystems without -v. +# +test "$VERBOSE" != no && echo "Mounting local filesystems..." +mount -a $MOUNTALL + +# +# We might have mounted something over /dev, see if /dev/initctl is there. +# +if test ! -p /dev/initctl +then + rm -f /dev/initctl + mknod -m 600 /dev/initctl p +fi +kill -USR1 1 + +# +# Execute swapon command again, in case we want to swap to +# a file on a now mounted filesystem. +# +doswap=yes +if test $doswap = yes +then + swapon -a 2> /dev/null +fi + +# A missing homedirectory for root can cause all sorts of problems. +# This can happen after user formats his /home partition for example + +if test -e /etc/passwd +then + ROOT_HOME="`grep root /etc/passwd | cut -d: -f6`" + + if test -n "$ROOT_HOME" + then + ! test -d "$ROOT_HOME" && mkdir -p "$ROOT_HOME" + fi +fi +: exit 0 + diff --git a/packages/initscripts/initscripts-openmoko/mountdevsubfs.sh b/packages/initscripts/initscripts-openmoko/mountdevsubfs.sh new file mode 100644 index 0000000000..c6cfb05af2 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/mountdevsubfs.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. /etc/default/devpts + +test -c /dev/ptmx || mknod -m 666 /dev/ptmx c 5 2 + +if [ -d /dev/pts ]; then + mount -n -t devpts devpts /dev/pts -ogid=${TTYGRP},mode=${TTYMODE} +fi + + +if [ -d /dev/shm ]; then + mount -n -t tmpfs shmfs /dev/shm -omode=0777 +fi diff --git a/packages/initscripts/initscripts-openmoko/mountkernfs.sh b/packages/initscripts/initscripts-openmoko/mountkernfs.sh new file mode 100644 index 0000000000..1ed09fcf05 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/mountkernfs.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +supported_kernel() { + case "$(uname -r)" in + 2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;; + 2.6.1[0-7]|2.6.1[0-7][!0-9]*) return 1 ;; + esac + return 0 +} + +check_kernel() { + if ! supported_kernel; then + echo "WARNING: kernel < 2.6.18" + fi + + if ! grep -qs devpts /proc/filesystems; then + echo "WARNING: kernel does not support devpts" + fi + + if ! grep -qs tmpfs /proc/filesystems; then + echo "WARNING: kernel does not support tmpfs" + fi +} + +if [ -d /proc ]; then + mount -n -t proc proc /proc +fi + +check_kernel + +if [ -d /sys ]; then + mount -n -t sysfs sysfs /sys +fi diff --git a/packages/initscripts/initscripts-openmoko/mountnfs.sh b/packages/initscripts/initscripts-openmoko/mountnfs.sh new file mode 100644 index 0000000000..2631392483 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/mountnfs.sh @@ -0,0 +1,87 @@ +# +# mountnfs.sh Now that TCP/IP is configured, mount the NFS file +# systems in /etc/fstab if needed. If possible, +# start the portmapper before mounting (this is needed for +# Linux 2.1.x and up). +# +# Also mounts SBM filesystems now, so the name of +# this script is getting increasingly inaccurate. +# +# Version: @(#)mountnfs.sh 2.83 05-Oct-2001 miquels@cistron.nl +# + +. /etc/default/rcS + +# +# Run in a subshell because of I/O redirection. +# +test -x /sbin/portmap && test -f /etc/fstab && ( + +# +# Read through fstab line by line. If it is NFS, set the flag +# for mounting NFS filesystems. If any NFS partition is found and it +# not mounted with the nolock option, we start the portmapper. +# +portmap=no +mount_nfs=no +mount_smb=no +mount_ncp=no +while read device mountpt fstype options +do + case "$device" in + ""|\#*) + continue + ;; + esac + + case "$options" in + *noauto*) + continue + ;; + esac + + if test "$fstype" = nfs + then + mount_nfs=yes + case "$options" in + *nolock*) + ;; + *) + portmap=yes + ;; + esac + fi + if test "$fstype" = smbfs + then + mount_smb=yes + fi + if test "$fstype" = ncpfs + then + mount_ncp=yes + fi +done + +exec 0>&1 + +if test "$portmap" = yes +then + if test -x /sbin/portmap + then + echo -n "Starting portmapper... " + start-stop-daemon --start --quiet --exec /sbin/portmap + sleep 2 + fi +fi + +if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes +then + echo "Mounting remote filesystems..." + test "$mount_nfs" = yes && mount -a -t nfs + test "$mount_smb" = yes && mount -a -t smbfs + test "$mount_ncp" = yes && mount -a -t ncpfs +fi + +) < /etc/fstab + +: exit 0 + diff --git a/packages/initscripts/initscripts-openmoko/populate-volatile.sh b/packages/initscripts/initscripts-openmoko/populate-volatile.sh new file mode 100644 index 0000000000..6fb23d758d --- /dev/null +++ b/packages/initscripts/initscripts-openmoko/populate-volatile.sh @@ -0,0 +1,248 @@ +#!/bin/sh + +. /etc/default/rcS + +CFGDIR="/etc/default/volatiles" +TMPROOT="/var/tmp" +COREDEF="00_core" + +[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems." + +create_file() { + EXEC=" + touch \"$1\"; + chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; + chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " + + test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache + + [ -e "$1" ] && { + [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." + } || { + eval $EXEC + } +} + +mk_dir() { + EXEC=" + mkdir -p \"$1\"; + chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; + chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " + + test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache + + [ -e "$1" ] && { + [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." + } || { + eval $EXEC + } +} + +link_file() { + EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" + + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache + + [ -e "$2" ] && { + echo "Cannot create link over existing -${TNAME}-." >&2 + } || { + eval $EXEC + } +} + +check_requirements() { + + cleanup() { + rm "${TMP_INTERMED}" + rm "${TMP_DEFINED}" + rm "${TMP_COMBINED}" + } + + CFGFILE="$1" + + [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0 + + TMP_INTERMED="${TMPROOT}/tmp.$$" + TMP_DEFINED="${TMPROOT}/tmpdefined.$$" + TMP_COMBINED="${TMPROOT}/tmpcombined.$$" + + + cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" + cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}" + cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" + + NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" + NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`" + + [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && { + echo "Undefined users:" + diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" + cleanup + return 1 + } + + + cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" + cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}" + cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" + + NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`" + NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`" + + [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && { + echo "Undefined groups:" + diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" + cleanup + return 1 + } + + # Add checks for required directories here + + cleanup + return 0 + } + +apply_cfgfile() { + + CFGFILE="$1" + + check_requirements "${CFGFILE}" || { + echo "Skipping ${CFGFILE}" + return 1 + } + + cat ${CFGFILE} | grep -v "^#" | \ + while read LINE; do + + eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` + + [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." + + + [ "${TTYPE}" = "l" ] && { + TSOURCE="$TLTARGET" + [ -L "${TNAME}" ] || { + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." + link_file "${TSOURCE}" "${TNAME}" + } + continue + } + + [ -L "${TNAME}" ] && { + [ "${VERBOSE}" != "no" ] && echo "Found link." + NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'` + echo ${NEWNAME} | grep -v "^/" >/dev/null && { + TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}" + [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." + } || { + TNAME="${NEWNAME}" + [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-." + } + } + + case "${TTYPE}" in + "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-." + create_file "${TNAME}" + ;; + "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-." + mk_dir "${TNAME}" + # Add check to see if there's an entry in fstab to mount. + ;; + *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-." + continue + ;; + esac + + + done + + return 0 + + } + +SKEL_DIR="/etc/volatile/skel" + +skel_mount() { + VOLATILE="$1" + + [ -d "$VOLATILE" ] || mkdir -p "$VOLATILE" + + mount -t tmpfs volatile "$VOLATILE" -omode=0755 +} + +skel_load() { + VOLATILE="$1" + + if ! skel_mount "$VOLATILE"; then + echo "failed to mount $VOLATILE" + return 1 + fi + + cp -a "$SKEL_DIR"/* "$VOLATILE"/ +} + +skel_update() { + VOLATILE="$1" + + if ! skel_mount "$VOLATILE"; then + echo "failed to update" + return 1 + fi + + echo -n "Populating volatile directory..." + for file in `ls -1 "${CFGDIR}" | sort`; do + apply_cfgfile "${CFGDIR}/${file}" + done + echo "done" + + if [ -d "$SKEL_DIR" ]; then + rm -rf "$SKEL_DIR" + fi + + mkdir -p "$SKEL_DIR"/tmp + cp -a "$VOLATILE"/* "$SKEL_DIR"/ +} + +populate() { + if [ -d "$SKEL_DIR"/tmp ]; then + skel_load /var/volatile + else + skel_update /var/volatile + fi + + for d in /var/volatile/* + do + ln -sf "$d" /var + done + + if ! test -L /tmp; then + rm -rf /tmp + ln -sf /var/tmp /tmp + fi +} + +case "$1" in + start) + if grep -q "^volatile " /proc/mounts; then + echo "volatile directory is already mounted" + else + populate + fi + ;; + stop) + : # no-op + ;; + update) + if skel_update /var/volatile; then + umount /var/volatile + if grep -q "^volatile " /proc/mounts; then + cp -a "$SKEL_DIR"/* /var/volatile + fi + fi + ;; + *) + echo "Usage: /etc/init.d/populate-volatile {start|stop|update}" + ;; +esac + +: exit 0 diff --git a/packages/initscripts/initscripts-openmoko_1.0.bb b/packages/initscripts/initscripts-openmoko_1.0.bb new file mode 100644 index 0000000000..d6d233b535 --- /dev/null +++ b/packages/initscripts/initscripts-openmoko_1.0.bb @@ -0,0 +1,111 @@ +DESCRIPTION = "Openmoko init scripts" +SECTION = "base" +PRIORITY = "required" +LICENSE = "GPL" +DEPENDS = "" +RDEPENDS = "" + +RCONFLICTS_${PN} = "initscripts" + +SRC_URI = "file://bootmisc.sh \ + file://campgsm \ + file://checkroot.sh \ + file://finish.sh \ + file://functions \ + file://hostname.sh \ + file://led-trigger.sh \ + file://mountall.sh \ + file://mountdevsubfs.sh \ + file://mountkernfs.sh \ + file://mountnfs.sh \ + file://populate-volatile.sh \ + file://devpts \ + file://volatiles \ + file://halt \ + file://reboot \ + file://rmnologin \ + file://save-rtc.sh \ + file://sendsigs \ + file://umountfs \ + file://umountnfs.sh \ + " + +SRC_URI_append_arm = " file://alignment.sh" + +inherit base + +do_install () { +# +# Create directories and install device independent scripts +# + install -d ${D}${sysconfdir}/init.d + install -d ${D}${sysconfdir}/rcS.d + install -d ${D}${sysconfdir}/rc0.d + install -d ${D}${sysconfdir}/rc1.d + install -d ${D}${sysconfdir}/rc2.d + install -d ${D}${sysconfdir}/rc3.d + install -d ${D}${sysconfdir}/rc4.d + install -d ${D}${sysconfdir}/rc5.d + install -d ${D}${sysconfdir}/rc6.d + install -d ${D}${sysconfdir}/default + install -d ${D}${sysconfdir}/default/volatiles + + if [ "${TARGET_ARCH}" = "arm" ]; then + install -m 0755 ${WORKDIR}/alignment.sh ${D}${sysconfdir}/init.d + fi + install -m 0755 ${WORKDIR}/bootmisc.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/campgsm ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/checkroot.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/finish.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/functions ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/hostname.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/led-trigger.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/mountall.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/mountnfs.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/mountdevsubfs.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/mountkernfs.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/populate-volatile.sh ${D}${sysconfdir}/init.d + + install -m 0644 ${WORKDIR}/devpts ${D}${sysconfdir}/default/devpts + install -m 0644 ${WORKDIR}/volatiles ${D}${sysconfdir}/default/volatiles/00_core + + install -m 0755 ${WORKDIR}/halt ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/reboot ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/rmnologin ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/save-rtc.sh ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/sendsigs ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/umountfs ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/umountnfs.sh ${D}${sysconfdir}/init.d + +# +# Create runlevel links +# + ln -sf ../init.d/hostname.sh ${D}${sysconfdir}/rcS.d/S02hostname.sh + ln -sf ../init.d/mountkernfs.sh ${D}${sysconfdir}/rcS.d/S02mountkernfs.sh + ln -sf ../init.d/mountdevsubfs.sh ${D}${sysconfdir}/rcS.d/S04mountdevsubfs.sh + if [ "${TARGET_ARCH}" = "arm" ]; then + ln -sf ../init.d/alignment.sh ${D}${sysconfdir}/rcS.d/S06alignment + fi + #ln -sf ../init.d/campgsm ${D}${sysconfdir}/rcS.d/S07campgsm + ln -sf ../init.d/checkroot.sh ${D}${sysconfdir}/rcS.d/S10checkroot.sh + ln -sf ../init.d/mountall.sh ${D}${sysconfdir}/rcS.d/S35mountall.sh + ln -sf ../init.d/populate-volatile.sh ${D}${sysconfdir}/rcS.d/S37populate-volatile.sh + ln -sf ../init.d/mountnfs.sh ${D}${sysconfdir}/rcS.d/S45mountnfs.sh + ln -sf ../init.d/bootmisc.sh ${D}${sysconfdir}/rcS.d/S55bootmisc.sh + ln -sf ../init.d/led-trigger.sh ${D}${sysconfdir}/rcS.d/S97led-trigger.sh + ln -sf ../init.d/finish.sh ${D}${sysconfdir}/rcS.d/S99finish.sh + + ln -sf ../init.d/rmnologin ${D}${sysconfdir}/rc5.d/S99rmnologin + + ln -sf ../init.d/sendsigs ${D}${sysconfdir}/rc0.d/S20sendsigs + ln -sf ../init.d/save-rtc.sh ${D}${sysconfdir}/rc0.d/S25save-rtc.sh + ln -sf ../init.d/umountnfs.sh ${D}${sysconfdir}/rc6.d/S31umountnfs.sh + ln -sf ../init.d/umountfs ${D}${sysconfdir}/rc0.d/S40umountfs + ln -sf ../init.d/halt ${D}${sysconfdir}/rc0.d/S90halt + + ln -sf ../init.d/sendsigs ${D}${sysconfdir}/rc6.d/S20sendsigs + ln -sf ../init.d/save-rtc.sh ${D}${sysconfdir}/rc6.d/S25save-rtc.sh + ln -sf ../init.d/umountnfs.sh ${D}${sysconfdir}/rc6.d/S31umountnfs.sh + ln -sf ../init.d/umountfs ${D}${sysconfdir}/rc6.d/S40umountfs + ln -sf ../init.d/reboot ${D}${sysconfdir}/rc6.d/S90reboot +} diff --git a/packages/initscripts/initscripts-openprotium_1.0.bb b/packages/initscripts/initscripts-openprotium_1.0.bb index 1ae398e962..e787eede92 100644 --- a/packages/initscripts/initscripts-openprotium_1.0.bb +++ b/packages/initscripts/initscripts-openprotium_1.0.bb @@ -74,7 +74,7 @@ do_install_append() { rm ${D}${sysconfdir}/rcS.d/S45mountnfs.sh rm ${D}${sysconfdir}/rcS.d/S55bootmisc.sh # rm ${D}${sysconfdir}/rcS.d/S55urandom - rm ${D}${sysconfdir}/rcS.d/S99finish + rm ${D}${sysconfdir}/rcS.d/S99finish.sh rm ${D}${sysconfdir}/rcS.d/S05devices # udev will run at S04 if installed rm ${D}${sysconfdir}/rcS.d/S03sysfs @@ -136,7 +136,7 @@ do_install_append() { # urandom is currently disabled from S 55 (and won't work with tmpfs /var) # ipkg-cl configure runs at S 98 - update-rc.d -r ${D} finish start 99 S . + update-rc.d -r ${D} finish.sh start 99 S . # # User (2-5) links - UNCHANGED diff --git a/packages/initscripts/initscripts-slugos_1.0.bb b/packages/initscripts/initscripts-slugos_1.0.bb index 1b29e8f1af..41b1e97d9d 100644 --- a/packages/initscripts/initscripts-slugos_1.0.bb +++ b/packages/initscripts/initscripts-slugos_1.0.bb @@ -66,7 +66,7 @@ do_install_append() { rm ${D}${sysconfdir}/rcS.d/S45mountnfs.sh rm ${D}${sysconfdir}/rcS.d/S55bootmisc.sh # rm ${D}${sysconfdir}/rcS.d/S55urandom - rm ${D}${sysconfdir}/rcS.d/S99finish + rm ${D}${sysconfdir}/rcS.d/S99finish.sh rm ${D}${sysconfdir}/rcS.d/S05devices # udev will run at S04 if installed rm ${D}${sysconfdir}/rcS.d/S03sysfs @@ -130,7 +130,7 @@ do_install_append() { # urandom is currently disabled from S 55 (and won't work with tmpfs /var) # ipkg-cl configure runs at S 98 - update-rc.d -r ${D} finish start 99 S . + update-rc.d -r ${D} finish.sh start 99 S . # # User (2-5) links - UNCHANGED diff --git a/packages/initscripts/initscripts_1.0.bb b/packages/initscripts/initscripts_1.0.bb index 8daefc519d..5d0982e62a 100644 --- a/packages/initscripts/initscripts_1.0.bb +++ b/packages/initscripts/initscripts_1.0.bb @@ -16,7 +16,7 @@ SRC_URI = "file://functions \ file://hostname.sh \ file://mountall.sh \ file://banner \ - file://finish \ + file://finish.sh \ file://bootmisc.sh \ file://mountnfs.sh \ file://reboot \ @@ -56,7 +56,7 @@ do_install () { install -m 0755 ${WORKDIR}/functions ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/bootmisc.sh ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/checkroot.sh ${D}${sysconfdir}/init.d - install -m 0755 ${WORKDIR}/finish ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/finish.sh ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/halt ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/hostname.sh ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/mountall.sh ${D}${sysconfdir}/init.d @@ -113,7 +113,7 @@ do_install () { ln -sf ../init.d/mountnfs.sh ${D}${sysconfdir}/rcS.d/S45mountnfs.sh ln -sf ../init.d/bootmisc.sh ${D}${sysconfdir}/rcS.d/S55bootmisc.sh # ln -sf ../init.d/urandom ${D}${sysconfdir}/rcS.d/S55urandom - ln -sf ../init.d/finish ${D}${sysconfdir}/rcS.d/S99finish + ln -sf ../init.d/finish.sh ${D}${sysconfdir}/rcS.d/S99finish.sh ln -sf ../init.d/devices ${D}${sysconfdir}/rcS.d/S05devices # udev will run at S04 if installed ln -sf ../init.d/sysfs.sh ${D}${sysconfdir}/rcS.d/S03sysfs -- cgit 1.2.3-korg