* uninstaller.pl to uninstall Koha
[koha.git] / misc / uninstall.pl
1 #!/usr/bin/perl
2
3 sub ReadConfigFile
4 {
5         my $fname = shift;      # Config file to read
6         my $retval = {};        # Return value: ref-to-hash holding the configuration
7         open (CONF, $fname) or return undef;
8         while (<CONF>) {
9                 my $var;                # Variable name
10                 my $value;              # Variable value
11                 chomp;
12                 s/#.*//;                # Strip comments
13                 next if /^\s*$/;        # Ignore blank lines
14                 next if (!/^\s*(\w+)\s*=\s*(.*?)\s*$/);
15                 $var = $1;
16                 $value = $2;
17                 $retval->{$var} = $value;
18         }
19         close CONF;
20         return $retval;
21 }
22
23 my $config = ReadConfigFile("/etc/koha.conf");
24 # to remove web sites:
25 print "\nrm -rf ".$config->{intranetdir};
26 print "\nrm -rf ".$config->{opacdir};
27 # remove mySQL stuff
28 # DB
29 print "\nmysqladmin -f -u".$config->{user}." -p".$config->{pass}." drop ".$config->{database};
30 # user
31 print "enter mySQL root password, please\n";
32 my $response=<STDIN>;
33 chomp $response;
34 print "\nmysql -uroot -p$response -Dmysql -e\"delete from user where user='".$config->{user}.'"';
35 # reload mysql
36 print "\nmysqladmin -uroot -p$response reload";
37 print "\nrm -f /etc/koha-httpd.conf";
38 print "\nrm -f /etc/koha.conf";
39 print "\nEDIT httpd.conf to remove /etc/koha-httpd.conf\n";