summaryrefslogtreecommitdiffstats
path: root/update-conf.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-05-06 09:53:36 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-05-06 09:53:36 +0000
commitec0c7a74bbf5824adc4efa54e1f91984ac870a8e (patch)
tree7f5a8763836154b10c8325629b493ebc67ead7e6 /update-conf.in
parentf590563940559429ffe77094473d12361937852d (diff)
downloadalpine-conf-ec0c7a74bbf5824adc4efa54e1f91984ac870a8e.tar.bz2
alpine-conf-ec0c7a74bbf5824adc4efa54e1f91984ac870a8e.tar.xz
move to .in files
Diffstat (limited to 'update-conf.in')
-rw-r--r--update-conf.in88
1 files changed, 88 insertions, 0 deletions
diff --git a/update-conf.in b/update-conf.in
new file mode 100644
index 0000000..6a8ab16
--- /dev/null
+++ b/update-conf.in
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+
+PREFIX=
+. $PREFIX/lib/libalpine.sh
+
+# set up temp dir
+init_tmpdir TMPD
+
+LBUCACHE="$TMPD/lbucache"
+
+usage() {
+ echo "$PROGRAM $VERSION
+Usage: $PROGAM [-aihl]
+
+ -a Select all updated files.
+ -h Show this help.
+ -i Use all new init.d scripts.
+ -l List updated files.
+"
+}
+
+
+is_modified() {
+ [ -f "$LBUCACHE" ] || lbu status -a | awk '{print $2}' > "$LBUCACHE"
+ test -n "`( echo \"$1\" ; cat \"$LBUCACHE\" ) | sort | uniq -d`"
+}
+
+
+is_initd() {
+ echo "$1" | grep etc/init.d/ > /dev/null
+}
+
+while getopts "alih" opt ; do
+ case "$opt" in
+ a) aflag="-a" ;;
+ i) iflag="-i" ;;
+ l) lflag="-l" ;;
+ h|*) usage;;
+ esac
+done
+shift `expr $OPTIND - 1`
+
+for apknew in $(find "$ROOT/etc" -name '*.apk-new') ; do
+ p="${apknew%.apk-new}"
+ f="${p#${ROOT}/}"
+ unset choice
+
+ if [ "$lflag" ] ; then
+
+ # just list the file
+ if [ "$aflag" ] || is_modified "$f" ; then
+ echo "$p"
+ fi
+
+ elif [ "$aflag" ] || is_modified "$f" ; then
+ if [ "$iflag" ] && is_initd "$f" ; then
+ echo "Autoupdating $p"
+ mv "$apknew" "$p"
+ continue
+ fi
+
+ diff -u "$p" "$apknew"
+
+ # ask user what to do with the file
+ while [ -z "$choice" ] ; do
+ echo "New $p available:"
+ echon "Quit, Next, Show diff, Edit new, Zap new, Use new (q/n/s/e/z/u) [s]: "
+ default_read choice "s" </dev/tty
+ case "$choice" in
+ q) exit;;
+ n) continue;;
+ s) diff -u "$p" "$apknew" | ${PAGER:-less}
+ unset choice
+ ;;
+ e) ${EDITOR:-vi} "$apknew" ; unset choice;;
+ z) rm "$apknew";;
+ u) mv "$apknew" "$p";;
+ *) unset choice;;
+ esac
+ done
+ else
+ # auto update
+ echo "Autoupdating unchanged $p"
+ mv "$apknew" "$p"
+ fi
+done
+