chiark / gitweb /
finalise 6.0.0
[chiark-utils.git] / backup / remount
1 #!/bin/sh
2
3 set -e
4
5 removes () {
6         rm -f -- "$vardir/snap-mount" "$vardir/snap-device"
7 }
8
9 vardir="$2"
10
11 case "$#.$1" in
12 2.drop)
13         fs="$(readlink "$vardir/snap-mount")"
14         removes
15         mount -vo remount,rw "$fs" || true
16         ;;
17 4.snap)
18         removes
19         mount -vo remount,ro "$4"
20         ln -s -- "$3" "$vardir/snap-device"
21         ln -s -- "$4" "$vardir/snap-mount"
22         ;;
23 *)
24         cat >&2 <<'END'
25 usage: .../remount snap VARDIR DEV MOUNT
26        .../remount drop VARDIR
27 END
28         exit 1
29         ;;
30 esac