summaryrefslogtreecommitdiff
path: root/packages/openslug-init/openslug-init-0.10
diff options
context:
space:
mode:
Diffstat (limited to 'packages/openslug-init/openslug-init-0.10')
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/leds_startup (renamed from packages/openslug-init/openslug-init-0.10/leds_startup)0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/rmrecovery (renamed from packages/openslug-init/openslug-init-0.10/rmrecovery)0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/syslog.file0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/syslog.network0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh0
-rw-r--r--packages/openslug-init/openslug-init-0.10/initscripts/zleds0
-rw-r--r--packages/openslug-init/openslug-init-0.10/leds_rs_green38
-rw-r--r--packages/openslug-init/openslug-init-0.10/sysconfsetup146
-rw-r--r--packages/openslug-init/openslug-init-0.10/turnup152
11 files changed, 129 insertions, 207 deletions
diff --git a/packages/openslug-init/openslug-init-0.10/leds_startup b/packages/openslug-init/openslug-init-0.10/initscripts/leds_startup
index e69de29bb2..e69de29bb2 100644
--- a/packages/openslug-init/openslug-init-0.10/leds_startup
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/leds_startup
diff --git a/packages/openslug-init/openslug-init-0.10/rmrecovery b/packages/openslug-init/openslug-init-0.10/initscripts/rmrecovery
index e69de29bb2..e69de29bb2 100644
--- a/packages/openslug-init/openslug-init-0.10/rmrecovery
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/rmrecovery
diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup b/packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup
diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer
diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/syslog.file b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.file
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.file
diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/syslog.network b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.network
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.network
diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh b/packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh
diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/zleds b/packages/openslug-init/openslug-init-0.10/initscripts/zleds
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/openslug-init/openslug-init-0.10/initscripts/zleds
diff --git a/packages/openslug-init/openslug-init-0.10/leds_rs_green b/packages/openslug-init/openslug-init-0.10/leds_rs_green
deleted file mode 100644
index c3ad3d2d64..0000000000
--- a/packages/openslug-init/openslug-init-0.10/leds_rs_green
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-#
-# This script is executed at the start and end of each run-level
-# transition. It is the first 'stop' script and the last 'start'
-# script.
-#
-# 'stop' sets the correct colour power LED to flash between the
-# two colours of the previous and next runlevel.
-# 'start' sets the LED to steady
-#
-# 'red' is the initial setting on kernel boot
-#
-# 'amber' is used for run levels S (from /linuxrc), 0 (halt),
-# 1 (single user) and 6 (reboot). halt and reboot do not
-# terminate therefore the LED remains flashing until the
-# kernel terminates.
-#
-# 'green' is used for run levels 2-5 - the normal user run levels.
-#
-# colours are 'g' (green), 'r' (red) or 'gr' (amber).
-colour() {
- case "$1" in
- S|0|1|6) echo gr;;
- 2|3|4|5) echo g;;
- N) echo r;;
- *) echo "led change: $runlevel: runlevel unknown" >&2
- echo r;;
- esac
-}
-
-# leds syntax is -A +<init state> /<new state>
-case "$1" in
-start) leds -A +"$(colour "$runlevel")";;
-stop) leds -A +"$(colour "$previous")" /"$(colour "$runlevel")";;
-*) echo "led change: $1: command ignored" >&2;;
-esac
-
-exit 0
diff --git a/packages/openslug-init/openslug-init-0.10/sysconfsetup b/packages/openslug-init/openslug-init-0.10/sysconfsetup
deleted file mode 100644
index 8d2ecdca09..0000000000
--- a/packages/openslug-init/openslug-init-0.10/sysconfsetup
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/sh
-# This script is run once when the system first boots. Its sole
-# purpose is to create /etc/default/sysconf (the overall system
-# configuration file) and other files derived from this.
-#
-# The script runs immediately after S10checkroot.sh - this is the
-# point at which the rootfs will be mounted rw even if the kernel
-# booted with it ro.
-#
-# rm or mv the file to run this again. If this is done the
-# following configuration files will be rewritten:
-#
-# /etc/default/sysconf
-# /etc/hostname
-# /etc/defaultdomain
-# /etc/network/interfaces
-# /etc/resolv.conf
-#
-test -r /etc/default/sysconf && exit 0
-#
-# /etc/default/functions contains useful utility functions - it's
-# in a separate file so that it can be loaded by any script
-. /etc/default/functions
-#
-# Utility to deal with absence of DNS configuration
-echodns(){
- local dns
- if test $# -gt 0
- then
- for dns in "$@"
- do
- echo "nameserver $dns"
- done
- fi
-}
-#
-# The SysConf device must exist in /dev at this point for this script
-# to work.
-#
-# It is important not to hard-wire the name of the device because of
-# the posibility of changing the flash partition layout.
-#
-# The block device is used here because at present udev does not
-# show the character devices
-sysdev="$(mtblockdev SysConf)"
-if test -n "$sysdev" -a -b "$sysdev"
-then
- # Read the defined part of SysConf into /etc/default/sysconf.
- # SysConf has lines of two forms:
- #
- # [section]
- # name=value
- #
- # In practice SysConf also contains other stuff, use the command:
- #
- # devio '<</dev/mtd1;cpb'
- #
- # to examine the current settings. The badly formatted stuff
- # is removed (to be exact, the sed script selects only lines
- # which match one of the two above). The lan interface, which
- # defaults to ixp0, is changed to the correct value for openslug,
- # eth0
- devio '<<'"$sysdev"';cpb;fb1,10' | sed -n '/^\[[^][]*\]$/p;
- s/^lan_interface=ixp0$/lan_interface=eth0/;
- /^[-a-zA-Z0-9_][-a-zA-Z0-9_]*=/p' >/etc/default/sysconf
- #
- # Now take the result and set up the 'standard' files in the
- # root file system (these couldn't be set up before because
- # they depend on stuff which RedBoot puts into SysConf from the
- # ID info on the specific machine - in particular the hardware
- # address of eth0, which must be the one assigned for *this*
- # box!)
- #
- # HOSTNAME: defaults to LGK<mac> i.e. something derived from
- # the ethernet hardware. LinkSys documentation explains how
- # to determine this. Set by the user in linksys setup software.
- # DOMAINNAME: LinkSys puts this in w_d_name.
- test -n "$(config host)" && config host >/etc/hostname
- domain="$(config domain)"
- test -n "$domain" && echo "$domain" >/etc/defaultdomain
- #
- # Ethernet information. This goes into /etc/network/interfaces,
- # however this is only used for static setup (and this is not
- # the default). With dhcp the openslug udhcp script,
- # /etc/udhcpc.d/50default, loads the values from sysconf. The
- # lan_interface config value must exist for the file to be
- # overwritten here.
- iface="$(config iface)"
- if test -n "$iface"
- then
- boot="$(config boot)"
- # Only dhcp and static are supported at present - bootp
- # support requires installation of appropriate packages
- # dhcp is the fail-safe
- case "$boot" in
- dhcp|static) ;;
- *) boot=dhcp;;
- esac
- #
- mac="$(config mac)"
- ip="$(config ip)"
- netmask="$(config netmask)"
- gateway="$(config gateway)"
- {
- echo "# /etc/network/interfaces"
- echo "# configuration file for ifup(8), ifdown(8)"
- echo "#"
- echo "# The loopback interface"
- echo "auto lo"
- echo "iface lo inet loopback"
- echo "#"
- echo "# The NSLU2 built-in ethernet"
- echo "auto eth0"
- echo "# Automatically generated from /etc/default/sysconf"
- if test -n "$mac"
- then
- echo "# The pre-up option must always be supplied, regardless"
- echo "# of configuration, to set the hardware correctly."
- echo "# Severe network problems may result if this option is"
- echo "# removed."
- c=
- else
- echo "# WARNING: improperly configured network interface."
- echo "# WARNING: the pre-up line must be corrected or severe"
- echo "# WARNING: network problems may result."
- c='#'
- mac='<WARNING: unknown hardware address>'
- fi
- echo "iface $iface inet $boot"
- echo "${c} pre-up ifconfig $iface hw ether $mac"
- # The following are ignored for DHCP but are harmless
- test -n "$ip" && echo " address $ip"
- test -n "$netmask" && echo " netmask $netmask"
- test -n "$gateway" && echo " gateway $gateway"
- } >/etc/network/interfaces
- fi
- #
- # The DNS server information gives up to three nameservers, but this
- # currently only binds in the first.
- {
- test -n "$domain" && echo "search $domain"
- echodns $(config dns) $(config dns1) $(config dns2)
- } >/etc/resolv.conf
-fi
-
-exit 0
diff --git a/packages/openslug-init/openslug-init-0.10/turnup b/packages/openslug-init/openslug-init-0.10/turnup
index b688bc3051..d22e15c208 100644
--- a/packages/openslug-init/openslug-init-0.10/turnup
+++ b/packages/openslug-init/openslug-init-0.10/turnup
@@ -8,6 +8,55 @@
# force: override certain checks
force=
#
+# fstype new
+# The type of the file system mounted on "new" Outputs the last
+# piece of information found, which should be the one for the
+# currently visible mount!
+fstype() {
+ local cwd dev mp type options pass freq result
+ cwd="$(cd "$1"; /bin/pwd)"
+ result=
+ while read dev mp type options pass freq
+ do
+ case "$mp" in
+ "$cwd") result="$type";;
+ esac
+ done </proc/mounts
+ echo "$result"
+}
+#
+# fsoptions arguments
+# Collapses the mount (-o) options into a single list which is
+# printed on stdout. Accepts an arbitrary list of options and
+# just joins them together.
+fsoptions() {
+ local options
+ options=
+ while test $# -gt 1
+ do
+ case "$1" in
+ -t) shift;;
+ -o) if test -n "$2"
+ then
+ if test -n "$options"
+ then
+ options="$options,$2"
+ else
+ options="$2"
+ fi
+ fi
+ shift;;
+ esac
+ shift
+ done
+ if test -n "$options"
+ then
+ echo "$options"
+ else
+ echo defaults
+ fi
+}
+#
# check_rootfs [-i] <root fs directory>
# Make sure the candidate rootfs is empty
check_rootfs() {
@@ -87,8 +136,8 @@ setup_dev() {
return 1
}
echo "done" >&2
- # now remove the startup links which mount the ramfs on /dev
- rm "$1"/etc/rc?.d/[KS]??devices
+ # now prevent this being done each time
+ :>"$1"/dev/.permanent
return 0
}
@@ -128,8 +177,8 @@ setup_var() {
echo "turnup: /var: could not populate directory" >&2
return 1
}
- # and remove the startup links
- rm "$1"/etc/rc?.d/[KS]??populate-var.sh
+ # the startup link is left for the moment, this seems safer
+ #rm "$1"/etc/rc?.d/[KS]??populate-var.sh
# remove the /var tmpfs entry from the new /etc/fstab
case "$2" in
disk) sed -i '\@\s/var\s\s*tmpfs\s@d' "$1"/etc/fstab
@@ -138,10 +187,9 @@ setup_var() {
echo "turnup: tmpfs /var mount moved to /var/tmp" >&2;;
esac
#
- # warn the user - it's not enough to put the /var mount back, it
- # is necessary to reinsert the populate-var.sh links!
- echo " If you remount tmpfs on /var it must be populated at boot, use:" >&2
- echo " update-rc.d populate-var.sh start 37 S ." >&2
+ # Previous versions of turnup removed populate-var.sh from the
+ # startup links, this one doesn't, so /var can be made back into
+ # a tmpfs just by a change to /etc/fstab.
return 0
}
@@ -225,6 +273,23 @@ setup_rootfs() {
}
#
+# setup_fstab new fsdev fstype fsoptions
+# Alters the /etc/fstab entry for / to refer to the correct device and
+# have the correct type and options. Essential for checkroot to remount
+# / with the correct options.
+# bad, since sed won't fail even if it changes nothing.
+setup_fstab() {
+ sed -i '\@^[^ ]*\s\s*/\s@s@^.*$@'"$2 / $3 $4 1 1"'@' "$1"/etc/fstab
+ egrep -q "^$2 / $3 $4 1 1\$" "$1"/etc/fstab || {
+ echo "turnup: /etc/fstab: root(/) entry not changed" >&2
+ echo " you probably need to check the options in /etc/fstab" >&2
+ echo " to ensure that the root partition is mounted correctly" >&2
+ return 1
+ }
+}
+
+
+#
# boot_rootfs <boot type> <flash file system> <sleep time> <device> [options]
# Change the flash partition (not the current root!) to boot off
# the new root file system
@@ -342,7 +407,7 @@ mountflash() {
# disk [-m] [-i] [-s<time>] <device> {options}
# Carefully copy the flash file system to the named device.
disk() {
- local setup_type sleep init device new ffs
+ local setup_type sleep init device new ffs fst fso
setup_type=disk
sleep=0
@@ -388,8 +453,17 @@ disk() {
# read only is *not* an option, this is important because the boot/disk
# script needs a rw file system
status=1
+ fst=
+ fso="$(fsoptions "$@")"
if mount "$@" "$device" "$new"
then
+ fst="$(fstype "$new")"
+ umount "$new" ||
+ echo "turnup disk: $device($new): umount does not seem to work" >&2
+ fi
+
+ if test -n "$fst" && mount -t "$fst" -o "$fso" "$device" "$new"
+ then
if check_rootfs $init "$new" && {
test -z "$init" || {
copy_rootfs "$ffs" "$new" &&
@@ -397,14 +471,20 @@ disk() {
}
}
then
+ setup_fstab "$new" "$device" "$fst" "$fso"
status=0
fi
# clean up the disk. It is worrying if this umount fails!
- umount "$new" || {
+ umount "$new" || test "$force" = "-f" || {
echo "turnup disk: $device: umount failed" >&2
echo " you must unmount this device cleanly yourself, then use" >&2
- echo " the -i option to boot from the device" >&2
+ if test -z "$init"
+ then
+ echo " turnup with the -f option to boot from the device" >&2
+ else
+ echo " turnup without the -i option to boot from the device" >&2
+ fi
status=1
}
@@ -412,10 +492,15 @@ disk() {
if test $status -eq 0
then
# memsticks boot like disks, so ignore the -m
- boot_rootfs disk "$ffs" "$sleep" "$device" "$@"
+ boot_rootfs disk "$ffs" "$sleep" "$device" -t "$fst" -o "$fso"
fi
else
echo "turnup disk: $device($*): unable to mount device on $new" >&2
+ # If it worked first time
+ if test -n "$fst"
+ then
+ echo " options used: -t $fst -o $fso [error in this script]" >&2
+ fi
fi
# clean up the flash file system
@@ -501,7 +586,19 @@ nfs() {
# read only is *not* an option, this is important because the boot/disk
# script needs a rw file system
status=1
- if mount -t nfs -o nolock,noatime,hard,intr,rsize=1024,wsize=1024,"$@" "$nfsroot" "$new"
+ fst=
+ # These settings for for NFS, something better will probably have to
+ # be done to support other network file systems.
+ nfsopt="nolock,noatime,hard,intr,rsize=1024,wsize=1024"
+ fso="$(fsoptions -o "$nfsopt" "$@")"
+ if mount -o "$nfsopt" "$@" "$nfsroot" "$new"
+ then
+ fst="$(fstype "$new")"
+ umount "$new" ||
+ echo "turnup nfs: $nfsroot($new): umount does not seem to work" >&2
+ fi
+
+ if test -n "$fst" && mount -t "$fst" -o "$fso" "$nfsroot" "$new"
then
if :>"$new"/ttt && test -O "$new"/ttt && rm "$new"/ttt
then
@@ -512,19 +609,25 @@ nfs() {
}
}
then
+ setup_fstab "$new" "$nfsroot" "$fst" "$fso"
status=0
fi
else
- echo "turnup nfs: $nfsroot: partition must be mounted no_root_squash" >&2
+ echo "turnup nfs: $nfsroot: partition must be exported no_root_squash" >&2
fi
# clean up the disk. It is worrying if this umount fails!
- umount "$new" || {
+ umount "$new" || test "$force" = "-f" || {
echo "turnup nfs: $nfsroot: umount failed" >&2
if test $status -eq 0
then
echo " you must unmount this partition cleanly yourself, then use" >&2
- echo " the -i option to boot from the NFS root" >&2
+ if test -z "$init"
+ then
+ echo " turnup with the -f option to boot from the NFS root" >&2
+ else
+ echo " turnup without the -i option to boot from the NFS root" >&2
+ fi
status=1
fi
}
@@ -533,11 +636,15 @@ nfs() {
if test $status -eq 0
then
# the options used are exactly those which worked before.
- boot_rootfs nfs "$ffs" 0 "$nfsroot" -t nfs \
- -o nolock,noatime,hard,intr,rsize=1024,wsize=1024,"$@"
+ boot_rootfs nfs "$ffs" 0 "$nfsroot" -t nfs -o "$fso"
fi
else
- echo "turnup disk: $nfsroot($*): unable to mount device on $new" >&2
+ echo "turnup nfs: $nfsroot($*): unable to mount device on $new" >&2
+ # If it worked first time
+ if test -n "$fst"
+ then
+ echo " options obtained: -t $fst -o $fso" >&2
+ fi
fi
# clean up the flash file system
@@ -588,10 +695,9 @@ usage: turnup command [options]
partition must be available to be mounted without root id
sqashing (i.e. root must be root) and it will be selected
as the root file system for subsequent reboots.
- The options are added to the -o list, therefore to give
- additional flag arguments specify an empty first option.
- The options may be used to override the defaults just by
- specifying the new value.
+ A default set of -o options are provided, additional options
+ may be given on the command line (multiple -o options will
+ be combined into a single -o).
flash
Revert to booting from the flash disk on next reboot.
ram