turnup: updated to use the populate-volatile mechanism to manage /var
authorMike Westerhof <mwester@dls.net>
Mon, 4 Jun 2007 01:49:53 +0000 (01:49 +0000)
committerMike Westerhof <mwester@dls.net>
Mon, 4 Jun 2007 01:49:53 +0000 (01:49 +0000)
when initializing a rootfs on disk, memstick, or nfs.

packages/slugos-init/files/turnup
packages/slugos-init/slugos-init_0.10.bb

index c852f91..10bccb8 100644 (file)
@@ -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:
+# <type> <owner> <group> <mode> <path> <linksource>
+# where the items are separated by whitespace !
+#
+# <type> : 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
 }
 
index ac6f6c3..77e1efb 100644 (file)
@@ -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 \