File: config

package info (click to toggle)
uif 1.0.5-4.3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 312 kB
  • ctags: 30
  • sloc: perl: 1,812; sh: 231; makefile: 67
file content (71 lines) | stat: -rwxr-xr-x 1,609 bytes parent folder | download | duplicates (5)
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
62
63
64
65
66
67
68
69
70
71
#!/bin/sh -e

# Source debconf library.
. /usr/share/debconf/confmodule

is_ip() {
            echo "$1" | egrep -q '^([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])$'
}

is_net() {
    NET=`echo "$1" | cut -d/ -f1`
    MASK=`echo "$1" | cut -d/ -f2`
    is_ip "$MASK" && is_ip "$NET" && return 0
    echo "$MASK"|egrep -q '^([0-2]?[0-9]?|3[0-2])$' && is_ip "$NET" && return 0
    return 1
}

is_host() {
    host "$1" 2> /dev/null| egrep '([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' | cut -f3
}

# Chooser for conf_method
db_input high uif/conf_method || true
db_go

# Check their answer.
db_get uif/conf_method

case "$RET" in
	workstation)
		# show message
		db_input high uif/workstation || true
		db_go

		# configure ping / traceroutes
		db_input high uif/pings || true
		db_go

		db_input high uif/traceroute || true
		db_go
	
		# configure trusted hosts
		while true; do
			db_input high uif/trusted || true
			db_go
			db_get uif/trusted
		
			if [ -n "$RET" ]; then
				for i in $RET; do
					WORKS=0
					is_ip "$i" && WORKS=1
					[ $WORKS -eq "0" ] && is_net "$i" && WORKS=1
					[ $WORKS -eq "0" ] && HOST=`is_host "$i"`
					[ -n "$HOST" ] && WORKS=1
					if [ $WORKS -eq 0 ]; then
						db_input high uif/error || true
			                        db_go
						break
					fi
				done
				[ $WORKS -eq 0 ] && continue
			fi
			break
		done
		;;		

	*)
		;;
esac

exit 0