#!/bin/sh # This is based on the Fedora Core 3 INSTALL file, modified using the information in the Freeside Wiki # It's intended to be a universal Freeside installation script, but it's nowhere near that yet. # # Primary domain - see the Wiki DOMAIN= # Package manager to use PACKAGER= # Main freeside user USER= # Name for database for this instance of freeside DBNAME=freeside # Parse the command line arguments #parse_cli_arguments() #{ while getopts "hd:n:p:u:" flag do case $flag in d) NEWVAL=`echo $OPTARG | tr '[A-Z]' '[a-z]'` if [ "x$DOMAIN" != "x" -a "$DOMAIN" != "$NEWVAL" ] ; then echo STDERR "Domain already set to $DOMAIN. Changing to $NEWVAL" fi DOMAIN=$NEWVAL;; h) usage;; n) # We don't lowercase the database name if [ "x$DBNAME" != "x" -a "$DBNAME" != "$OPTARG" ] ; then echo STDERR "Database name already set to $DBNAME. Changing to $OPTARG" fi DBNAME=$OPTARG;; p) NEWVAL=`echo $OPTARG | tr '[A-Z]' '[a-z]'` if [ "x$PACKAGER" != "x" -a "$PACKAGER" != "$NEWVAL" ] ; then echo STDERR "Packager already set to $PACKAGER. Changing to $NEWVAL" fi PACKAGER=$NEWVAL;; u) # We don't lowercase the user name if [ "x$USER" != "x" -a "$USER" != "$OPTARG" ] ; then echo STDERR "Main freeside web user already set to $USER. Changing to $OPTARG" fi USER=$OPTARG;; esac done #} usage() { echo "freeside-install is a utility to install the Freeside ISP billing system." echo "Usage: freeside-install -d -n -p -u " echo "where:" echo " domain is the required first domain, usually the ISP's main customer domain" echo " database name is the name of the database for this instance of Freeside - defaults to freeside" echo " packager is the package management tool you want to use: RPM, CPAN, etc." exit 1 } apologize() { echo "Sorry, this version of freeside-install is non-functional. Feel free to contribute fixes" echo "See http://www.sisd.com/mediawiki/index.php/Freeside:1.7:Documentation:Installation for information on how to install Freeside" exit 1 } install_perl_module() { # We should do something smarter than this, checking to see if the module was installed # and falling back to another package manager (or two) if not echo "$MODULE: $CPAN" case $PACKAGER in apt) # apt-get install $CPAN; ;; cpan) # cpan install $CPAN; ;; cpan2rpm) # cpan2rpm $CPAN; # rpm -Uvh /usr/src/redhat/RPMS/*/perl-$CPAN*.rpm ;; rpm) # Nothing to do; RPM should already be installed? ;; yum) # yum install perl-$CPAN; ;; esac } install_all_perl_modules() { while read MODULE CPAN do install_perl_module $MODULE $CPAN; done <