Last change
on this file since 11066 was 10916, checked in by rick, 13 years ago |
Make dryrun default as I always forget the type the command.
|
-
Property svn:executable
set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[10600] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Quick to do sync only the /etc (most) changed entry to permanent storage.
|
---|
| 4 | #
|
---|
| 5 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
| 6 | #
|
---|
| 7 |
|
---|
| 8 | : ${VERBOSE=false}
|
---|
| 9 |
|
---|
| 10 | usage() {
|
---|
| 11 | cat <<EOF
|
---|
| 12 | Usage: $0 [-v] <dryrun|sync>
|
---|
| 13 | Options:
|
---|
| 14 | -v - Verbose diffs
|
---|
| 15 | Arguments:
|
---|
[10916] | 16 | dryrun - Check the pending changes [default]
|
---|
[10600] | 17 | sync - Sync the pending changes
|
---|
| 18 | EOF
|
---|
| 19 | exit ${1:-128}
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[10916] | 22 | SYNC=false
|
---|
[10600] | 23 | while [ -n "$1" ]; do
|
---|
| 24 | case "$1" in
|
---|
| 25 | "-v")
|
---|
| 26 | VERBOSE=true; shift
|
---|
| 27 | ;;
|
---|
| 28 | "dryrun")
|
---|
| 29 | SYNC=false; shift
|
---|
| 30 | ;;
|
---|
| 31 | "sync")
|
---|
| 32 | SYNC=true; shift
|
---|
| 33 | ;;
|
---|
[10916] | 34 | "-h")
|
---|
| 35 | usage; exit 0;;
|
---|
[10600] | 36 | *)
|
---|
| 37 | echo "Invalid Argument -- $1"
|
---|
| 38 | usage
|
---|
| 39 | ;;
|
---|
| 40 | esac
|
---|
| 41 | done
|
---|
| 42 |
|
---|
[10916] | 43 | # To sync we need to now the content of /cfg
|
---|
| 44 | mount -r /cfg || exit 1
|
---|
[10600] | 45 |
|
---|
[10916] | 46 | # Leave disks in consistent state on exit
|
---|
| 47 | trap "umount /cfg; mount -ur /"
|
---|
| 48 | trap "exit 1" 1 2 15
|
---|
| 49 |
|
---|
| 50 | $SYNC && mount -uwo noatime / || exit 1
|
---|
[10600] | 51 | for file in `find /conf/base/etc -type f`; do
|
---|
| 52 | live_file=${file##/conf/base}
|
---|
| 53 | conf_file=/cfg${file##/conf/base/etc}
|
---|
| 54 |
|
---|
| 55 | # Do not sync files stored on the config mount
|
---|
| 56 | [ -r $conf_file ] && continue
|
---|
| 57 |
|
---|
| 58 | if ! cmp $file $live_file; then
|
---|
| 59 | $VERBOSE && diff $file $live_file
|
---|
| 60 | $SYNC && cp -v $live_file $file
|
---|
| 61 | fi
|
---|
| 62 | done
|
---|
| 63 |
|
---|
[10916] | 64 | if ! $SYNC; then
|
---|
| 65 | echo "# Dryrun done, commit changes by calling: $0 sync"
|
---|
| 66 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.