File: nosnap

package info (click to toggle)
chiark-utils 4.1.28
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 820 kB
  • ctags: 519
  • sloc: perl: 3,045; ansic: 2,176; sh: 820; makefile: 276; tcl: 228
file content (32 lines) | stat: -rwxr-xr-x 435 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

set -e

removes () {
	if test -d "$vardir/snap-mount"; then
		rmdir -- "$vardir/snap-mount"
	else
		rm -f -- "$vardir/snap-mount"
	fi
	rm -f -- "$vardir/snap-device"
}

vardir="$2"

case "$#.$1" in
2.drop)
	removes
	;;
4.snap)
	removes
	ln -s -- "$3" "$vardir/snap-device"
	ln -s -- "$4" "$vardir/snap-mount"
	;;
*)
	cat >&2 <<'END'
usage: .../nosnap snap VARDIR DEV MOUNT
       .../nosnap drop VARDIR
END
	exit 1
	;;
esac