-#!/bin/sh
+#!/bin/bash
#
# Simple wrapper for FusionForge installation
#
# Usage: ./install-ng <hostname>
#
-# This will install all the fusionforge code in /opt/gforge
+# This will install all the fusionforge code in $FORGE_HOME
# Configuration is stored in /etc/gforge
#
# Currently supported:
# Author: Alain Peyrat <aljeux@free.fr>
# Christian Bayle <bayle@debian.org>
#
-scriptdir=`cd \`dirname $0\`; pwd`
-. $scriptdir/install/detect_os
-. $scriptdir/install/config
+FORGE_HOME=/opt/gforge
+
+usage(){
+ echo "Usage: $1 [-r|-h|-a|--reinit|--help|--auto|--deps|--files|--database|--config] [<hostname>]"
+}
+
+options=`getopt -o rha -l reinit,help,auto,deps,files,database,config -- "$@"`
+
+if [ $? != 0 ] ; then echo "Terminating..." >&2 ; usage $0 ;exit 1 ; fi
+
+eval set -- "$options"
+
+if [[ $EUID -ne 0 ]]; then
+ echo "This script must be run as root" 1>&2
+ exit 1
+fi
+
+REINIT=false
+AUTO=false
+
+# Install dependancies files database config by default
+DEFAULT=true
+
+# Install dependancies
+DEPS=false
+# Install files
+FILES=false
+# Install database
+DATABASE=false
+# Install config
+CONFIG=false
+
+while true
+do
+ case "$1" in
+ -r|--reinit) REINIT=true; shift 1;;
+ -h|--help) usage $0 ; exit 0; shift 1;;
+ -a|--auto) AUTO=true ; shift 1;;
+ --deps) DEFAULT=false ; DEPS=true ; shift 1;;
+ --files) DEFAULT=false ; FILES=true ; shift 1;;
+ --database) DEFAULT=false ; DATABASE=true ; shift 1;;
+ --config) DEFAULT=false ; CONFIG=true ; shift 1;;
+ --) shift 1; break;;
+ *) break ;;
+ esac
+done
hostname=$1
-if [ ! "$hostname" ]
+if [ -z "$hostname" ]
then
hostname=`hostname -f`
fi
+echo "Using hostname=$hostname"
+
+# Load some script
+scriptdir=`cd \`dirname $0\`; pwd`
+. $scriptdir/install/detect_os
+
+FUSIONFORGE_DEFAULT_SRC_DIR=$(cd $(dirname $0); pwd)
+FUSIONFORGE_DEFAULT_DIR=$FORGE_HOME
+fusionforge_src_dir=${FUSIONFORGE_SRC_DIR:-$FUSIONFORGE_DEFAULT_SRC_DIR}
+fusionforge_dir=${FUSIONFORGE_DIR:-$FUSIONFORGE_DEFAULT_DIR}
+fusionforge_data_dir=${FUSIONFORGE_DATA_DIR:-/var/lib/gforge}
+fusionforge_log_dir=${FUSIONFORGE_LOG_DIR:-/var/log/gforge}
+fusionforge_etc_dir=${FUSIONFORGE_ETC_DIR:-/etc/gforge}
# Call to detect_os, this will set $type and $distrib
os=$(detect_os)
+type=$(detect_type)
+echo "Install type = $type"
+
+if $DEPS || $DEFAULT
+then
+ # Load deps script and run the appropriate one
+ . $scriptdir/install/deps
+ deps_$os
+fi
+
+# Load install scripts
+. $scriptdir/install/install2
+. $scriptdir/install/install3
+. $scriptdir/install/install4
+. $scriptdir/install/install5_post
+. $scriptdir/install/install6_upgrade
+
+if $AUTO
+then
+ echo "Using automatic configuration"
+ FFORGE_DB=fforge
+ FFORGE_USER=gforge
+ FFORGE_ADMIN_USER=admin
+ FFORGE_ADMIN_PASSWORD=myadmin
+fi
-if [ -d "/opt/gforge" ]
+if $REINIT
+then
+ echo "Reinit the database"
+ rm -f /etc/gforge/install_completed
+ dropdbifexists $FFORGE_DB
+fi
+
+if [ -d "$FORGE_HOME" ]
then
if [ -f "/etc/gforge/install_completed" ]
then
echo "Installing FusionForge ...";
fi
-. $scriptdir/install/deps
-deps_$os
-
-. $scriptdir/install/install2
-. $scriptdir/install/install3
-. $scriptdir/install/install4
+if $DEFAULT || $FILES
+then
+ install2_files_$type "$hostname"
+fi
-echo "Install type = $type"
-case $type in
- redhat)
- echo "Running install/install2 "$hostname" apache apache"
- install2 "$hostname" apache apache
- if [ "$mode" = "install" ]
+if [ "$mode" = "install" ]
+then
+ if $DEFAULT || $DATABASE
then
- echo "Running install/install3"
- install3
- echo "Running install/install4"
- install4
-
- # Post installation fixes.
- perl -spi -e "s/^#ServerName (.*):80/ServerName $hostname:80/" /etc/httpd/conf/httpd.conf
- # Disable ssl
- perl -spi -e "s/^Include/#Include/" /etc/gforge/httpd.conf.d/ssl-on.inc
-
- chkconfig httpd on
- chkconfig postgresql on
- chkconfig iptables off
-
- service httpd restart
- service iptables stop
- msg="IMPORTANT: Service iptables (firewall) disabled, please reconfigure after"
-
- cp $scriptdir/packaging/cron.d/cron.fusionforge /etc/cron.d
- cp $scriptdir/plugins/*/etc/cron.d/* /etc/cron.d/
- service crond reload
- else
- echo "Running php db/upgrade-db.php"
- cd $scriptdir; php db/upgrade-db.php
- echo "Running php utils/normalize_roles.php"
- php utils/normalize_roles.php
+ echo "Running install3_db_$type"
+ install3_db_$type
fi
- ;;
-
- suse)
- install2 "$hostname" wwwrun www
- if [ $mode = "install" ]
+ if $DEFAULT || $CONFIG
then
- install3
- echo "Running php db/upgrade-db.php"
- cd $scriptdir; php db/upgrade-db.php
- install4
-
- # Post installation fixes.
- #perl -spi -e "s/^#ServerName (.*):80/ServerName $hostname:80/" /etc/apache2/httpd.conf
-
- chkconfig -s apache2 on
- chkconfig -s postgresql on
-
- # Apache settings: modules
- for m in dav dav_svn authz_svn ssl; do
- a2enmod $m
- a2enflag $m
- done
- echo "Virtual hosts for ${hostname}:"
- httpd2 -S -DSSL 2>&1 | grep ${hostname}
-
- rcapache2 restart
-
- rcSuSEfirewall2 stop
- msg="IMPORTANT: Service SuSEfirewall2 stopped, please reconfigure after"
-
- cp packaging/cron.d/cron.fusionforge /etc/cron.d
- cp plugins/*/etc/cron.d/* /etc/cron.d/
- rccron reload
- else
- echo "Running php db/upgrade-db.php"
- cd $scriptdir; php db/upgrade-db.php
+ echo "Running install4_config_$type"
+ install4_config_$type
fi
- ;;
-
- ubuntu)
- echo "--"
- echo "For ubuntu, rather use ubuntu $distrib package"
- echo "SEE https://fusionforge.org/mediawiki/index.php/Installing/UbuntuRepositories"
- echo "--"
- ;;
-
- debian)
- echo "--"
- echo "For debian, rather use debian $distrib package"
- echo "SEE https://fusionforge.org/mediawiki/index.php/Installing/DebianRepositories"
- echo "--"
- ;;
-
- *)
- echo "Only Red Hat, Fedora or CentOS and OpenSUSE are supported by this script.";
- echo "See INSTALL for normal installation";
- exit 1
- ;;
-esac
+ if $DEFAULT
+ then
+ echo "Running install5_post_$type"
+ install5_post_$type "$hostname"
+ fi
+else
+ if $DEFAULT
+ then
+ echo "Running install6_upgrade_$type"
+ install6_upgrade_$type
+ fi
+fi
echo "check /etc/gforge/local.inc for $hostname specific FusionForge settings"
echo "Write INSTALL COMPLETED"