From e71663c2e0d3fba5c0076db763dc43bc45641512 Mon Sep 17 00:00:00 2001 From: tomash Date: Wed, 6 Dec 2006 20:06:54 +0000 Subject: [PATCH] Hub setup script improved (can be installed along to studio etc.) --- campcaster/bin/createHubTarball.sh | 2 +- campcaster/bin/hubSetup.sh | 141 +++++++++++------- campcaster/src/modules/alib/etc/Makefile.in | 1 + .../src/modules/archiveServer/etc/Makefile.in | 3 +- .../modules/archiveServer/etc/configure.ac | 14 ++ campcaster/src/modules/getid3/etc/Makefile.in | 1 + .../src/modules/storageAdmin/etc/Makefile.in | 1 + .../src/modules/storageServer/etc/Makefile.in | 7 +- .../modules/storageServer/etc/configure.ac | 14 ++ 9 files changed, 121 insertions(+), 63 deletions(-) diff --git a/campcaster/bin/createHubTarball.sh b/campcaster/bin/createHubTarball.sh index 00d456740..1bbaa99d9 100755 --- a/campcaster/bin/createHubTarball.sh +++ b/campcaster/bin/createHubTarball.sh @@ -107,7 +107,7 @@ fi #------------------------------------------------------------------------------- tarball=$directory/campcaster-hub-$version.tar.bz2 -tmpreldir=campcaster-$version +tmpreldir=campcaster-hub-$version ls_tmpdir=$tmpdir/$tmpreldir src_tmpdir=$ls_tmpdir/src tools_tmpdir=$src_tmpdir/tools diff --git a/campcaster/bin/hubSetup.sh b/campcaster/bin/hubSetup.sh index fbf5b4a04..202438a21 100755 --- a/campcaster/bin/hubSetup.sh +++ b/campcaster/bin/hubSetup.sh @@ -43,7 +43,7 @@ basedir=`cd $reldir; pwd;` bindir=$basedir/bin etcdir=$basedir/etc srcdir=$basedir/src -toolsdir=$srcdir/tools +tools_dir=$srcdir/tools modules_dir=$srcdir/modules @@ -56,6 +56,7 @@ printUsage() echo "parameters"; echo ""; echo " -d, --directory The installation directory, required."; + echo " -n, --hostname The remotely accessible hostname [default `hostname -f`]."; echo " -D, --database The name of the Campcaster database."; echo " [default: CampcasterHub]"; echo " -g, --apache-group The group the apache daemon runs as."; @@ -72,6 +73,8 @@ printUsage() echo " pg_hba.conf [default: /etc/postgresql]"; echo " -i, --postgresql-init-script The name of the postgresql init"; echo " script [default: /etc/init.d/postgresql]"; + echo " -P, --skip-postgresql Don't modify posgresql configuration."; + echo " -A, --skip-apache Don't modify apache configuration."; echo " -h, --help Print this message and exit."; echo ""; } @@ -82,10 +85,13 @@ printUsage() #------------------------------------------------------------------------------- CMD=${0##*/} -opts=$(getopt -o d:D:g:hi:p:r:s:u:w: -l apache-group:,database:,dbserver:,dbuser:,dbpassword:,directory:,help,postgresql-dir:,postgresql-init-script:,www-root: -n $CMD -- "$@") || exit 1 +opts=$(getopt -o Ad:D:g:hi:n:p:Pr:s:u:w: -l apache-group:,database:,dbserver:,dbuser:,dbpassword:,directory:,help,hostname:,postgresql-dir:,postgresql-init-script:,skip-apache,skip-postgresql,www-root: -n $CMD -- "$@") || exit 1 eval set -- "$opts" while true; do case "$1" in + -S|--skip-apache) + skip_apache="yes"; + shift;; -d|--directory) installdir=$2; shift; shift;; @@ -101,9 +107,15 @@ while true; do -i|--postgresql-init-script) postgresql_init_script=$2; shift; shift;; + -n|--hostname) + hostname=$2; + shift; shift;; -p|--postgresql-dir) postgresql_dir=$2; shift; shift;; + -P|--skip-postgresql) + skip_postgresql="yes"; + shift;; -r|--www-root) www_root=$2; shift; shift;; @@ -164,7 +176,10 @@ if [ "x$www_root" == "x" ]; then www_root=/var/www; fi -hostname=`hostname -f` +if [ "x$hostname" == "x" ]; then + hostname=`hostname -f` +fi + www_port=80 echo "Installing Campcaster network hub (archiveServer)."; @@ -200,6 +215,7 @@ install_lib=$installdir/lib install_usr=$installdir/usr install_var_ls=$installdir/var/Campcaster +url_prefix=campcaster_hub #------------------------------------------------------------------------------- # Function to check for the existence of an executable on the PATH @@ -255,74 +271,76 @@ rm -f $group_tmp_file; #------------------------------------------------------------------------------- # Install the new pg_hba.conf file #------------------------------------------------------------------------------- -echo "Modifying postgresql access permissions..."; +if [ "$skip_postgresql" != "yes" ]; then + echo "Modifying postgresql access permissions..."; -pg_config_dir=$postgresql_dir -pg_config_file=pg_hba.conf -pg_config_file_saved=pg_hba.conf.before-campcaster + pg_config_dir=$postgresql_dir + pg_config_file=pg_hba.conf + pg_config_file_saved=pg_hba.conf.before-campcaster -if [ -f $pg_config_dir/$pg_config_file ] ; then - mv -vf $pg_config_dir/$pg_config_file $pg_config_dir/$pg_config_file_saved ; + if [ -f $pg_config_dir/$pg_config_file ] ; then + mv -vf $pg_config_dir/$pg_config_file $pg_config_dir/$pg_config_file_saved ; + fi + cp -v $etcdir/$pg_config_file $pg_config_dir/$pg_config_file + chown root:$postgres_user $pg_config_dir/$pg_config_file + + # don't use restart for the init script, as it might return prematurely + # and in the later call to psql we wouldn't be able to connect + ${postgresql_init_script} stop + ${postgresql_init_script} start fi -cp -v $etcdir/$pg_config_file $pg_config_dir/$pg_config_file -chown root:$postgres_user $pg_config_dir/$pg_config_file - -# don't use restart for the init script, as it might return prematurely -# and in the later call to psql we wouldn't be able to connect -${postgresql_init_script} stop -${postgresql_init_script} start - #------------------------------------------------------------------------------- # Configuring Apache #------------------------------------------------------------------------------- -echo "Configuring apache ..." -CONFFILE=90_php_campcaster.conf -AP_DDIR_FOUND=no -for APACHE_DDIR in \ - /etc/apache/conf.d /etc/apache2/conf.d /etc/apache2/conf/modules.d \ - /etc/httpd/conf.d /etc/apache2/modules.d -do - echo -n "$APACHE_DDIR " - if [ -d $APACHE_DDIR ]; then - echo "Y" - AP_DDIR_FOUND=yes - cp -v $basedir/etc/apache/$CONFFILE $APACHE_DDIR - break - else - echo "N" - fi -done -if [ "$AP_DDIR_FOUND" != "yes" ]; then - echo "###############################" - echo " Could not configure Apache" - echo " include following file into apache config manually:" - echo " $basedir/etc/apache/$CONFFILE" - echo "###############################" -else - echo "done" - echo "Restarting apache..."; - AP_SCR_FOUND=no - for APACHE_SCRIPT in apache apache2 httpd ; do - echo -n "$APACHE_SCRIPT " - if [ -x /etc/init.d/$APACHE_SCRIPT ]; then +if [ "$skip_apache" != "yes" ]; then + echo "Configuring apache ..." + CONFFILE=90_php_campcaster.conf + AP_DDIR_FOUND=no + for APACHE_DDIR in \ + /etc/apache/conf.d /etc/apache2/conf.d /etc/apache2/conf/modules.d \ + /etc/httpd/conf.d /etc/apache2/modules.d + do + echo -n "$APACHE_DDIR " + if [ -d $APACHE_DDIR ]; then echo "Y" - AP_SCR_FOUND=yes - /etc/init.d/$APACHE_SCRIPT restart + AP_DDIR_FOUND=yes + cp -v $basedir/etc/apache/$CONFFILE $APACHE_DDIR + break else echo "N" fi done - if [ "$AP_SCR_FOUND" != "yes" ]; then + if [ "$AP_DDIR_FOUND" != "yes" ]; then echo "###############################" - echo " Could not reload Apache" - echo " please reload apache manually" + echo " Could not configure Apache" + echo " include following file into apache config manually:" + echo " $basedir/etc/apache/$CONFFILE" echo "###############################" + else + echo "done" + echo "Restarting apache..."; + AP_SCR_FOUND=no + for APACHE_SCRIPT in apache apache2 httpd ; do + echo -n "$APACHE_SCRIPT " + if [ -x /etc/init.d/$APACHE_SCRIPT ]; then + echo "Y" + AP_SCR_FOUND=yes + /etc/init.d/$APACHE_SCRIPT restart + else + echo "N" + fi + done + if [ "$AP_SCR_FOUND" != "yes" ]; then + echo "###############################" + echo " Could not reload Apache" + echo " please reload apache manually" + echo "###############################" + fi + echo "done" fi - echo "done" fi - #------------------------------------------------------------------------------- # Create the necessary database user and database itself #------------------------------------------------------------------------------- @@ -366,6 +384,7 @@ fi #------------------------------------------------------------------------------- echo "Configuring modules ..."; +cd $tools_dir/pear && ./configure --prefix=$installdir cd $modules_dir/alib && ./configure --prefix=$installdir cd $modules_dir/archiveServer && \ ./configure --prefix=$installdir \ @@ -374,7 +393,8 @@ cd $modules_dir/archiveServer && \ --with-database-server=$dbserver \ --with-database=$database \ --with-database-user=$dbuser \ - --with-database-password=$dbpassword + --with-database-password=$dbpassword \ + --with-url-prefix=$url_prefix cd $modules_dir/getid3 && ./configure --prefix=$installdir #cd $modules_dir/htmlUI && ./configure --prefix=$installdir \ # --with-apache-group=$apache_group \ @@ -393,7 +413,8 @@ cd $modules_dir/storageServer && \ --with-database=$database \ --with-database-user=$dbuser \ --with-database-password=$dbpassword \ - --with-init-database=no + --with-init-database=no \ + --with-url-prefix=$url_prefix #------------------------------------------------------------------------------- @@ -401,6 +422,9 @@ cd $modules_dir/storageServer && \ #------------------------------------------------------------------------------- echo "Installing modules ..."; +mkdir -p $installdir +#$tools_dir/pear/bin/install.sh -d $installdir || exit 1 +make -C $tools_dir/pear install make -C $modules_dir/alib install make -C $modules_dir/getid3 install make -C $modules_dir/storageServer install @@ -419,8 +443,9 @@ done echo "Creating symlinks..."; # create symlink for the PHP pages in apache's document root -rm -f $www_root/campcaster -ln -vs $install_var_ls $www_root/campcaster +webentry=$www_root/$url_prefix +rm -f $webentry +ln -vs $install_var_ls $webentry #------------------------------------------------------------------------------- diff --git a/campcaster/src/modules/alib/etc/Makefile.in b/campcaster/src/modules/alib/etc/Makefile.in index 6042cc22b..368b8c98a 100644 --- a/campcaster/src/modules/alib/etc/Makefile.in +++ b/campcaster/src/modules/alib/etc/Makefile.in @@ -29,6 +29,7 @@ #------------------------------------------------------------------------------- # General command definitions #------------------------------------------------------------------------------- +SHELL = /bin/bash MKDIR = mkdir -p RM = rm -f RMDIR = rm -rf diff --git a/campcaster/src/modules/archiveServer/etc/Makefile.in b/campcaster/src/modules/archiveServer/etc/Makefile.in index ba6b59ba9..755693066 100644 --- a/campcaster/src/modules/archiveServer/etc/Makefile.in +++ b/campcaster/src/modules/archiveServer/etc/Makefile.in @@ -29,6 +29,7 @@ #------------------------------------------------------------------------------- # General command definitions #------------------------------------------------------------------------------- +SHELL = /bin/bash MKDIR = mkdir -p RM = rm -f RMDIR = rm -rf @@ -87,8 +88,8 @@ DB_SERVER = @DB_SERVER@ DATABASE = @DATABASE@ DB_USER = @DB_USER@ DB_PASSWORD = @DB_PASSWORD@ +PHP_URL_PREFIX = @URL_PREFIX@ -PHP_URL_PREFIX=campcaster USR_LIB_DIR_S=$(shell ${ECHO} ${USR_LIB_DIR} | ${SED} -e "s/\//\\\\\\\\\//g") PHP_URL_PREFIX_S=$(shell ${ECHO} ${PHP_URL_PREFIX} | ${SED} -e "s/\//\\\\\\\\\//g") diff --git a/campcaster/src/modules/archiveServer/etc/configure.ac b/campcaster/src/modules/archiveServer/etc/configure.ac index cd231fdca..1c1588a47 100644 --- a/campcaster/src/modules/archiveServer/etc/configure.ac +++ b/campcaster/src/modules/archiveServer/etc/configure.ac @@ -118,6 +118,19 @@ AC_ARG_WITH([database-password], AC_MSG_RESULT([using database server user password: ${DB_PASSWORD}]) +dnl----------------------------------------------------------------------------- +dnl specify url prefix +dnl----------------------------------------------------------------------------- +AC_SUBST(URL_PREFIX) + +AC_ARG_WITH([url-prefix], + AC_HELP_STRING([--with-url-prefix], + [use the specified url prefix (campcaster)]), + [URL_PREFIX=${withval}], [URL_PREFIX=campcaster]) + +AC_MSG_RESULT([using url prefix: ${URL_PREFIX}]) + + dnl display status info on what libraries will get compiled AC_MSG_NOTICE( @@ -129,6 +142,7 @@ AC_MSG_NOTICE( database name: ${DATABASE} database user: ${DB_USER} database user password: ${DB_PASSWORD} + url prefix: ${URL_PREFIX} ]) diff --git a/campcaster/src/modules/getid3/etc/Makefile.in b/campcaster/src/modules/getid3/etc/Makefile.in index 7d8310c43..7faee8e40 100644 --- a/campcaster/src/modules/getid3/etc/Makefile.in +++ b/campcaster/src/modules/getid3/etc/Makefile.in @@ -30,6 +30,7 @@ #------------------------------------------------------------------------------- # General command definitions #------------------------------------------------------------------------------- +SHELL = /bin/bash MKDIR = mkdir -p RM = rm -f RMDIR = rm -rf diff --git a/campcaster/src/modules/storageAdmin/etc/Makefile.in b/campcaster/src/modules/storageAdmin/etc/Makefile.in index 0ddf7efbe..eb6473ecd 100644 --- a/campcaster/src/modules/storageAdmin/etc/Makefile.in +++ b/campcaster/src/modules/storageAdmin/etc/Makefile.in @@ -30,6 +30,7 @@ #------------------------------------------------------------------------------- # General command definitions #------------------------------------------------------------------------------- +SHELL = /bin/bash MKDIR = mkdir -p RM = rm -f RMDIR = rm -rf diff --git a/campcaster/src/modules/storageServer/etc/Makefile.in b/campcaster/src/modules/storageServer/etc/Makefile.in index 9aa306780..77e61fcc2 100644 --- a/campcaster/src/modules/storageServer/etc/Makefile.in +++ b/campcaster/src/modules/storageServer/etc/Makefile.in @@ -29,6 +29,7 @@ #------------------------------------------------------------------------------- # General command definitions #------------------------------------------------------------------------------- +SHELL = /bin/bash MKDIR = mkdir -p RM = rm -f RMDIR = rm -rf @@ -92,8 +93,8 @@ DB_USER = @DB_USER@ DB_PASSWORD = @DB_PASSWORD@ SCHEDULER_PORT = @SCHEDULER_PORT@ WWW_DOCROOT = @WWW_DOCROOT@ +PHP_URL_PREFIX = @URL_PREFIX@ -PHP_URL_PREFIX=campcaster SCHEDULER_URL_PREFIX = SCHEDULER_XML_RPC_PREFIX = RC2 @@ -193,8 +194,8 @@ copy_files: chmod g+sw ${DEST_DIR}/stor/buffer chmod g+sw ${DEST_DIR}/trans - ${RM} ${WWW_DOCROOT}/campcaster - ln -sf ${USR_VAR_DIR}/Campcaster ${WWW_DOCROOT}/campcaster + ${RM} ${WWW_DOCROOT}/${PHP_URL_PREFIX} + ln -sf ${USR_VAR_DIR}/Campcaster ${WWW_DOCROOT}/${PHP_URL_PREFIX} create_database: ifeq (@CREATE_LS_DATABASE@,yes) diff --git a/campcaster/src/modules/storageServer/etc/configure.ac b/campcaster/src/modules/storageServer/etc/configure.ac index 1473063ef..304050a9c 100644 --- a/campcaster/src/modules/storageServer/etc/configure.ac +++ b/campcaster/src/modules/storageServer/etc/configure.ac @@ -186,6 +186,19 @@ AC_ARG_WITH([www-docroot], AC_MSG_RESULT([using www document root: ${WWW_DOCROOT}]) +dnl----------------------------------------------------------------------------- +dnl specify url prefix +dnl----------------------------------------------------------------------------- +AC_SUBST(URL_PREFIX) + +AC_ARG_WITH([url-prefix], + AC_HELP_STRING([--with-url-prefix], + [use the specified url prefix (campcaster)]), + [URL_PREFIX=${withval}], [URL_PREFIX=campcaster]) + +AC_MSG_RESULT([using url prefix: ${URL_PREFIX}]) + + dnl display status info on what libraries will get compiled AC_MSG_NOTICE( @@ -201,6 +214,7 @@ AC_MSG_NOTICE( creating Campcaster database: ${CREATE_LS_DATABASE} initialize Campcaster database: ${INIT_LS_DATABASE} www document root: ${WWW_DOCROOT} + url prefix: ${URL_PREFIX} ])