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
dfd72ed5
Commit
dfd72ed5
authored
Oct 24, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add port support, fix other codes
parent
f235388c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
18 deletions
+65
-18
add_site.sh
web/add_site.sh
+28
-6
create_sep_sites.sh
web/create_sep_sites.sh
+7
-5
functions
web/functions
+11
-1
functions-apache
web/functions-apache
+18
-5
refresh_site_conf.sh
web/refresh_site_conf.sh
+1
-1
No files found.
web/add_site.sh
View file @
dfd72ed5
...
@@ -3,8 +3,14 @@
...
@@ -3,8 +3,14 @@
# $ add_site.sh domain user
# $ add_site.sh domain user
test
"
$1
"
||
exit
1
test
"
$1
"
||
exit
1
test
"
$2
"
||
exit
1
test
"
$2
"
||
exit
1
DOMAINNAME
=
$(
echo
"
$1
"
|
tr
[
A-Z]
[
a-z] |
sed
-e
"s/:.*//g"
)
SITEPORT
=
$(
echo
"
$1
"
|
sed
"s/.*
\(
:[0-9]
\+\)
/
\1
/g"
)
[
"
$1
"
=
"
$SITEPORT
"
]
&&
SITEPORT
=
USERNAME
=
$2
USERNAME
=
$2
DOMAINNAME
=
$(
echo
"
$1
"
|
tr
[
A-Z]
[
a-z]
)
FLAG
=
$3
ALIASLIST
=
ALIASLIST
=
.
./config
.
./config
...
@@ -43,28 +49,44 @@ chown $USERNAME $SESSIONDIR/
...
@@ -43,28 +49,44 @@ chown $USERNAME $SESSIONDIR/
test
-f
$SITEDIR
/favicon.ico
||
touch
$SITEDIR
/favicon.ico
test
-f
$SITEDIR
/favicon.ico
||
touch
$SITEDIR
/favicon.ico
touch
$SITEDIR
/robots.txt
touch
$SITEDIR
/robots.txt
# due nscd?
# due nscd?
chown
-R
$
2
:webmaster
$SITEDIR
/
||
{
sleep
10
;
chown
-R
$2
:webmaster
$SITEDIR
/
;
}
chown
-R
$
USERNAME
:webmaster
$SITEDIR
/
||
{
sleep
10
;
chown
-R
$USERNAME
:webmaster
$SITEDIR
/
;
}
#chmod o+r $SITE/robots.txt $SITE/favicon.ico
#chmod o+r $SITE/robots.txt $SITE/favicon.ico
chmod
g+rwx
$SITEDIR
/
chmod
g+rwx
$SITEDIR
/
chmod
o-rwx
$SITEDIR
/
chmod
o-rwx
$SITEDIR
/
chmod
g+s
$SITEDIR
/
chmod
g+s
$SITEDIR
/
# HACK for separated
if
[
-n
"
$FLAG
"
]
;
then
TECHALIAS
=
APACHECONF
=
$USERNAME
.conf
fi
check_dirs
check_dirs
create_site_config
create_site_config
if
[
-z
"
$
3
"
]
;
then
if
[
-z
"
$
FLAG
"
]
;
then
service httpd2 reload
service httpd2 reload
# starthttpd2 forces run httpd2
# starthttpd2 forces run httpd2
service httpd2 status
||
starthttpd2
service httpd2 status
||
starthttpd2
fi
cat
<<
EOF
cat
<<
EOF
URL: http://
$DOMAINNAME
URL: http://
$DOMAINNAME
$SITEPORT
Site dir: www/
$DOMAINNAME
Site dir: www/
$DOMAINNAME
Log dir: log/
Log dir: log/
Technical URL: http://
$TECHNAME
.
$TECHHOST
Technical URL: http://
$TECHNAME
.
$TECHHOST
$SITEPORT
EOF
EOF
else
cat
<<
EOF
Internal URL: http://
$DOMAINNAME$SITEPORT
Site dir: www/
$DOMAINNAME
Log dir: log/
EOF
fi
web/create_sep_sites.sh
View file @
dfd72ed5
...
@@ -8,7 +8,7 @@ fatal()
...
@@ -8,7 +8,7 @@ fatal()
exit
1
exit
1
}
}
for
URL
in
$(
cat
create_sep_sites.list |
grep
-v
"#"
)
;
do
cat
create_sep_sites.list |
grep
-v
"#"
|
while
read
PORT URL
;
do
NAME
=
$(
basename
$URL
)
NAME
=
$(
basename
$URL
)
[
-L
"
$MAINSITEDIR
/
$NAME
"
]
&&
{
echo
"Skipping
$NAME
"
;
continue
;
}
[
-L
"
$MAINSITEDIR
/
$NAME
"
]
&&
{
echo
"Skipping
$NAME
"
;
continue
;
}
echo
echo
...
@@ -19,30 +19,32 @@ for URL in $(cat create_sep_sites.list | grep -v "#") ; do
...
@@ -19,30 +19,32 @@ for URL in $(cat create_sep_sites.list | grep -v "#") ; do
#userdel -r $SEPUSER
#userdel -r $SEPUSER
#id $SEPUSER >/dev/null || fatal "$SEPUSER already exists"
#id $SEPUSER >/dev/null || fatal "$SEPUSER already exists"
# HACK: azbyka specific
# Переименовываем, если это основной пользователь
# Переименовываем, если это основной пользователь
if
id
$SEPUSER
>
/dev/null
;
then
if
id
$SEPUSER
>
/dev/null
;
then
if
getent passwd
$SEPUSER
|
grep
-q
/home/azbyka/
;
then
if
getent passwd
$SEPUSER
|
grep
-q
/home/azbyka/
;
then
usermod
-l
${
SEPUSER
/azbyka_/
}
$SEPUSER
||
fatal
usermod
-l
${
SEPUSER
/azbyka_/
}
$SEPUSER
||
fatal
groupmod
-n
${
SEPUSER
/azbyka_/
}
$SEPUSER
||
fatal
groupmod
-n
${
SEPUSER
/azbyka_/
}
$SEPUSER
||
fatal
else
else
echo
"
$SEPUSER
already exists, skipping"
echo
"
User
$SEPUSER
already exists, skipping"
continue
continue
fi
fi
fi
fi
test
-d
/home/
$SEPUSER
&&
fatal
"
$SEPUSER
already created"
test
-d
/home/
$SEPUSER
&&
fatal
"
$SEPUSER
already created"
export
HACKCOMMONDIR
=
"/home/azbyka/www/azbyka.ru/include:/home/azbyka/www/azbyka.ru/orphus"
cat
<<
EOF
cat
<<
EOF
========
$SEPUSER
============
========
$SEPUSER
============
EOF
EOF
./add_user.sh
$SEPUSER
2>>
$0
.errlog
||
fatal
./add_user.sh
$SEPUSER
2>>
$0
.errlog
||
fatal
./add_site.sh
$
SEPUSER
$SEPUSER
NORESTARTAPACHE 2>>
$0
.errlog
./add_site.sh
$
MAINDOMAIN
:
$PORT
$SEPUSER
NORESTARTAPACHE 2>>
$0
.errlog
cat
<<
EOF
cat
<<
EOF
Abs path: /home/
$SEPUSER
/www/
$SEPUSER
/
$NAME
/
Abs path: /home/
$SEPUSER
/www/
$SEPUSER
/
$NAME
/
Real URL: http://
$MAINDOMAIN
/
$NAME
Real URL: http://
$MAINDOMAIN
/
$NAME
EOF
EOF
subst
"s|prepend.php|prepend-azbyka.php|g"
/etc/httpd2/conf/sites-enabled/
$SEPUSER
.conf
#
subst "s|prepend.php|prepend-azbyka.php|g" /etc/httpd2/conf/sites-enabled/$SEPUSER.conf
done
done
service httpd2 reload
#
service httpd2 reload
web/functions
View file @
dfd72ed5
...
@@ -7,7 +7,7 @@ set_vars()
...
@@ -7,7 +7,7 @@ set_vars()
HOSTBASE=$HOMEDIR/www
HOSTBASE=$HOMEDIR/www
LOGDIR=$HOMEDIR/log
LOGDIR=$HOMEDIR/log
USERTMPDIR=$HOMEDIR/tmp
USERTMPDIR=$HOMEDIR/tmp
SESSIONDIR=$
USERTMPDIR/session
/$DOMAINNAME
SESSIONDIR=$
HOMEDIR/sessions
/$DOMAINNAME
TECHNAME=`echo $DOMAINNAME | sed -e "s|\..*||g"`
TECHNAME=`echo $DOMAINNAME | sed -e "s|\..*||g"`
TECHALIAS=$TECHNAME.$TECHHOST
TECHALIAS=$TECHNAME.$TECHHOST
SITEDIR=$HOSTBASE/$DOMAINNAME
SITEDIR=$HOSTBASE/$DOMAINNAME
...
@@ -38,6 +38,16 @@ set_dirperms()
...
@@ -38,6 +38,16 @@ set_dirperms()
mkdir -p $LOGDIR
mkdir -p $LOGDIR
chown -R -v root:apache2 $LOGDIR
chown -R -v root:apache2 $LOGDIR
chmod -v 0755 $LOGDIR
chmod -v 0755 $LOGDIR
# tmp
mkdir -p $USERTMPDIR
chown -v $USERNAME:webmaster $USERTMPDIR
chmod -v 0771 $USERTMPDIR
# sessions
mkdir -p $SESSIONDIR
chown -v root:apache2 $SESSIONDIR
chmod -v 0755 $SESSIONDIR
}
}
check_dir()
check_dir()
...
...
web/functions-apache
View file @
dfd72ed5
...
@@ -50,20 +50,31 @@ fi
...
@@ -50,20 +50,31 @@ fi
local PHPINCLUDE=/etc/httpd2/conf/include
local PHPINCLUDE=/etc/httpd2/conf/include
[ -r $PHPINCLUDE/prepend.php ] || echo "<?php putenv('TMPDIR='.ini_get('upload_tmp_dir'));" >$PHPINCLUDE/prepend.php
[ -r $PHPINCLUDE/prepend.php ] || echo "<?php putenv('TMPDIR='.ini_get('upload_tmp_dir'));" >$PHPINCLUDE/prepend.php
cat <<EOF >$DOMAINNAME.conf.new
[ -n "$SITEPORT" ] || SITEPORT=":80"
[ -n "$APACHECONF" ] || APACHECONF=$DOMAINNAME.conf
cat <<EOF >$APACHECONF.new
# Autogenerated by $0
# Autogenerated by $0
# DO NOT CHANGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN!
# DO NOT CHANGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN!
#NameVirtualHost *
EOF
if [ -n "$FLAG" ] && [ -n "$SITEPORT" ] ; then
cat <<EOF >>$APACHECONF.new
NameVirtualHost *$SITEPORT
EOF
fi
cat <<EOF >>$APACHECONF.new
# ----- $1 -----
# ----- $1 -----
<VirtualHost *>
<VirtualHost *
$SITEPORT
>
ServerName $DOMAINNAME
ServerName $DOMAINNAME
ServerAlias www.$DOMAINNAME $TECHALIAS$aliaslist
ServerAlias www.$DOMAINNAME $TECHALIAS$aliaslist
AssignUserID $USERNAME $USERNAME
AssignUserID $USERNAME $USERNAME
php_admin_value session.save_path "$SESSIONDIR"
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
# Due http://drupal.stackexchange.com/questions/10646/i-get-tmp-is-not-writeable-by-the-webserver-on-migration
# NOTE: /tmp for open_basedir
# NOTE: /tmp for open_basedir
php_admin_value open_basedir "$SITEDIR:$USERTMPDIR:$PHPINCLUDE:/tmp"
php_admin_value open_basedir "$SITEDIR:$USERTMPDIR:$PHPINCLUDE:/tmp
:$HACKCOMMONDIR
"
php_admin_value upload_tmp_dir "$USERTMPDIR"
php_admin_value upload_tmp_dir "$USERTMPDIR"
php_admin_value auto_prepend_file "$PHPINCLUDE/prepend.php"
php_admin_value auto_prepend_file "$PHPINCLUDE/prepend.php"
ServerAdmin $ADMINMAIL
ServerAdmin $ADMINMAIL
...
@@ -73,12 +84,14 @@ cat <<EOF >$DOMAINNAME.conf.new
...
@@ -73,12 +84,14 @@ cat <<EOF >$DOMAINNAME.conf.new
</VirtualHost>
</VirtualHost>
EOF
EOF
rewrite_if_changed $
DOMAINNAME.conf.new $DOMAINNAME.conf
rewrite_if_changed $
APACHECONF.new $APACHECONF
}
}
parse_site_config()
parse_site_config()
{
{
local i=$1
SITEPORT=$(get_var $i "<VirtualHost" | sed -e "s/.*:/:/g" | sed -e "s/[\*>]//g")
DOMAINNAME=$(get_var $i ServerName | tr [A-Z] [a-z])
DOMAINNAME=$(get_var $i ServerName | tr [A-Z] [a-z])
USERNAME=$(get_var $i AssignUserID | cut -f1 -d" ")
USERNAME=$(get_var $i AssignUserID | cut -f1 -d" ")
[ -n "$DOMAINNAME" ] || fatal
[ -n "$DOMAINNAME" ] || fatal
...
...
web/refresh_site_conf.sh
View file @
dfd72ed5
...
@@ -15,7 +15,7 @@ LISTCONF="*.conf"
...
@@ -15,7 +15,7 @@ LISTCONF="*.conf"
for
i
in
$LISTCONF
;
do
for
i
in
$LISTCONF
;
do
test
-L
$i
&&
continue
test
-L
$i
&&
continue
parse_site_config
parse_site_config
$i
set_vars
set_vars
...
...
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