1 #- beginning of included section from handle-mainconffile.config
3 # Functions to handle the main @FORGENAME@ configuration file
5 mainconfdir=/etc/@PACKAGE@
6 mainconffile=$mainconfdir/@PACKAGE@.conf
7 create_mainconffile () {
8 if [ ! -e $mainconfdir ] ; then
11 if [ ! -e $mainconffile ] ; then
12 if [ -e /etc/gforge/gforge.conf ] ; then
13 cp -a /etc/gforge/gforge.conf $mainconffile
17 chmod 600 $mainconffile
20 init_debconf_from_mainconffile () {
21 for i in $(grep -v "^ *#" $mainconffile | sort -u | cut -d= -f1) ; do
22 update_onevar_from_mainconfile $i
25 update_onevar_from_mainconfile () {
27 update_onevar_from_mainconfile__retcode=0
28 value=$(grep ^$key= $mainconffile | tail -1 | cut -d= -f2-)
29 if [ ! -z "$value" ] ; then
30 db_set @PACKAGE@/shared/$key $value || update_onevar_from_mainconfile__retcode=$? || true
31 # case $update_onevar_from_mainconfile__retcode in
33 # echo "$key = $value injected into Debconf OK"
34 # db_fset @PACKAGE@/shared/$key seen true || true
37 # echo "$key = $value not injected into Debconf (non-existing question maybe?)"
40 # echo "Something wicked happened"
46 update_mainconffile () {
48 db_get @PACKAGE@/shared/$key
50 update_onevar_mainconffile $key $val
53 update_onevar_mainconffile () {
56 if grep -q "^$key=" $mainconffile ; then
57 newval=$(echo $val | sed -e 's/@/\\@/g' -e 's/\$/\\$/g' -e 's/\//\\\//g')
58 perl -pi -e "s/^$key=.*/$key=$newval/" $mainconffile
60 echo "$key=$val" >> $mainconffile
63 #- end of included section from handle-mainconffile.config