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


1.5
date	99.08.24.15.42.24;	author rkrusty;	state dead;
branches;
next	1.4;

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

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

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

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


desc
@@


1.5
log
@[IEM] moving all debian related files into packaging/debian to follow suit
@
text
@#! /bin/sh
# postinst script for skattek
#
# see: dh_installdeb(1)

set -e

case "$1" in
    configure)
	cp /usr/doc/skattek/skattek_config.php3 /etc/horde/modules >/dev/null 2>&1
       /usr/bin/hordesetup skattek
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.


exit 0


@


1.4
log
@[IEM] things allows us to use horde (1.2.x).  Fixing up debian pieces to
talk with new horde-core package
@
text
@@


1.3
log
@[IEM] Updating install procedures to work with new 2.2 horde-core package
@
text
@d10 1
@


1.2
log
@[IEM] final fixes
@
text
@d1 4
a4 4
#!/usr/bin/perl --
# Copyright 1999 Ivan E. Moore II
# See /usr/doc/skattek/copyright.
$|=1;
d6 1
a6 3
$etc='/etc/horde/skattek';
$syshostname=`hostname --fqdn`;
chop($syshostname=`hostname --fqdn`);
d8 4
a11 7
if (-s "/usr/sbin/apache-ssl") {
  $srm='/etc/apache-ssl/srm.conf';  
  $http='/etc/apache-ssl/httpd.conf';
} else {
  $srm='/etc/apache/srm.conf';
  $http='/etc/apache/httpd.conf';
}
d13 1
d15 1
a15 5
  if (-s "/usr/bin/psql") {
    $database='postgres';
  } else {
    $database='dummy';
  }
d17 5
a21 2
  $tmproot='/var/www';
  $buildopts ='/etc/horde/skattek/build.opts';
d23 2
a24 4
sub loadconf ($$;$)
{
    $parameter = 'DocumentRoot';
    $default = $_[1];
a25 7
    $file = (defined ($_[2]) ? $_[2] : "$http");
    $in = `egrep "^[:space:]*$parameter " $file 2> /dev/null| head -1`;
    $in =~ s/\s*$parameter //;
    chomp ($in);
    return $in if ($in ne "");
    return $default;
}
d27 1
a27 4
sub load_conf ($$;$)
{
    my $parameter = $_[0];
    my $default = $_[1];
a28 7
    my $file = (defined ($_[2]) ? $_[2] : "$srm"); 
    my $in = `egrep "^[:space:]*$parameter " $file 2> /dev/null| head -1`;
    $in =~ s/\s*$parameter //;
    chomp ($in);              
    return $in if ($in ne "");   
    return $default;              
}
a29 345
sub load_config_files ()
{
    $main::srmconf = `cat $srm`;
    $main::buildconf = (-f $buildopts ? `cat $buildopts`: '');

}


$write_srmconf = 0;
$restart_apache = 0;
$write_buildconf = 0;

sub make_corrections ()
{
    if (! ($srmconf =~ m/.*Alias\s+\/skattek\/\s+\/usr\/share\/horde\/skattek\//m))
    {
        print "Adding alias /skattek/ -> /usr/share/horde/skattek/ to srm.conf.\n";
        $srmconf =~ s/$/\n# Added for Skattek\n/s;
        $srmconf =~ s/$/Alias \/skattek\/ \/usr\/share\/horde\/skattek\/\n/s;
    if (! ($srmconf =~ m/.*Alias\s+\/skattek\s+\/usr\/share\/horde\/skattek\//m))
    {
        $srmconf =~ s/$/Alias \/skattek \/usr\/share\/horde\/skattek\/\n/s;
    }
        $write_srmconf++;
    }

  if (! ($database =~ dummy)) {
    if ($buildconf =~ m/.*--with-database=*/m)
    {
       system("rm /etc/horde/skattek/build.opts >> /dev/null 2>&1");
       system("touch /etc/horde/skattek/build.opts >> /dev/null 2>&1");
    }
    if (! ($buildconf =~ m/.*database=*/m))
    {
        print "Setting $database as your database option in build.opts\n";
        $buildconf =~ s/$/database=$database\n/s;
        $write_buildconf++;
    }
  }
}

if (! (-s "/etc/horde/skattek/defaults.php3")) {

  load_config_files ();
  make_corrections ();
  print "\nSeeing if the Database needs to be configured...\n";
  $db_owner = "postgres";
  $com1 = "/usr/bin/psql -d skattek -c '\\dt'";
  $com2 = "su - ";
  $com4 = ' -c "';
  $com3 = '" | grep fw_objects';
  if (system("$com2$db_owner$com4$com1$com3 >/dev/null"))
  {
    print "Attempting to auto-config PostgreSQL for you...\n";
    system("su - postgres -c '/usr/bin/psql template1 < /usr/doc/skattek/scripts/pgsql_create.sql'");
  } else {
    print "Postgres seems to be already configured\n";
  }

}

if (-s "/etc/horde/config") {
  $have_skattek = `cat /etc/horde/config | grep skattek`;
  if ($have_skattek)  {
     print "\n";
} else {
     system ("echo 'skattek\n' >> /etc/horde/config");
  }
}


if ($write_buildconf)
{
    system ("savelog -c 100 $buildopts >> /dev/null 2>&1")
        && die ("couldn't rotate $buildopts\n");
    open (CONF, ">$buildopts") || die ("couldn't open $buildopts\n");
    print CONF $buildconf;
    close (CONF);
}

if ($write_srmconf)
{
    system ("savelog -c 100 $srm >> /dev/null 2>&1")
        && die ("couldn't rotate $srm");
    open (CONF, ">$srm") || die ("couldn't open $srm");
    print CONF $srmconf;
    close (CONF);
    $restart_apache++;
}

if (-s "/etc/horde/skattek/defaults.php3") {

system("chmod -R 644 /usr/share/horde/lib/*.lib >> /dev/null 2>&1");
system("chmod -R 644 /usr/share/horde/skattek/lib/*.lib >> /dev/null 2>&1");

### Configure Skattek Libraries ###

   print "
Building Skattek Libraries for your specific installation

   (Not Needed Yet)
";


## Build the libraries ##

   system("cp /etc/horde/skattek/defaults.php3.bak /etc/horde/skattek/defaults.php3 >> /dev/null 2>&1");

### Change file permissions for security ###

 system("chown -R www-data.root /etc/horde >> /dev/null 2>&1");
 system("chown -R www-data.root /usr/share/horde >> /dev/null 2>&1");
 system("chmod -R 555 /usr/share/horde/skattek/lib/*.lib >> /dev/null 2>&1");
 system("chmod 555 /etc/horde/skattek/* >> /dev/null 2>&1");
 system("chmod -R o-rwx /etc/horde/skattek >> /dev/null 2>&1");
 system("chmod -R 555 /usr/share/horde/lib/*.lib >> /dev/null 2>&1");

     print "\n\nSkattek is already configured; I\'ll leave\n";
     print "the existing configuration untouched in a .bak \n";


if ($restart_apache)
{
  if (-s "/usr/sbin/apache-ssl") {
    print "\nRestarting Apache-SSL...\n";
    system("/etc/init.d/apache-ssl restart >> /dev/null 2>&1")
  } else {
    print "\nRestarting Apache...\n";
    system("/etc/init.d/apache restart >> /dev/null 2>&1")
  }
}  

        exit(0);
}



    undef @@files;

		$configtype='1';
    if (-s "/usr/bin/psql") {
                $dbtype='pgsql';
		$skattekmgr="www-data";
	 	$skattekmgr_passwd='';
		$configtype='3';
    } 

sub buildconf() {


    if (-s "/usr/bin/psql") {
                $dbtype='pgsql';
                $skattekmgr="www-data";
                $skattekmgr_passwd='';
                $configtype='3';
    } 


    &setfile('defaults.php3',
'<?php',
"

/*

 Copyright 1999: Ivan E. Moore II <rkrusty\@@tdyc.com>

 You should have received a copy of the GNU Public
 License along with this package; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.

 */

/* For debugging purposes */
\$default->error_level               = 15;

\$default->max_execution_time        = 0;

\$default->localhost                 = 'ruins.tdyc.com';

/* Web server configuration */
\$default->root_url                  = '/horde/skattek';
\$default->include_dir             = './templates';
\$default->graphics_url              = \$default->root_url . '/graphics';

\$default->cache_pages               = false;

\$default->path_to_ipchains          = '/sbin/ipchains';
\$default->path_to_ipfwadm           = '/sbin/ipfwadm';
\$default->path_to_ssh               = '/usr/bin/ssh';

\$default->cookie_timeout            = '10000';
\$default->secure                    = true;
\$default->language                  = 'en';

\$default->db_type                   = 'pgsql';
\$default->db_user_name              = 'www-data';
\$default->db_password               = 'beavis';
\$default->db_name                   = 'skattek';
\$default->db_server_name            = 'localhost';
\$default->db_objects_table          = 'objects';
\$default->db_fw_users_table         = 'fw_users';
\$default->db_policy_table           = 'policy';
\$default->db_fw_objects_table       = 'fw_objects';
\$default->db_services_table         = 'services';
\$default->db_connect_string         = '';
\$default->db_server_port            = '';
\$default->db_server_options         = '';
\$default->db_server_tty             = '';

?>
");     



sub setfileshort {
    local ($filename,$value) = @@_;
    push(@@files,$filename);
    $filecontents{$filename}= $value;
}

sub setfile {
    local ($filename,$value1,$value2,$d) = @@_;
    chop($d=`date`);
    $v=
"$value1\
$value2";
    push(@@files,$filename);
    $filecontents{$filename}=$v;
}

sub reswarn {
    print STDERR "$_[0]\n";
    return 0;
}

for $f (@@files) {
    open(N,">$etc/$f.postinstnew") || die "Error creating $etc/$f.postinstnew: $!\n";
    print(N $filecontents{$f}) || die "Error writing $etc/$f.postinstnew: $!\n";
    close(N) || die "Error closing $etc/$f.postinstnew: $!\n";
}

while (defined($f= pop(@@files))) {
    rename("$etc/$f.postinstnew","$etc/$f") || die "Error installing $etc/$f: $!\n";
}


while (defined($f= pop(@@files))) {
    rename("$etc/$f.postinstnew","$etc/$f") || die "Error installing $etc/$f: $!\n";
}


}

sub query {
    local ($question, $varname, $default, $check, $opts) = @@_;
    local ($allowempty, $response, $e);
    print "\n";
    $allowempty= $opts =~ m/e/;
    if (eval "defined(\$$varname)") {
        $default= eval "\$$varname";
        $default='none' if $default eq '' && $allowempty;
    }
    for (;;) {
        print "$question\nEnter value (";
        print "default=\`$default', " if length($default);
        print "\`x' to restart): ";
	$!=0; defined($iread=<STDIN>) || die "skattekconfig: EOF/error on stdin: $!\n";
        $_= $iread; s/^\s+//; s/\s+$//;
        return 0 if m/^x$/i;
        $_= $default if $_ eq '';
        if (!length($_)) {
            print "  Sorry, you must enter a value.\n";
            next;
        }
        $_= '' if $_ eq 'none' && $allowempty;
        $response= $_;
        last if eval $check;
        if (length($@@)) {
            print STDERR "  Aargh, bug - bug - please report:\n$@@\nin\n $check\n";
            last;
        } else {
            print "  Sorry, that value is not acceptable.\n";
        }
    }
    $e= "\$$varname = \$response;";
    eval $e; length($@@) && die "aargh - internal error ($e): $@@";
    1;
}


### Configure Skattek Libraries ###

 buildconf();

### Restart Database ###

if ($configtype == 3) {
  print "
Restarting PostgreSql";
  system("/etc/init.d/postgresql restart >> /dev/null 2>&1 ");
}

### Change file permissions for security ###

  system("chown -R www-data.root /etc/horde >> /dev/null 2>&1");
  system("chown -R www-data.root /usr/share/horde >> /dev/null 2>&1");
  system("chmod -R 555 /usr/share/horde/skattek/lib/*.lib >> /dev/null 2>&1");
  system("chmod 555 /etc/horde/skattek/* >> /dev/null 2>&1");
  system("chmod -R o-rwx /etc/horde/skattek >> /dev/null 2>&1");
  system("chmod -R 555 /usr/share/horde/lib/*.lib >> /dev/null 2>&1");

###  Restart the web server ###

 if (-s "/usr/sbin/apache-ssl") {
   print "
Restarting Apache-SSL";
   system("/etc/init.d/apache-ssl restart");

 } else {
    if (-s "/usr/sbin/apache") {
   print "
Restarting Apache";
   system("/etc/init.d/apache restart >> /dev/null 2>&1");

    } else {
   print "
Please restart your web server";
    }
 }

### Extra Information ###
print "

You can now point your browser to:

         http://$syshostname/horde
	 Login: fwadmin
	 Pass:  fwadmin

";

system("sleep 5");

### Done ###
@


1.1
log
@[IEM] database build procedures.  Debian package now configures postgres
properly (as long as pam-apps isn't installed).
@
text
@d99 13
a111 18
  print "\nSeeing if the Database needs to be configured...
  ";
    $db_owner = "postgres";
    $scripts = "/usr/share/skattek/scripts";
    $com1 = "/usr/bin/psql -d skattek -c '\\dt'";     
    $com2 = 'su - ';
    $com4 = ' -c "';
    $com3 = '" | grep fw_objects > /tmp/skattektemp.txt';
    system("$com2$db_owner$com4$com1$com3");
    $main::skattektemp = `cat /tmp/skattektemp.txt`;
    if (! ($skattektemp = ~ m/.*fw_objects*/m))
    {
      print "Attempting to auto-config PostgreSQL for you...\n";
      system("su - $db_owner -c '/usr/bin/psql template1 < $scripts/pgsql_create.sql'");
    } else {
      print "Postgres seems to be already configured\n";
    }
    system("rm /tmp/skattektemp.txt >>/dev/null 2>&1");
@

