Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
aabf1d11
Commit
aabf1d11
authored
Sep 05, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web: major update
parent
f89d71fb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
41 deletions
+85
-41
functions
web/functions
+18
-27
functions-apache
web/functions-apache
+62
-0
refresh_site_conf.sh
web/refresh_site_conf.sh
+5
-14
No files found.
web/functions
View file @
aabf1d11
...
...
@@ -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
}
web/functions-apache
View file @
aabf1d11
...
...
@@ -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"
}
web/refresh_site_conf.sh
View file @
aabf1d11
#!/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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment