Commit aabf1d11 authored by Vitaly Lipatov's avatar Vitaly Lipatov

web: major update

parent f89d71fb
...@@ -55,33 +55,24 @@ check_dirs() ...@@ -55,33 +55,24 @@ check_dirs()
done done
} }
# needs: DOMAINNAME fatal()
create_site_config()
{ {
local aliaslist= echo "Fatal: $@"
# for get space before exit 1
[ -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 *
# ----- $1 ----- # new file -> old file
<VirtualHost *> rewrite_if_changed()
ServerName $DOMAINNAME {
ServerAlias www.$DOMAINNAME $TECHALIAS$aliaslist local NEWFILE="$1" OLDFILE="$2"
AssignUserID $USERNAME $USERNAME if [ -r $OLDFILE ] ; then
php_admin_value session.save_path "$SESSIONDIR" if diff -u $OLDFILE $NEWFILE ; then
# Due http://drupal.stackexchange.com/questions/10646/i-get-tmp-is-not-writeable-by-the-webserver-on-migration echo "$OLDFILE not changed"
# NOTE: /tmp for open_basedir rm -f $NEWFILE
php_admin_value open_basedir "$SITEDIR:$USERTMPDIR:$PHPINCLUDE:/tmp" else
php_admin_value upload_tmp_dir "$USERTMPDIR" mv -f $NEWFILE $OLDFILE
php_admin_value auto_prepend_file "$PHPINCLUDE/prepend.php" fi
ServerAdmin $ADMINMAIL else
DocumentRoot "$SITEDIR" mv -f $NEWFILE $OLDFILE
ErrorLog $LOGDIR/${TECHNAME}_error.log fi
CustomLog $LOGDIR/${TECHNAME}_access.log common
</VirtualHost>
EOF
} }
...@@ -30,3 +30,65 @@ get_aliaslist() ...@@ -30,3 +30,65 @@ get_aliaslist()
# first xargs -n1 for get line by line, next xargs - for get one line output # 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 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 #!/bin/sh
# run as # DISABLE_LOG=1 ./refresh_site_conf.sh
# for disable log
. ./config . ./config
. ./functions . ./functions
. ./functions-apache . ./functions-apache
...@@ -10,23 +13,11 @@ LISTCONF="*.conf" ...@@ -10,23 +13,11 @@ LISTCONF="*.conf"
[ -n "$*" ] && LISTCONF="$*" [ -n "$*" ] && LISTCONF="$*"
for i in $LISTCONF ; do for i in $LISTCONF ; do
DOMAINNAME=$(get_var $i ServerName | tr [A-Z] [a-z]) test -L $i && continue
USERNAME=$(get_var $i AssignUserID | cut -f1 -d" ")
[ -n "$DOMAINNAME" ] || continue
echo "File $i, site: $DOMAINNAME, user: $USERNAME" parse_site_config
if [ "$i" != "$DOMAINNAME.conf" ] ; then
echo "ERROR with $i: file conf name and site name are not equal!"
continue
fi
set_vars set_vars
ALIASLIST=$(get_aliaslist $i)
[ -z "$ALIASLIST" ] || echo " Alias list: $ALIASLIST"
# one time fix
#mkdir -p $SESSIONDIR/
#chown $USERNAME $SESSIONDIR/
check_dirs 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