File: libphone-utils0.postinst

package info (click to toggle)
libphone-utils 0.1%2Bgit20110523-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 320 kB
  • ctags: 106
  • sloc: ansic: 1,031; sh: 72; python: 50; makefile: 46
file content (40 lines) | stat: -rw-r--r-- 871 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# postinst script for libphone-utils

set -e

. /usr/share/debconf/confmodule

cfgpath=/etc/phone-utils.conf

cfg_prep() {
	[ -f "$cfgpath" ] || touch "$cfgpath"
	grep -q '^\[local\]' "$cfgpath" || echo '[local]' >> "$cfgpath"
}

cfg_set() {
	var="$1" val="$2" perl -i -ple '
		s/^($ENV{var})[ \t]*=.*/$1 = $ENV{val}/ and $seen++;
		print STDERR "WARNING: option \"$ENV{var}\" set multiple times!\n" if ( $seen > 1 );
		s/$/\n$ENV{var} = $ENV{val}/ if (eof and ! $seen);
	' "$cfgpath"
}

if [ "$1" = "configure" ] ; then
	cfg_prep
	db_get libphone-utils/international_prefix
	cfg_set international_prefix $RET
	db_get libphone-utils/national_prefix
	cfg_set national_prefix $RET
	db_get libphone-utils/country_code
	cfg_set country_code $RET
	db_get libphone-utils/area_code
	cfg_set area_code $RET
fi

# tell debconf we are done
db_stop;

#DEBHELPER#

exit 0;