summaryrefslogtreecommitdiff
path: root/src/store-child-permanently
diff options
context:
space:
mode:
Diffstat (limited to 'src/store-child-permanently')
-rwxr-xr-xsrc/store-child-permanently47
1 files changed, 0 insertions, 47 deletions
diff --git a/src/store-child-permanently b/src/store-child-permanently
deleted file mode 100755
index 82e79d8..0000000
--- a/src/store-child-permanently
+++ /dev/null
@@ -1,47 +0,0 @@
1#!/bin/sh
2
3. samizdat-paths.sh
4
5error()
6{
7 printf 'Error: %s\n' "${*:-command failed}" >&2
8 exit 1
9}
10
11warning()
12{
13 printf 'Warning: %s\n' "${*:-something went wrong}" >&2
14}
15
16store_tmpfs()
17{
18 local dir="$1"
19 mountpoint -q "$dir" || return 0
20 [ ! -d "$dir".backup ] || error "existing child backup found: '$dir.backup'. Refusing to continue."
21 cp -a "$dir" "$dir".backup || error "failed to make copy of child."
22 umount "$dir" || error "failed to unmount child tmpfs"
23 rmdir "$dir" || mv -Tb "$dir" "$dir".unlikely
24 mv -T "$dir".backup "$dir" || error "failed to move copied child dir into place. Child will not function!"
25}
26
27assert_root()
28{
29 [ "$(id -u)" = 0 ] || error "you are not root"
30}
31
32main()
33{
34 assert_root
35 child=$1
36 [ "$child" ] || usage
37 if [ -d "$samizdat_child_dir"/child."$child" ]; then
38 store_tmpfs "$samizdat_child_dir"/child."$child"
39 else
40 error "not a directory: $samizdat_child_dir/child.$child"
41 fi
42}
43
44case $# in
45 0) read child < reused-child && main "$child" ;;
46 *) main "$@" ;;
47esac