From 708b28e11eede1a8e5e8da8178bb695c01db83ba Mon Sep 17 00:00:00 2001 From: Mike Westerhof Date: Mon, 4 Jun 2007 01:49:53 +0000 Subject: turnup: updated to use the populate-volatile mechanism to manage /var when initializing a rootfs on disk, memstick, or nfs. --- packages/slugos-init/files/turnup | 132 ++++++++++++++++++++++++------- packages/slugos-init/slugos-init_0.10.bb | 2 +- 2 files changed, 106 insertions(+), 28 deletions(-) diff --git a/packages/slugos-init/files/turnup b/packages/slugos-init/files/turnup index c852f911c8..10bccb8279 100644 --- a/packages/slugos-init/files/turnup +++ b/packages/slugos-init/files/turnup @@ -8,9 +8,93 @@ # configuration # The following variables control which directories in /var end # up on the rootfs and which end up in a temporary file system. -INRAM_MEMSTICK="/var/cache /var/lock /var/log /var/run /var/tmp /var/lib/ipkg" -INRAM_NFS="/var/cache /var/lock /var/run /var/tmp" -INRAM_DISK="" +INRAM_MEMSTICK="\ +### SlugOS from-memory-stick boot. +d root root 0755 /var/backups none +d root root 0755 /var/volatile/cache none +l root root 0755 /var/cache /var/volatile/cache +d root root 0755 /var/lib none +d root root 2755 /var/local none +d root root 1777 /var/volatile/lock none +l root root 1777 /var/lock /var/volatile/lock +d root root 0755 /var/volatile/log none +l root root 0755 /var/log /var/volatile/log +d root root 0755 /var/volatile/run none +l root root 0755 /var/run /var/volatile/run +d root root 0755 /var/spool none +d root root 1777 /var/volatile/tmp none +l root root 1777 /var/tmp /var/volatile/tmp +d root root 0755 /var/lock/subsys none +d root root 0755 /var/lib/dropbear none +d root root 0755 /var/lib/misc none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none" + +INRAM_NFS="\ +### SlugOS from-NFS boot. +d root root 0755 /var/backups none +d root root 0755 /var/volatile/cache none +l root root 0755 /var/cache /var/volatile/cache +d root root 0755 /var/lib none +d root root 2755 /var/local none +d root root 1777 /var/volatile/lock none +l root root 1777 /var/lock /var/volatile/lock +d root root 0755 /var/log none +d root root 0755 /var/volatile/run none +l root root 0755 /var/run /var/volatile/run +d root root 0755 /var/spool none +d root root 1777 /var/volatile/tmp none +l root root 1777 /var/tmp /var/volatile/tmp +d root root 0755 /var/lock/subsys none +d root root 0755 /var/lib/dropbear none +d root root 0755 /var/lib/misc none +d root root 0755 /var/lib/ipkg none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none" + +INRAM_DISK="\ +### SlugOS from-disk boot. +d root root 0755 /var/backups none +d root root 0755 /var/cache none +d root root 0755 /var/lib none +d root root 2755 /var/local none +d root root 1777 /var/lock none +d root root 0755 /var/log none +d root root 0755 /var/run none +d root root 0755 /var/spool none +d root root 1777 /var/tmp none +d root root 0755 /var/lock/subsys none +d root root 0755 /var/lib/dropbear none +d root root 0755 /var/lib/misc none +d root root 0755 /var/lib/ipkg none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none" + +INRAM_HEADER="\ +# 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. +#" # # force: override certain checks @@ -209,7 +293,6 @@ setup_bootdev() { # Removes the /var tmpfs entry from /etc/fstab. # Creates links from /var into /media/ram for NFS and Memstick. setup_var() { - local ram_targets directory test -n "$1" -a -d "$1"/var || { echo "turnup: setup_var($1,$2): expected a directory" >&2 @@ -220,35 +303,30 @@ setup_var() { *) echo "turnup: setup_var($1,$2): expected 'disk', 'nfs' or 'memstick'" >&2 return 1;; esac - # - # populate /var, there is a shell script to do this, but it uses - # absolute path names - chroot "$1" /bin/busybox sh /etc/init.d/populate-volatile.sh || { - echo "turnup: /var: could not populate directory" >&2 - return 1 - } + # populate /var. We just need to create the /var/volatile mount + # point, the populate-volatile script does the work at boot time. + echo "turnup: ensuring /var/volatile mountpoint exists" + test -d "$1"/var/volatile || mkdir "$1"/var/volatile + + # we need to put in place the correct configuration file for + # the populate-volatile script to use at boot time. The config + # file is already in place for the flash boot, and it's the same + # file for the ram boot. case "$2" in - disk) ram_targets="$INRAM_DISK";; - nfs) ram_targets="$INRAM_NFS";; - memstick) - ram_targets="$INRAM_MEMSTICK";; + disk) echo "$INRAM_HEADER" > "$1"/etc/default/volatiles/00_core + echo "$INRAM_DISK" >>"$1"/etc/default/volatiles/00_core;; + nfs) echo "$INRAM_HEADER" > "$1"/etc/default/volatiles/00_core + echo "$INRAM_NFS" >>"$1"/etc/default/volatiles/00_core;; + memstick) echo "$INRAM_HEADER" > "$1"/etc/default/volatiles/00_core + echo "$INRAM_MEMSTICK" >>"$1"/etc/default/volatiles/00_core;; esac - for directory in $ram_targets - do - rm -rf "$1/$directory" - ln -s "/media/ram/$directory" "$1/$directory" - done - # 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 + # remove the /var tmpfs entry from the new /etc/fstab, if it is + # present in the first place. sed -i '\@[ ]/var[ ][ ]*tmpfs[ ]@d' "$1"/etc/fstab - echo "turnup: tmpfs will no longer be mounted on /var" >&2 + echo "turnup: ensuring tmpfs will not be mounted on /var" >&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 } diff --git a/packages/slugos-init/slugos-init_0.10.bb b/packages/slugos-init/slugos-init_0.10.bb index ac6f6c3ac0..77e1efb314 100644 --- a/packages/slugos-init/slugos-init_0.10.bb +++ b/packages/slugos-init/slugos-init_0.10.bb @@ -4,7 +4,7 @@ PRIORITY = "required" LICENSE = "GPL" DEPENDS = "base-files devio" RDEPENDS = "busybox devio" -PR = "r83" +PR = "r84" SRC_URI = "file://boot/flash \ file://boot/disk \ -- cgit v1.2.3