source: hybrid/branches/releng-9.0/nanobsd/files/tools/sync-etc-changes-to-cf@ 10827

Last change on this file since 10827 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
Line 
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
10usage() {
11 cat <<EOF
12Usage: $0 [-v] <dryrun|sync>
13Options:
14 -v - Verbose diffs
15Arguments:
16 dryrun - Check the pending changes
17 sync - Sync the pending changes
18EOF
19 exit ${1:-128}
20}
21
22while [ -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
38done
39[ -z "$SYNC" ] && usage
40
41trap "umount /cfg; mount -ur /" 1 2 15 EXIT
42mount -r /cfg
43$SYNC && mount -uwo noatime /
44
45for 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
56done
57
58umount /cfg
59mount -ur /
60trap 1 2 15 EXIT
Note: See TracBrowser for help on using the repository browser.