head	1.4;
access;
symbols;
locks; strict;
comment	@# @;


1.4
date	99.12.20.22.17.11;	author rkrusty;	state Exp;
branches;
next	1.3;

1.3
date	99.10.18.11.15.16;	author rkrusty;	state Exp;
branches;
next	1.2;

1.2
date	99.10.15.01.08.38;	author rkrusty;	state Exp;
branches;
next	1.1;

1.1
date	99.08.24.15.42.25;	author rkrusty;	state Exp;
branches;
next	;


desc
@@


1.4
log
@[IEM] debconf cleanup
@
text
@#! /bin/sh -e
# Horde postinst script using debconf
# written by Ivan E. Moore II <rkrusty@@tdyc.com> with help from
# debconf examples and tons of other references
#

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

# Where the config file is that stores the previous selections
DEFAULTS_FILE="/etc/skattek/defaults.php3";
TEMPLATE="/etc/skattek/defaults.php3.in";

## Grab some extra db info from horde configs
  db_input "medium" "horde/database_type"
  db_go
  db_get "horde/database_type"
  dbtype="$RET"
  db_input "medium" "horde/database_server"
  db_go
  db_get "horde/database_server"
  dbserver="$RET"
  db_input "medium" "horde/database_name"
  db_go
  db_get "horde/database_name"
  dbname="$RET"
  db_input "medium" "horde/database_user"
  db_go
  db_get "horde/database_user"
  dbuser="$RET"
  db_input "medium" "horde/database_pass"
  db_go
  db_get "horde/database_pass"
  dbpass="$RET"

## Ok set our temp file to use
TMPFILE=`mktemp /tmp/skattek.XXXXXX` || exit 1

### Set the shell variable so that it can be sourced in
echo "#!/bin/sh" >>$TMPFILE 2>&1;
echo "# Config file read in by Skattek setup program" >>$TMPFILE
echo "# Autobuilt by debconf/hordeconf Do not edit" >>$TMPFILE
echo "#" >>$TMPFILE
echo "#  DO NOT EDIT" >>$TMPFILE
echo "#" >>$TMPFILE
echo "# configure program (defaults.php3)" >>$TMPFILE

## Ok, now we need to run through the choices ##
for i in `cat $OPTIONS_FILE | grep -v "#"`; do
  # go get the value, prompt for it if we don't have it
  db_input "medium" "skattek/$i"
  db_go
  # set the tmp file with this value
  db_get "skattek/$i"
  echo "$i=\"$RET\";" >>$TMPFILE
done

# Now drop the newly created file into it's place
mv $TMPFILE $CHOICES_FILE > /dev/null 2>&1;
chmod 755 $CHOICES_FILE
chmod go-rwx $CHOICES_FILE

# Read in the new values
. $CHOICES_FILE

# Now let's create the defaults.php3 file needed by Skattek
echo "<?php" >>$TMPFILE
echo "" >>$TMPFILE
echo "/* For debugging purposes */" >>$TMPFILE
echo "\$default->error_level               = 15;" >>$TMPFILE
echo "" >>$TMPFILE
echo "\$default->max_execution_time        = 0;" >>$TMPFILE
echo "" >>$TMPFILE
echo "/* Web server configuration */" >>$TMPFILE
echo "\$default->root_url                  = '$root_url';" >>$TMPFILE
echo "\$default->include_dir             = '$include_dir';" >>$TMPFILE
echo "\$default->graphics_url              = '$graphics_url';" >>$TMPFILE
echo "" >>$TMPFILE
echo "\$default->cache_pages               = false;" >>$TMPFILE
echo "" >>$TMPFILE
echo "\$default->path_to_ipchains          = '$path_to_ipchains';" >>$TMPFILE
echo "\$default->path_to_ipfwadm           = '$path_to_ipfwadm';" >>$TMPFILE
echo "\$default->path_to_ssh               = '$path_to_ssh';" >>$TMPFILE
echo "" >>$TMPFILE
echo "\$default->cookie_timeout            = '10000';" >>$TMPFILE
echo "\$default->secure                    = true;" >>$TMPFILE
echo "\$default->language                  = '$language';" >>$TMPFILE
echo "" >>$TMPFILE
echo "\$default->db_objects_table          = 'objects';" >>$TMPFILE
echo "\$default->db_fw_users_table         = 'fw_users';" >>$TMPFILE
echo "\$default->db_policy_table           = 'policy';" >>$TMPFILE
echo "\$default->db_fw_objects_table       = 'fw_objects';" >>$TMPFILE
echo "\$default->db_services_table         = 'services';" >>$TMPFILE
echo "" >>$TMPFILE
echo "?>" >>$TMPFILE


# Now lets move that file into place

mv $TMPFILE $DEFAULTS_FILE > /dev/null 2>&1

##  Now take care of the rest of the conf files needing changed


##  We need to figure out what type of database to use now:

if [ "$dbtype" = "PostgreSQL" ]; then

  /bin/sed -e "s#@@dbname@@#$dbname#" /usr/share/doc/skattek/examples/pgsql_create.sql > /etc/skattek/pgsql_create.sql

  db_input "medium" "skattek/dbconfigured"
  db_go
  db_get "skattek/dbconfigured"
  if [ "$RET" = "no" ] ; then
   PSQL2_QUERY="GRANT SELECT, INSERT, UPDATE ON active_sessions, auth_user,auth_user_md5, objects, rules, services, policy, fw_objects TO $dbuser"
    su - postgres -c '/usr/bin/psql -q template1 < /usr/share/doc/skattek/examples/pgsql_create.sql >/dev/null 2>&1'
    su - postgres -c '/usr/bin/psql -q horde -c "$PSQL2_QUERY" >/dev/null 2>&1'
    db_set "skattek/dbconfigured" "yes"
  fi
  /etc/init.d/postgresql restart > /dev/null 2>&1
  (cd /usr/share/horde/skattek/lib/src && ./build.pl --database=postgres >/dev/null 2>&1)

fi

###  Done with the database stuff, move on to the next item on the list

db_input "medium" "horde/webserver_type"
db_go
db_get "horde/webserver_type"
webtype="$RET"

if [ "$webtype" = "Apache" ]; then
  if (!(grep 'Added for SKATTEK' /etc/apache/srm.conf >/dev/null 2>&1)); \
  then \
    echo '# Added for SKATTEK' >> /etc/apache/srm.conf ;\
    echo 'Alias /skattek /usr/share/horde/skattek' >> /etc/apache/srm.conf ; \
  fi
  /etc/init.d/apache reload >/dev/null 2>&1
fi

if [ "$webtype" = "Apache-SSL" ]; then
  if (!(grep 'Added for SKATTEK' /etc/apache-ssl/srm.conf >/dev/null 2>&1)); \
  then \
    (echo '# Added for SKATTEK' >> /etc/apache-ssl/srm.conf ;\
    echo 'Alias /skattek /usr/share/horde/skattek' >> /etc/apache-ssl/srm.conf); \
  fi
  /etc/init.d/apache-ssl reload >/dev/null 2>&1
fi

chown -R www-data.root /usr/share/horde >> /dev/null 2>&1
chown -R www-data.root /etc/skattek >> /dev/null 2>&1
chmod -R 555 /usr/share/horde/skattek/lib/*.lib >> /dev/null 2>&1
chmod 555 `find /etc/skattek/ -type f -print ` >/dev/null 2>&1
chmod o-rwx `find /etc/skattek/ -type f -print ` >/dev/null 2>&1

db_stop

#DEBHELPER#

exit 0
@


1.3
log
@[IEM]

    1> Start of Debian migration to debconf
    2> removing obsolete db.lib
    3> adding delete/update functions for objects
    4> merging fwobjects and objects
    5> getting rid of some non-used variables
    6> cleaning up db tables a bit more
    7> getting rid of html.php3..using html.php3.dist instead
    8> getting rid of calls to db.php3 and adding calls to horde.php3
@
text
@a10 2
CHOICES_FILE="/etc/skattek/defaults.choices";
OPTIONS_FILE="/etc/skattek/defaults.options";
d12 1
a12 15
HCHOICES_FILE="/etc/horde/defaults.choices";
HCHOICES_PHP="/etc/horde/horde.choices";

# read those selections in if and only if they exist
if [ -f "$CHOICES_FILE." ]; then
   . $CHOICES_FILE
fi

if [ -f "$HCHOICES_FILE." ]; then
   . $HCHOICES_FILE
fi

if [ -f "$HCHOICES_PHP." ]; then
   . $CHOICES_PHP
fi
d37 1
a37 2
p=`basename $0`
TMPFILE=`mktemp /tmp/$p.XXXXXX` || exit 1
d109 1
a109 3
  /bin/sed -e "s#@@dbname@@#$dbname#" /usr/share/doc/skattek/examples/pgsql_create.sql > /usr/share/doc/skattek/examples/pgsql_create.sql.new
  cp /usr/share/doc/skattek/examples/pgsql_create.sql /usr/share/doc/skattek/examples/pgsql_create.sql.bak >/dev/null 2>&1
  mv /usr/share/doc/skattek/examples/pgsql_create.sql.new /usr/share/doc/skattek/examples/pgsql_create.sql >/dev/null 2>&1
d133 1
a133 1
  if (grep 'Added for SKATTEK' /etc/apache/srm.conf >/dev/null 2>&1); \
a134 2
    (notsome="1"); \
  else \
d142 1
a142 1
  if (grep 'Added for SKATTEK' /etc/apache-ssl/srm.conf >/dev/null 2>&1); \
a143 2
    (notsome="1"); \
  else \
a157 5





a160 2


@


1.2
log
@[IEM] Migrating skattek to debconf. (debian build stuff)
      Updating the defaults.php3.dist file removing unneeded items
      Same with the pgsql create script
      Updating Changes, version number, etc...
      Removing unneeded default options from the object
      Slowly moving away from a db.lib and towards phplib
@
text
@a90 2
echo "\$default->localhost                 = '$localhost';" >>$TMPFILE
echo "" >>$TMPFILE
d94 1
a94 1
echo "\$default->graphics_url              = $graphics_url';" >>$TMPFILE
@


1.1
log
@[IEM] moving all debian related files into packaging/debian to follow suit
@
text
@d1 4
a4 2
#! /bin/sh
# postinst script for skattek
a5 1
# see: dh_installdeb(1)
d7 2
a8 1
set -e
d10 170
a179 5
case "$1" in
    configure)
	cp /etc/skattek/skattek_module_config.php3 /etc/horde/modules >/dev/null 2>&1
       /usr/bin/hordesetup skattek
    ;;
d181 1
a181 1
    abort-upgrade|abort-remove|abort-deconfigure)
a182 1
    ;;
a183 5
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac
a184 2
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
d186 3
@

