Commit aabf1d11 authored by Vitaly Lipatov's avatar Vitaly Lipatov

web: major update

parent f89d71fb
......@@ -55,33 +55,24 @@ check_dirs()
done
}
# needs: DOMAINNAME
create_site_config()
fatal()
{
local aliaslist=
# for get space before
[ -n "$ALIASLIST" ] && aliaslist=" $ALIASLIST"
local PHPINCLUDE=/etc/httpd2/conf/include
[ -r $PHPINCLUDE/prepend.php ] || echo "<?php putenv('TMPDIR='.ini_get('upload_tmp_dir'));" >$PHPINCLUDE/prepend.php
cat <<EOF >$DOMAINNAME.conf
#NameVirtualHost *
echo "Fatal: $@"
exit 1
}
# ----- $1 -----
<VirtualHost *>
ServerName $DOMAINNAME
ServerAlias www.$DOMAINNAME $TECHALIAS$aliaslist
AssignUserID $USERNAME $USERNAME
php_admin_value session.save_path "$SESSIONDIR"
# Due http://drupal.stackexchange.com/questions/10646/i-get-tmp-is-not-writeable-by-the-webserver-on-migration
# NOTE: /tmp for open_basedir
php_admin_value open_basedir "$SITEDIR:$USERTMPDIR:$PHPINCLUDE:/tmp"
php_admin_value upload_tmp_dir "$USERTMPDIR"
php_admin_value auto_prepend_file "$PHPINCLUDE/prepend.php"
ServerAdmin $ADMINMAIL
DocumentRoot "$SITEDIR"
ErrorLog $LOGDIR/${TECHNAME}_error.log
CustomLog $LOGDIR/${TECHNAME}_access.log common
</VirtualHost>
EOF
# new file -> old file
rewrite_if_changed()
{
local NEWFILE="$1" OLDFILE="$2"
if [ -r $OLDFILE ] ; then
if diff -u $OLDFILE $NEWFILE ; then
echo "$OLDFILE not changed"
rm -f $NEWFILE
else
mv -f $NEWFILE $OLDFILE
fi
else
mv -f $NEWFILE $OLDFILE
fi
}
......@@ -30,3 +30,65 @@ get_aliaslist()
# first xargs -n1 for get line by line, next xargs - for get one line output
get_multivar $conf ServerAlias | xargs -n1 echo | sort -u | grep -v "^$SITE\$" | grep -v "^www.$SITE\$" | grep -v "$techhost$" | xargs echo
}
# needs: DOMAINNAME
create_site_config()
{
local aliaslist=
# for get space before
[ -n "$ALIASLIST" ] && aliaslist=" $ALIASLIST"
if [ -n "$DISABLE_LOG" ] ; then
ERRLOGNAME=/dev/null
CUSLOGNAME=/dev/null
else
ERRLOGNAME=$LOGDIR/${TECHNAME}_error.log
CUSLOGNAME=$LOGDIR/${TECHNAME}_access.log
fi
# fix for upload_tmp_dir
local PHPINCLUDE=/etc/httpd2/conf/include
[ -r $PHPINCLUDE/prepend.php ] || echo "<?php putenv('TMPDIR='.ini_get('upload_tmp_dir'));" >$PHPINCLUDE/prepend.php
cat <<EOF >$DOMAINNAME.conf.new
# Autogenerated by $0
# DO NOT CHANGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN!
#NameVirtualHost *
# ----- $1 -----
<VirtualHost *>
ServerName $DOMAINNAME
ServerAlias www.$DOMAINNAME $TECHALIAS$aliaslist
AssignUserID $USERNAME $USERNAME
php_admin_value session.save_path "$SESSIONDIR"
# Due http://drupal.stackexchange.com/questions/10646/i-get-tmp-is-not-writeable-by-the-webserver-on-migration
# NOTE: /tmp for open_basedir
php_admin_value open_basedir "$SITEDIR:$USERTMPDIR:$PHPINCLUDE:/tmp"
php_admin_value upload_tmp_dir "$USERTMPDIR"
php_admin_value auto_prepend_file "$PHPINCLUDE/prepend.php"
ServerAdmin $ADMINMAIL
DocumentRoot "$SITEDIR"
ErrorLog $ERRLOGNAME
CustomLog $CUSLOGNAME common
</VirtualHost>
EOF
rewrite_if_changed $DOMAINNAME.conf.new $DOMAINNAME.conf
}
parse_site_config()
{
DOMAINNAME=$(get_var $i ServerName | tr [A-Z] [a-z])
USERNAME=$(get_var $i AssignUserID | cut -f1 -d" ")
[ -n "$DOMAINNAME" ] || fatal
echo
echo "*** File $i, site: $DOMAINNAME, user: $USERNAME"
if [ "$(basename $i)" != "$DOMAINNAME.conf" ] ; then
fatal "$i: file conf name and site name are not equal!"
fi
ALIASLIST=$(get_aliaslist $i)
[ -z "$ALIASLIST" ] || echo " Alias list: $ALIASLIST"
}
#!/bin/sh
# run as # DISABLE_LOG=1 ./refresh_site_conf.sh
# for disable log
. ./config
. ./functions
. ./functions-apache
......@@ -10,23 +13,11 @@ LISTCONF="*.conf"
[ -n "$*" ] && LISTCONF="$*"
for i in $LISTCONF ; do
DOMAINNAME=$(get_var $i ServerName | tr [A-Z] [a-z])
USERNAME=$(get_var $i AssignUserID | cut -f1 -d" ")
[ -n "$DOMAINNAME" ] || continue
test -L $i && continue
echo "File $i, site: $DOMAINNAME, user: $USERNAME"
if [ "$i" != "$DOMAINNAME.conf" ] ; then
echo "ERROR with $i: file conf name and site name are not equal!"
continue
fi
parse_site_config
set_vars
ALIASLIST=$(get_aliaslist $i)
[ -z "$ALIASLIST" ] || echo " Alias list: $ALIASLIST"
# one time fix
#mkdir -p $SESSIONDIR/
#chown $USERNAME $SESSIONDIR/
check_dirs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment