File processwire3-admin of Package processwire3
#!/bin/sh
#
# Manage ProcessWire installations
#
# (c) Johannes Weberhofer, Weberhofer GmbH 2016, 2017
#
# This script is licensed under the GPL
#
PACKAGE_SHARED=/usr/share/processwire3
PACKAGE_VAR=package_var
INSTALLATIONS=/etc/processwire3-installations
APACHE_CONF=apache_conf
APACHE_USER=apache_user
APACHE_GROUP=apache_group
#
# check input parameters
#
ERR=0
HELP=0
TARGETDIR=''
BUILD=0
PREFIX=''
COMMAND='install'
SCRIPTDIR=`dirname $0`
while [ $# -ge 1 ] ; do
OPT="$1"
shift
case "$OPT" in
--help)
HELP=1
;;
help)
HELP=1
;;
install)
COMMAND='install'
TARGETDIR=$1
shift
;;
update)
COMMAND='update'
;;
--prefix)
if [ -d "$1" ] ; then
PREFIX=`readlink -f "$1"`"/"
BUILD=1
else
echo "Invalid prefix $1" 1>&2
ERR=3
fi
shift
;;
*)
echo "unknown option: $1" 1>&2
ERR=1
;;
esac
done
if [ ! -d $PREFIX$PACKAGE_SHARED ] ; then
echo "Source directory does not exist: $PACKAGE_SHARED" 1>&2
ERR=4
fi
if [ "$COMMAND" == "install" ] ; then
if [ -d `dirname "$PREFIX$TARGETDIR"` ] ; then
if [ -d "$PREFIX$TARGETDIR" ] ; then
echo "Installation exists in $PREFIX$TARGETDIR" 1>&2
ERR=2
fi
else
echo "Parent directory does not exist:"`dirname "$PREFIX$TARGETDIR"` 1>&2
ERR=2
fi
fi
#
# usage section
#
if ( [ $HELP -eq 1 ] || [ $ERR -ne 0 ] ) ; then
echo \
"usage: "`basename $0`" [install DIR [--prefix DIR] |update|help]
Create or update a ProcessWire-installation based on an Apache/Alias
configuration.
help display this text
install Install into installation directory
DIR The installation's root directory; the structure will be
placed into this directory
--prefix DIR For packaging-purposes this directory will be prefixed.
This feature should not be used in production systems.
addremove correct added and removed modules.
update Update all current installations."
exit $ERR
fi
TARGETDIR=`echo "$TARGETDIR" | sed -e 's/\/\//\//g ; s/\/$//'`
function doInstall() {
for DIR in webroot temp session ; do
mkdir -p "$PREFIX$TARGETDIR/$DIR"
chown $APACHE_USER. "$PREFIX$TARGETDIR/$DIR"
done
for SYMLINK in wire index.php install.php ; do
ln -s "$PACKAGE_SHARED/$SYMLINK" "$PREFIX$TARGETDIR/webroot/$SYMLINK"
chown $APACHE_USER. "$PREFIX$TARGETDIR/webroot/$SYMLINK"
done
cp -a "$PREFIX/$PACKAGE_SHARED/site-blank" "$PREFIX$TARGETDIR/webroot/site"
if [ $BUILD -eq 0 ] ; then
echo $TARGETDIR/webroot >> "$INSTALLATIONS"
chown -R $APACHE_USER. "$PREFIX$TARGETDIR/webroot/site"
fi
echo "### Suggested configuration
#Alias /processwire3 \"$TARGETDIR/webroot\"
<Directory $TARGETDIR/webroot>
php_admin_value session.gc_maxlifetime 86400
php_admin_value memory_limit 128M
php_admin_value upload_max_filesize 20M
php_admin_value post_max_size 20M
php_admin_flag display_errors off
php_admin_flag log_errors on
php_admin_flag magic_quotes_runtime off
php_admin_flag register_globals off
php_admin_flag magic_quotes_gpc off
php_admin_flag magic_quotes_sybase off
php_admin_flag allow_url_include off
php_admin_flag allow_url_fopen off
php_admin_flag safe_mode Off
php_admin_value session.save_path "$TARGETDIR/session"
php_admin_value upload_tmp_dir "$TARGETDIR/tmp"
php_admin_value open_basedir "$TARGETDIR:/usr/share/processwire3:/usr/share/php7/PEAR"
php_admin_value max_execution_time 120
php_admin_value max_input_time 120
"
sed "$PREFIX$PACKAGE_SHARED/htaccess.txt" \
-e "s/^/\t\t/;"
# rule to remove the default redirection s/\(RewriteRule .* index.php?it=\$1 \[L,QSA\]\)/# \1/"
echo " </Directory>"
}
if [ "$COMMAND" == "install" ] ; then
doInstall
fi