2 # This is based on the Fedora Core 3 INSTALL file, modified using the information in the Freeside Wiki
3 # It's intended to be a universal Freeside installation script, but it's nowhere near that yet.
6 # Primary domain - see the Wiki
8 # Package manager to use
12 # Name for database for this instance of freeside
15 # Parse the command line arguments
16 #parse_cli_arguments()
18 while getopts "hd:n:p:u:" flag
22 NEWVAL=`echo $OPTARG | tr '[A-Z]' '[a-z]'`
23 if [ "x$DOMAIN" -ne "x" ] ; then
24 echo STDERR "Domain already set to $DOMAIN. Changing to $NEWVAL"
30 # We don't lowercase the database name
31 if [ "x$DBNAME" -ne "x" ] ; then
32 echo STDERR "Database name already set to $DBNAME. Changing to $OPTARG"
36 NEWVAL=`echo $OPTARG | tr '[A-Z]' '[a-z]'`
37 if [ "x$PACKAGER" -ne "x" ] ; then
38 echo STDERR "Packager already set to $PACKAGER. Changing to $NEWVAL"
42 # We don't lowercase the user name
43 if [ "x$USER" -ne "x" ] ; then
44 echo STDERR "Main freeside web user already set to $USER. Changing to $OPTARG"
53 echo "freeside-install is a utility to install the Freeside ISP billing system."
54 echo "Usage: freeside-install -d <domain> -n <database name> -p <packager> -u <first web user>"
56 echo " domain is the required first domain, usually the ISP's main customer domain"
57 echo " database name is the name of the database for this instance of Freeside - defaults to freeside"
58 echo " packager is the package management tool you want to use: RPM, CPAN, etc."
64 echo "Sorry, this version of freeside-install is non-functional. Feel free to contribute fixes"
65 echo "See http://www.sisd.com/mediawiki/index.php/Freeside:1.7:Documentation:Installation for information on how to install Freeside"
71 # We should do something smarter than this, checking to see if the module was installed
72 # and falling back to another package manager (or two) if not
76 # apt-get install $CPAN;
83 # rpm -Uvh /usr/src/redhat/RPMS/*/perl-$CPAN*.rpm
86 # Nothing to do; RPM should already be installed?
89 # yum install perl-$CPAN;
94 install_all_perl_modules()
96 while read MODULE CPAN
98 install_perl_module $MODULE $CPAN;
100 # Probably included in the distro
102 libwww-perl Bundle::LWP
110 MailTools Mail::Internet
112 TimeDate Date::Format
113 Locale-Codes Locale::Country
115 # Less common modules
124 DateTime::Format::Strptime
138 HTML::Widgets::SelectLayers
140 Lingua::EN::NameParse
142 # Optional modules - we'll add them anyway
148 # Create the freeside user account and create the database in PostgreSQL
151 /usr/sbin/useradd freeside
152 chsh freeside -s /bin/bash
157 /sbin/chkconfig postgresql on
158 /etc/init.d/postgresql start
161 create_freeside_pg_user_and_db()
163 echo "Creating Freeside database user for Pg"
164 su postgres -c "createuser -P -A -d freeside"
166 echo "Creating the $DBNAME database"
167 su freeside -c "createdb -E sql_ascii $DBNAME"
170 # Install Freeside's Perl modules, create the configuration, and create the first user
174 make install-perl-modules
178 add_freeside_system_users()
180 echo "Creating Freeside system users"
181 for SYSUSER in fs_queue fs_daily fs_selfservice ; do
182 su freeside -c "freeside-adduser -g 1 $SYSUSER"
186 add_first_freeside_user()
188 echo "Creating first Freeside application user"
189 su freeside -c "freeside-adduser -g 1 $USER"
190 su freeside -c "htpasswd -c /usr/local/etc/freeside/htpasswd $USER"
193 setup_freeside_database()
195 echo "Setting up Freeside for $DOMAIN"
196 su freeside -c "freeside-setup -d $DOMAIN"
199 # Should check that we're root...
201 #parse_cli_arguments;
203 if [ "x$USER" = "x" ]; then
207 if [ "x$DOMAIN" = "x" ]; then
211 if [ "$PACKAGER" -ne "rpm" ]; then
212 install_all_perl_modules;
218 create_freeside_pg_user_and_db;
220 setup_freeside_database;
222 add_freeside_system_users;
224 add_first_freeside_user;