commit | ba2e744d5667e48f727d357b38aaad1ff79630ec | [log] [tgz] |
---|---|---|
author | Andrew Jeffery <andrew@aj.id.au> | Tue Sep 07 09:11:21 2021 +0930 |
committer | Andrew Jeffery <andrew@aj.id.au> | Wed Sep 08 23:03:36 2021 +0930 |
tree | bb37a32b3613982842ca49e56de2bdbc9ce59df9 | |
parent | b25389e583ee33e984c960a179f5cc5108b1432e [diff] |
Add overlay script `overlay` does the tedious work of setting up and tearing down the environment required for overlay filesystems. Example use: ``` root@bmc:~# touch /usr/share/vpd/foo touch: /usr/share/vpd/foo: Read-only file system root@bmc:~# ./overlay add /usr/share/vpd [53864.956641] overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off. root@bmc:~# touch /usr/share/vpd/foo root@bmc:~# ls -l /usr/share/vpd/foo -rw-r--r-- 1 root root 0 Sep 6 23:55 /usr/share/vpd/foo root@bmc:~# rm /usr/share/vpd/foo root@bmc:~# ls -l /usr/share/vpd/foo ls: /usr/share/vpd/foo: No such file or directory root@bmc:~# ./overlay remove /usr/share/vpd root@bmc:~# touch /usr/share/vpd/foo touch: /usr/share/vpd/foo: Read-only file system ``` The `rm -rf` specifically removes the temporary directories specified in the mount options: ``` root@bmc:~# ./overlay add /usr/share/vpd root@bmc:~# sh -x ./overlay remove /usr/share/vpd + set -eu + '[' 2 -lt 2 ']' + case $1 in + o_lowerdir=/usr/share/vpd ++ fstab_fs_mntopt /usr/share/vpd ++ awk '"overlay" == $1 && "/usr/share/vpd" == $2 { printf("%s\n", $4) }' + o_options=rw,relatime,lowerdir=/usr/share/vpd,upperdir=/tmp/tmp.v8vJ35,workdir=/tmp/tmp.6v1YJY + umount /usr/share/vpd + '[' -z rw,relatime,lowerdir=/usr/share/vpd,upperdir=/tmp/tmp.v8vJ35,workdir=/tmp/tmp.6v1YJY ']' + fstab_option_iter + tr , '\n' + echo rw,relatime,lowerdir=/usr/share/vpd,upperdir=/tmp/tmp.v8vJ35,workdir=/tmp/tmp.6v1YJY + read FS_MNTOPT + case $FS_MNTOPT in + read FS_MNTOPT + case $FS_MNTOPT in + read FS_MNTOPT + case $FS_MNTOPT in + read FS_MNTOPT + case $FS_MNTOPT in ++ echo upperdir=/tmp/tmp.v8vJ35 ++ fstab_option_value ++ cut -d= -f2 + rm -rf /tmp/tmp.v8vJ35 + read FS_MNTOPT + case $FS_MNTOPT in ++ fstab_option_value ++ cut -d= -f2 ++ echo workdir=/tmp/tmp.6v1YJY + rm -rf /tmp/tmp.6v1YJY + read FS_MNTOPT root@bmc:~# ``` It also safely handles bad remove invocations: ``` root@bmc:~# sh -x ./overlay remove /asdf + set -eu + '[' 2 -lt 2 ']' + case $1 in + o_lowerdir=/asdf ++ fstab_fs_mntopt /asdf ++ awk '"overlay" == $1 && "/asdf" == $2 { printf("%s\n", $4) }' + o_options= + umount /asdf umount: /asdf: no mount point specified. root@bmc:~# sh -x ./overlay remove / + set -eu + '[' 2 -lt 2 ']' + case $1 in + o_lowerdir=/ ++ fstab_fs_mntopt / ++ awk '"overlay" == $1 && "/" == $2 { printf("%s\n", $4) }' + o_options= + umount / + '[' -z '' ']' + echo / is not an overlay / is not an overlay + exit 1 root@bmc:~# ``` Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Change-Id: I0118c645d9edf391d9670aacc889f31d1e1b2f5f
The goal of this repository is to collect the two-minute hacks you write to automate interactions with OpenBMC systems.
It's highly likely the scripts don't meet your needs - they could be undocumented, dysfunctional or utterly broken. Please help us improve!
Then this repository aims to be the default destination for your otherwise un-homed scripts. As such we are setting the bar for submission pretty low, and we aim to make the process as easy as possible.
Please use gerrit for all patches to this repository:
Do note that you will need to be party to the OpenBMC CLA before your contributions can be accepted. See Gerrit Setup and CLA for more information.
So long as your patches look sane with a cursory glance you can expect them to be applied. We may push back in the event that similar tools already exist or there are egregious issues.
We don't ask for much, but you need to give us at least a Signed-off-by, use SPDX markers in your source files and put your work under an Apache 2.0 compatible license.
There's no standard way to install the scripts housed here, and adding parts of the repository to your PATH might be a bit of a dice-roll. We may also move or remove scripts from time to time as part of housekeeping. It's probably best to copy things out if you need stability.