2 # Functions to handle the main @FORGENAME@ configuration file
4 mainconfdir=/etc/@PACKAGE@
5 mainconffile=$mainconfdir/@PACKAGE@.conf
6 create_mainconffile () {
7 if [ ! -e $mainconfdir ] ; then
10 if [ ! -e $mainconffile ] ; then
12 chmod 600 $mainconffile
15 init_debconf_from_mainconffile () {
16 for i in $(grep -v "^ *#" $mainconffile | sort -u | cut -d= -f1) ; do
17 update_onevar_from_mainconfile $i
20 update_onevar_from_mainconfile () {
22 update_onevar_from_mainconfile__retcode=0
23 value=$(grep ^$key= $mainconffile | tail -1 | cut -d= -f2-)
24 if [ ! -z "$value" ] ; then
25 db_set @PACKAGE@/shared/$key $value || update_onevar_from_mainconfile__retcode=$? || true
26 # case $update_onevar_from_mainconfile__retcode in
28 # echo "$key = $value injected into Debconf OK"
29 # db_fset @PACKAGE@/shared/$key seen true || true
32 # echo "$key = $value not injected into Debconf (non-existing question maybe?)"
35 # echo "Something wicked happened"
41 update_mainconffile () {
43 db_get @PACKAGE@/shared/$key
45 update_onevar_mainconffile $key $val
48 update_onevar_mainconffile () {
51 if grep -q "^$key=" $mainconffile ; then
52 newval=$(echo $val | sed -e 's/@/\\@/g' -e 's/\$/\\$/g' -e 's/\//\\\//g')
53 perl -pi -e "s/^$key=.*/$key=$newval/" $mainconffile
55 echo "$key=$val" >> $mainconffile