#!/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/weavemini-environment-test - test weave environment # # Copyright (c) 2010-2012 The Eisfair Team, team(at)eisfair(dot)org # # Creation : 2011-02-06 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version.. #------------------------------------------------------------------------------ # include eislib etc. . /var/install/include/eislib . /var/install/include/check-eisfair-version module_name='weavemini' module_webdir='weave_minimal' apache2file=/etc/config.d/apache2 apache2php5file=/etc/config.d/apache2_php5 ### set directory and file names ### case ${EISFAIR_SYSTEM} in eisfair-1) # eisfair-1 apache_user='wwwrun' apache_group='nogroup' ;; *) # default to eisfair-2 apache_user='www-data' apache_group='www-data' ;; esac # read Apache2 configuration . ${apache2file} web_root="${APACHE2_DOCUMENT_ROOT}/${module_webdir}" web_url="https://${APACHE2_SERVER_NAME}/weave/" if [ "$1" = "called-from-weavemini-menu" ] then clrhome mecho -info "Weave environment test" mecho fi mecho "Checking weave environment ..." # check if .htaccess is a null byte file if [ -f ${web_root}/.htaccess -a ! -s ${web_root}/.htaccess ] then rm -f ${web_root}/.htaccess fi # create .htaccess file if [ ! -f ${web_root}/.htaccess ] then mecho "- Creating .htaccess file ..." { echo 'RewriteEngine On' echo 'RewriteRule ^.*$ index.php [NC,L]' } > ${web_root}/.htaccess fi # create settings.php if [ ! -f ${web_root}/settings.php ] then mecho "- Creating settings.php file ..." { echo '' } > ${web_root}/settings.php fi # deactivate setup.php if [ -f ${web_root}/setup.php ] then mv ${web_root}/setup.php ${web_root}/setup.php.ORG fi # set file ownership mecho "- Setting directory/file ownership and access rights ..." chmod 440 ${web_root}/.htaccess chmod 640 ${web_root}/settings.php chmod 0750 ${web_root} chown -R ${apache_user} ${web_root} chgrp -R ${apache_group} ${web_root} # set file ownership to start script as apache user #chown -R ${apache_user} /var/install/bin/weavemini-modify-user.php #chgrp -R ${apache_group} /var/install/bin/weavemini-modify-user.php # create symbolic link #if [ ! -f ${web_root}/weavemini-modify-user.php ] #then # ln -s /var/install/bin/weavemini-modify-user.php ${web_root}/weavemini-modify-user.php #fi # check apache2 prerequisites if [ "${START_APACHE2}" = "yes" ] then mecho -info "- Apache2 has been actived." else mecho -warn "- Apache2 hasn't been actived!" fi web_ssl=1 if [ "${APACHE2_SSL}" = "yes" ] then web_ssl=0 mecho -info "- Apache2 SSL support has been actived." else mecho -warn "- Apache2 SSL support hasn't been actived!" mecho mecho " Please make sure that you set the following parameter in the" mecho " apache2 configuration file:" mecho mecho " APACHE2_SSL='yes'" mecho fi web_alias=1 web_path=1 web_cgi=1 idx=1 while [ ${idx} -le ${APACHE2_DIR_N} ] do eval active='$APACHE2_DIR_'${idx}'_ACTIVE' eval alias_active='$APACHE2_DIR_'${idx}'_ALIAS' if [ "${active}" = "yes" -a "${alias_active}" = "yes" ] then eval alias='$APACHE2_DIR_'${idx}'_ALIAS_NAME' eval path='$APACHE2_DIR_'${idx}'_PATH' eval cgi='$APACHE2_DIR_'${idx}'_CGI' if [ "${alias}" = "/weave" ] then web_alias=0 mecho -info "- Alias to weave directory found." if [ "${path}" = "${web_root}" -a -d ${web_root} ] then web_path=0 mecho -info "- Path to weave directory exists." fi echo "${cgi}" | grep -q "none" if [ $? -eq 0 ] then web_cgi=0 mecho -info "- Script support disabled." break fi fi fi idx=`expr ${idx} + 1` done if [ ${web_alias} -eq 1 -o ${web_path} -eq 1 -o ${web_cgi} -eq 1 ] then if [ ${web_alias} -eq 1 ] then mecho -warn "- Weave Alias not properly set!" fi if [ ${web_path} -eq 1 ] then mecho -warn "- Weave directory path not properly set or couldn't be found!" fi if [ ${web_cgi} -eq 1 ] then mecho -warn "- Script support hasn't been deactivated!" fi mecho mecho " Please make sure that you set the following parameters in the" mecho " apache2 configuration file:" mecho mecho " APACHE2_DIR_x_ACTIVE='yes'" mecho " APACHE2_DIR_x_ALIAS='yes'" mecho " APACHE2_DIR_x_ALIAS_NAME='/weave'" mecho " APACHE2_DIR_x_PATH='${web_root}'" mecho " APACHE2_DIR_x_CGI='none'" mecho fi # check apache2_php5 prerequisites . ${apache2php5file} if [ "${PHP5_EXT_SQLITE3}" = "yes" ] then mecho -info "- PHP5 SQLite3 support has been activated." # check if weave_db is a null byte file if [ -f ${web_root}/weave_db -a ! -s ${web_root}/weave_db ] then rm -f ${web_root}/weave_db fi # # create weave_db # if [ ! -f ${web_root}/weave_db ] # then # # database doesn't exist, create it # mecho -info "- Creating weave_db file ..." # curr_dir=`pwd` # cd ${web_root} # /usr/bin/php ${web_root}/weavemini-modify-user.php -c -u weave-dummy -s dummy 2> /dev/null # /usr/bin/php ${web_root}/weavemini-modify-user.php -d -u weave-dummy 2> /dev/null chmod 0640 ${web_root}/weave_db chown ${apache_user} ${web_root}/weave_db chgrp ${apache_group} ${web_root}/weave_db cd ${curr_dir} # else # mecho -info "- weave_db file found." # fi else mecho -warn "- PHP5 SQLite3 support hasn't been activated." mecho mecho " Please make sure that you set the following parameter in the" mecho " apache2_php5 configuration file:" mecho mecho " PHP5_EXT_SQLITE3='yes'" mecho fi if [ ${web_ssl} -eq 1 -o ${web_cgi} -eq 1 -o ${web_alias} -eq 1 -o \ ${web_path} -eq 1 -o "${PHP5_EXT_SQLITE3}" != "yes" -o "$1" = "called-from-weavemini-menu" ] then anykey fi exit 0