updated install script 15July2003
OGo Toasterz Admin <[email protected]>
| Newsgroups | gmane.comp.cms.opengroupware.discuss.general |
|---|---|
| Message-ID | <[email protected]> |
here's an updated version, with more useful features.
Major changes, improvement and additions from Gustavo Chavez, thanks!
- Include three missing rpms;
- Substitute a system call for the backticks so that I can see the
logs from the rpm call.
- Use a single rpm call with a list of all rpms to include to speed it
up a bit.
- Implemented two options (-n for do nothing and -v for verbosity).
I did these quickly... look over and test before you run on production
machine.
-added -f option to force rpm to install over existing packages
-added better usage text.
-added -a option to install all packages (postgres+Ogo)
hope you find it helpful.
more forthcoming.
kelley graham
http://www.toasterz.com
add_remove_ogo.pl
(text/plain, 4.1 KB)
#! /usr/bin/perl
# This is a simple perl script for installing ogo from rpms. I use redhat9 and it works for my needs. Use at your own risk. If it breaks your system, sorry, but I'm not liable for any losses or damages, etc. whatsoever.
# Copyright 2003 Kelley Graham http://www.toasterz.com
# License: LGPL
# Changelog ##############################################################
# 15July2003
# -added postgres install option
# -added force option
# -incorporated Gustavo Chavez' many enhancements, Thanks!.
# 13July2003
# -added comand line var and rudimentary sanity checks
# 12July2003
# -initial cobbling together
# -added libical before xml
# -removed libxmlsaxdriver line since it is included in the xml package
# Todo ###################################################################
#
# -add support for other distros (community help?)
# -add run script at end off install that starts needed services and seets defaults
# -add version check for postgresql, suggest upgrade if appropriate.
# -add "output debug info to file" switch.
# -add checks to wget the latest packages if not installed
use warnings;
use strict;
use Getopt::Std;
my $usage = "usage: $0 [-n] [-v] [-f] [-a] [install|remove] \n\nPass the script \"install\" to install-upgrade Opengroupware\nPass the script \"remove\" to remove Opengroupwware.\n\nOptions:\nTo install OGo \+ PostgresQL use the \"\-a\" switch. PostgresQL packages must be in directory.\nUse \"\-n\" to do nothing.\nUse \"\-v\" to get verbose debug output.\nUse \"\-f\" to force rpm to overwrite existing packages. (use with care) see man rpm.\n\n";
my %args;
getopts('nvfa', \%args) or die $usage;
my $action = shift or die $usage;
my @order = qw(
opengroupware-gstep-make*
opengroupware-gstep-objc*
opengroupware-libfoundation*
opengroupware-js*
opengroupware-libxml2*
opengroupware-libical-*
opengroupware-xml*
opengroupware-core*
opengroupware-gstep-db*
opengroupware-gstep-db-postgresql72*
opengroupware-sope*
opengroupware-env*
opengroupware-logic*
opengroupware-docapi*
opengroupware-database*
opengroupware-webui-libs*
opengroupware-webui-common*
opengroupware-webui-admin*
opengroupware-webui-app*
opengroupware-webui-contact*
opengroupware-webui-job*
opengroupware-webui-mailer*
opengroupware-webui-news*
opengroupware-webui-prefs*
opengroupware-webui-resource-en*
opengroupware-webui-scheduler*
opengroupware-webui-forms*
opengroupware-webui-project*
opengroupware-theme-default-en*
);
my @pg_order = qw(
postgresql-libs*
postgresql-7*
postgresql-server*
postgresqql-tcl*
postgresql-contrib*
postgresql-devel*
postgresql-docs*
postgresql-pl*
postgresql-python*
postgresql-test*
);
my @packages = map(glob("$_.i386.rpm"), @order);
my @stems = map(/(opengroupware-.*)-[.\d]+-\w+\.i386\.rpm/ ? $1 : "NOMATCH_$_", @packages);
if ($action eq "install") {
my $vopts = $args{v} ? "vv" : "vh";
my $fopt = $args{f} ? "--force" : "";
my $pgopt = $args{a} ? "all" : "";
if ($pgopt eq "all" && !$args{n}) {
my @pg_pkgs = map(glob("$_.i386.rpm"), @pg_order);
my @pg_stems = map(/(postgresql-.*)-[.\d]+-\w+\.i386\.rpm/ ? $1 : "NOMATCH_$_", @pg_pkgs);
my $pg_vopts = $args{v} ? "vv" : "vh";
my $pg_fopt = $args{f} ? "--force" : "";
print "\nInstalling PostgresQL...\n\n";
if (@pg_pkgs ne "") {
my $pg_cmd = join(' ', "rpm -U$pg_vopts $pg_fopt", @pg_pkgs);
print "$pg_cmd\n";
system($pg_cmd);
}
}
print "\nAdding Opengroupware.org...\n\n";
my $cmd = join(' ', "rpm -U$vopts $fopt", @packages);
print "$cmd\n";
exit 0 if $args{n};
my $code = system($cmd);
exit $code;
}
if ($action eq "remove") {
print "Removing Opengroupware.org...\n\n";
my $vopts = $args{v} ? "vv" : "v";
my $rm_cmd = join(' ', "rpm -e$vopts", reverse(@stems));
print "$rm_cmd\n";
exit 0 if $args{n};
exec($rm_cmd);
}
# If we get here then there's an improper command line var. Echo Usage and exit.
print $usage;
exit 0;