Commit | Line | Data |
---|---|---|
99248ed2 MW |
1 | #! /bin/sh |
2 | ### | |
3 | ### Make fake snapshots by doing nothing at all | |
4 | ### | |
5 | ### (c) 2011 Mark Wooding | |
6 | ### | |
7 | ||
8 | ###----- Licensing notice --------------------------------------------------- | |
9 | ### | |
13678d88 MW |
10 | ### This file is part of the distorted.org.uk backup suite. |
11 | ### | |
12 | ### distorted-backup is free software; you can redistribute it and/or modify | |
99248ed2 MW |
13 | ### it under the terms of the GNU General Public License as published by |
14 | ### the Free Software Foundation; either version 2 of the License, or | |
15 | ### (at your option) any later version. | |
16 | ### | |
13678d88 | 17 | ### distorted-backup is distributed in the hope that it will be useful, |
99248ed2 MW |
18 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ### GNU General Public License for more details. | |
21 | ### | |
13678d88 MW |
22 | ### You should have received a copy of the GNU General Public License along |
23 | ### with distorted-backup; if not, write to the Free Software Foundation, | |
99248ed2 MW |
24 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | ||
26 | set -e | |
27 | quis=${0##*/} | |
28 | ||
29 | ###-------------------------------------------------------------------------- | |
30 | ### Parse the command line. | |
31 | ||
32 | ## Provide help or version information. | |
33 | usage="usage: $quis DEVICE [KEY=VALUE ...]" | |
34 | version="$quis, version 1.0.0" | |
35 | case "$#,$1" in | |
36 | 0,*) echo >&2 "$usage"; exit 1 ;; | |
37 | *,-v | *,--version) echo "$version"; exit ;; | |
38 | *,-h | *,--help) | |
39 | cat <<EOF | |
40 | $version | |
41 | $usage | |
42 | ||
43 | Option keys: | |
44 | op=OPERATION \`snap' to create snapshot, or \`unsnap' to remove. | |
45 | tag=TAG Disambiguation tag to store in filesystem. | |
46 | EOF | |
47 | exit | |
48 | ;; | |
49 | esac | |
50 | ||
51 | ## Scan the option keys. | |
52 | dev=$1; shift | |
53 | Oop=snap Otag=snap | |
54 | win=t | |
55 | for i in "$@"; do | |
56 | case "$i" in | |
57 | ?*=*) ;; | |
58 | *) echo >&2 "$quis: malformed option \`$i'"; exit 1 ;; | |
59 | esac | |
60 | k=${i%%=*} v=${i#*=} | |
61 | case "$k" in *.trivial) k=${k%.trivial} ;; ?*.?*) continue ;; esac | |
62 | case "$k" in | |
63 | op | tag) eval "O$k=\$v" ;; | |
64 | *) echo >&2 "$quis: unknown option \`$k'"; win=nil ;; | |
65 | esac | |
66 | done | |
67 | case $win in nil) exit 1 ;; esac | |
68 | ||
69 | ###-------------------------------------------------------------------------- | |
70 | ### Take or remove the snapshot. | |
71 | ||
72 | case "$Oop" in | |
73 | snap) | |
74 | echo "$dev" | |
75 | ;; | |
76 | unsnap) | |
77 | ;; | |
78 | *) | |
79 | echo >&2 "$quis: unknown operation \`$Oop'" | |
80 | exit 1 | |
81 | ;; | |
82 | esac | |
83 | ||
84 | ###----- That's all, folks -------------------------------------------------- |