diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-23 17:17:41 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-24 17:04:20 +0000 |
commit | 26d5fbb15a91c6439bd83c8e99fd23b5c0173566 (patch) | |
tree | 20c16f10ca1e1c7d6b15afc906081db5ea485eb3 /yarns/fstab-configure.yarn | |
parent | 53e83cc89dce3434b7b62505ae5a1e359b124267 (diff) | |
download | morph-26d5fbb15a91c6439bd83c8e99fd23b5c0173566.tar.gz |
Add fstab.configure
This will allow the user to append text to /etc/fstab during a
deployment, without having to write custom configuration extensions.
Diffstat (limited to 'yarns/fstab-configure.yarn')
-rw-r--r-- | yarns/fstab-configure.yarn | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/yarns/fstab-configure.yarn b/yarns/fstab-configure.yarn new file mode 100644 index 00000000..cd7e7438 --- /dev/null +++ b/yarns/fstab-configure.yarn @@ -0,0 +1,62 @@ +`fstab.configure` +================= + +The `fstab.configure` extension appends text to the `/etc/fstab` from +environment variables beginning with `FSTAB_`. It also sets the +ownership and permissions of the file. + +The first thing to test is that the extension doesn't write anything +if not requested to do so, but does create the file if it doesn't +exist. + + SCENARIO fstab.configure does nothing by default + GIVEN a directory called tree/etc + WHEN fstab.configure is run against tree + THEN file tree/etc/fstab exists + AND file tree/etc/fstab has permissions -rw-r--r-- + AND file tree/etc/fstab is owned by uid 0 + AND file tree/etc/fstab is owned by gid 0 + AND file tree/etc/fstab is empty + +Append a something to the file, and verify the contents are exactly +correct. + + SCENARIO fstab.configure appends requested lines + GIVEN a directory called tree/etc + AND an environment variable FSTAB_FOO containing "foo" + WHEN fstab.configure is run against tree + THEN file tree/etc/fstab exists + AND file tree/etc/fstab has permissions -rw-r--r-- + AND file tree/etc/fstab is owned by uid 0 + AND file tree/etc/fstab is owned by gid 0 + AND file tree/etc/fstab contains "foo\n" + +Append something to an existing file, with wrong ownership and +permission. + + SCENARIO fstab.configure appends to existing file + GIVEN a directory called tree/etc + AND a file called tree/etc/fstab containing "# comment\n" + AND tree/etc/fstab is owned by uid 1 + AND tree/etc/fstab is owned by gid 1 + AND tree/etc/fstab has permissions 0600 + AND an environment variable FSTAB_FOO containing "foo" + WHEN fstab.configure is run against tree + THEN file tree/etc/fstab exists + AND file tree/etc/fstab has permissions -rw-r--r-- + AND file tree/etc/fstab is owned by uid 0 + AND file tree/etc/fstab is owned by gid 0 + AND file tree/etc/fstab contains "# comment\nfoo\n" + +Implement running `fstab.configure` +----------------------------------- + +When we actually run `fstab.configure`, we source `$DATADIR/env` to +get the desired environment variables. + + IMPLEMENTS WHEN fstab.configure is run against (\S+) + if [ -e "$DATADIR/env" ] + then + . "$DATADIR/env" + fi + "$SRCDIR/morphlib/exts/fstab.configure" "$DATADIR/$MATCH_1" |