File: configupdate

package info (click to toggle)
mysql-query-browser 1.2.5beta-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 63,792 kB
  • ctags: 46,485
  • sloc: pascal: 249,299; ansic: 80,111; cpp: 72,467; sh: 25,271; objc: 20,015; yacc: 10,755; java: 9,917; xml: 4,580; php: 2,806; python: 1,566; sql: 1,563; makefile: 1,452; perl: 3
file content (61 lines) | stat: -rw-r--r-- 1,304 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash

# Original written and copyright by Adam Majer <adamm@zombino.com>
#
# This file is 100% public domain. Use it for whatever you wish.
#

function update_configs()
{
	[ -x /usr/share/misc/config.${1} ] || return 0
	LATEST_VERSION=`/usr/share/misc/config.${1} -t`
	UPDATE_FILES=`find -type f | grep "/config\.${1}\$"`

	echo "Latest version of config.${1} file is ${LATEST_VERSION}"
	for i in $UPDATE_FILES; do
		head -1 "$i" | grep -q '#!.*\/bin\/sh'
		EXE=$?
		if [ -x "$i" ] || [ $EXE -eq 0 ]; then
			V=`sh -e "${i}" -t`
			echo "Updating ${V} version file at  ${i}"
			if [[ "$LATEST_VERSION" > "$V" ]]; then
				mv "${i}" "${i}.orig_update"
				ln -s /usr/share/misc/config.$1 "${i}"
			else
				echo "WARNING: Debian version of config.${1} is older than this package's upstream."
			fi
		fi
	done
	return 0
}


function reset_configs()
{
	UPDATED_FILES=`find -type l | grep "/config\.${1}\$"`
	for i in ${UPDATED_FILES}; do
		if [ -e "${i}.orig_update" ]; then
			mv "${i}.orig_update" "${i}"
		fi
	done
	return 0
}


# Check if we are updating, reseting or whatever
case "$1" in
	update)
		update_configs sub
		update_configs guess
		;;
	reset)
		reset_configs sub
		reset_configs guess
		;;
	*)
		echo "The only allowed parameters are 'update' or 'reset'"
		exit 2;
		;;
esac

exit 0