Last change
on this file since 10694 was 10600, checked in by rick, 13 years ago |
Well, this is properly the nicest poor mans config sync solution I can think
of. Most changes are config related /etc or /usr/local/etc (mapped to
/etc/local) this would nicely allow the items get synced to permanent storage
of the running image.
|
-
Property svn:executable
set to
*
|
File size:
1.1 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:
|
---|
| 16 | dryrun - Check the pending changes
|
---|
| 17 | sync - Sync the pending changes
|
---|
| 18 | EOF
|
---|
| 19 | exit ${1:-128}
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | while [ -n "$1" ]; do
|
---|
| 23 | case "$1" in
|
---|
| 24 | "-v")
|
---|
| 25 | VERBOSE=true; shift
|
---|
| 26 | ;;
|
---|
| 27 | "dryrun")
|
---|
| 28 | SYNC=false; shift
|
---|
| 29 | ;;
|
---|
| 30 | "sync")
|
---|
| 31 | SYNC=true; shift
|
---|
| 32 | ;;
|
---|
| 33 | *)
|
---|
| 34 | echo "Invalid Argument -- $1"
|
---|
| 35 | usage
|
---|
| 36 | ;;
|
---|
| 37 | esac
|
---|
| 38 | done
|
---|
| 39 | [ -z "$SYNC" ] && usage
|
---|
| 40 |
|
---|
| 41 | trap "umount /cfg; mount -ur /" 1 2 15 EXIT
|
---|
| 42 | mount -r /cfg
|
---|
| 43 | $SYNC && mount -uwo noatime /
|
---|
| 44 |
|
---|
| 45 | for file in `find /conf/base/etc -type f`; do
|
---|
| 46 | live_file=${file##/conf/base}
|
---|
| 47 | conf_file=/cfg${file##/conf/base/etc}
|
---|
| 48 |
|
---|
| 49 | # Do not sync files stored on the config mount
|
---|
| 50 | [ -r $conf_file ] && continue
|
---|
| 51 |
|
---|
| 52 | if ! cmp $file $live_file; then
|
---|
| 53 | $VERBOSE && diff $file $live_file
|
---|
| 54 | $SYNC && cp -v $live_file $file
|
---|
| 55 | fi
|
---|
| 56 | done
|
---|
| 57 |
|
---|
| 58 | umount /cfg
|
---|
| 59 | mount -ur /
|
---|
| 60 | trap 1 2 15 EXIT
|
---|
Note:
See
TracBrowser
for help on using the repository browser.