Re: [Koha-devel] No Koha Uninstall Script.

2009-07-07 Thread Koha-Developer


I've been giving Bug 459 (No unistall script) some thought. And I've come up 
with what might well be a solution. I'd be interested to hear thoughts on the 
matter.



*

[1] I've taken Galen's suggestion and added support for multiple machine 
architectures. 
Ostensibly this is to support unixes and variants who do not use /usr/sbin to 
store userdel & groupdel commands.

[2] I've removed comments about the install logfile holding misleading 
information. I believe those comments were probably mistaken and am 
investigating the matter further.


** help wanted:
I'd like suggestions of Perl Interpreter Machine Type Operating System 
Classifications for any machines which do not use the /usr/sbin directory for 
the commands userdel and groupdel

with the exception of FreeBSD (or BSDs in general) if they do not have a 
groupdel command of some kind. (Not a procedure for editing the group file, and 
so forth. It must be one single command.) (**Please do not send instructions 
for procedures for editing users and groups.)

Patrick Mackeown#!/usr/bin/perl -w # please develop with -w
#
# chances are you'll need to install CPAN IO::Tee
# perl -MCPAN -e'install "IO::Tee"'
#
# written @ Mon Jul 06 13:40:53 EDT 2009  patc...@koha.org
#

use strict;# please develop with the strict pragma
use Config;
use IO::Tee;
use diagnostics;
use DBI;
use File::Copy;
use File::Path; 

###
#  Global Assignments
#   (You may edit these values)
###

my $LOGDIR="/var/log/koha";
my $ETCDIR="/etc/koha";
my $DROPMODE="";
my $DELCOMPLETE="";
my $MODE="SAFE";
my $KOHAROOT="";
my $CONFIGFILE="";
my $TEE_DUAL_OUTPUT;
my @kohausers =qw(koha kohaadmin kohauser);
my @kohagroups =qw(koha kohaadmin kohauser);

###
# Support Multiple Machine Architectures
###
my $deluser;
my $delgroup;
for ($Config{myarchname}) {
  if (/i686-linux/) { 
$deluser= "/usr/sbin/userdel"; 
$delgroup= "/usr/sbin/groupdel"; 
  }elsif (/i86pc-solaris/){
$deluser= "/usr/sbin/userdel"; 
$delgroup= "/usr/sbin/groupdel"; 
  }elsif (/sun4-solaris/){
$deluser= "/usr/sbin/userdel"; 
$delgroup= "/usr/sbin/groupdel"; 
   }else { 
$deluser= "/usr/sbin/userdel"; 
$delgroup= "/usr/sbin/groupdel"; }
} 

###
#   Program Main
#   (Do not edit)
###
#[1] Open an uninstall logfile
 & open_logfile;

#[2] Ask for deletion info. But, only do this as an input flag
#or if you cannot locate any del info 
if ($ARGV[0]){
   if ($ARGV[0] =~ /-user/){
   & user_input;
   }else{
   if ($ARGV[0] =~ /-h\b|-help\b/i){
  & printhelp;
  exit 0;
   }else{
   if ($ARGV[0] =~ /-dropdb\b/i){
  & drop_the_koha_db;
  exit 0;
   }
   }
   }
}else{
& printhelpshort;
}
#Search for ENV variables
 & locate_env_variables;
###
# The Unix Help Documentation 
###

sub printhelp{
print $TEE_DUAL_OUTPUT > /tmp/koha_uninstall_history.log", 
\*STDOUT);
}


sub is_this_authentic_koha_root{

   my $BADUNINSTALLINFO="";
   my $manyerrors="0";
   my @KOHAFILES=qw( bin  doc  intranet  lib  man  misc  opac );
   foreach (@KOHAFILES) {
  if ($manyerrors < 3){
   if ( !-d "$KOHAROOT/$_"){
  ++$manyerrors;
  $BADUNINSTALLINFO="True";
  & warnaboutroot;
   }
  # Bailout of uninstall. You've been given bad uninstall info.
   } else {
  if ($manyerrors < 3){;
 if ( -f "$KOHAROOT/$_"){
 print $TEE_DUAL_OUTPUT "Validating $KOHAROOT [Found] 
$_\n";
 }
  }
   }
   } 
if ( "$BADUNINSTALLINFO" !~ /True/){
 & okibelieve;
 & prep_genuine_root_del;
}
}



sub locate_env_variables{
  #  The first thing we need to do is test for ENV variables
  if ($ENV{KOHA_CONF}){
 print $TEE_DUAL_OUTPUT "\n [Found] ENV Variable $ENV{KOHA_CONF}  
\n";
 & try_etc_koha_conf_xml;
  }
  if (!$ENV{PERL5LIB}){
 if (!$

[Koha-devel] Suggestions Wanted For Koha Uninstall Script.

2009-07-07 Thread Koha-Developer
I've been giving Bug 459 (No unistall script) some thought. And I've come up 
with what might well be a solution. I'd be interested to hear thoughts on the 
matter.



*

[1] I've taken Galen's suggestion and added support for multiple machine 
architectures. 
Ostensibly this is to support unixes and variants who do not use /usr/sbin to 
store userdel & groupdel commands.

[2] I've removed comments about the install logfile holding misleading 
information. I believe those comments were probably mistaken and am 
investigating the matter further.


** help wanted:
I'd like suggestions of Perl Interpreter Machine Type Operating System 
Classifications for any machines which do not use the /usr/sbin directory for 
the commands userdel and groupdel

with the exception of FreeBSD (or BSDs in general) if they do not have a 
groupdel command of some kind. (Not a procedure for editing the group file, and 
so forth. It must be one single command.) (**Please do not send instructions 
for procedures for editing users and groups.)


A demonstration Koha uninstall script is here:
http://www.help-desks.co.uk/downloads/uninstall_koha.pl.txt
  
Patrick Mackeown___
Koha-devel mailing list
Koha-devel@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-devel