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
89898ffe
Commit
89898ffe
authored
Jul 11, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add_site: move some parts to a functions
parent
844b2047
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
31 deletions
+62
-31
add_site.sh
web/add_site.sh
+7
-29
config
web/config
+55
-2
No files found.
web/add_site.sh
View file @
89898ffe
...
...
@@ -3,19 +3,13 @@
# $ add_site.sh domain user
test
"
$1
"
||
exit
1
test
"
$2
"
||
exit
1
HOMEDIR
=
/home/
$2
test
-d
"
$HOMEDIR
"
||
exit
1
HOSTBASE
=
$HOMEDIR
/www
LOGDIR
=
$HOMEDIR
/log
TMPDIR
=
$HOMEDIR
/tmp
USERNAME
=
$2
DOMAINNAME
=
$(
echo
"
$1
"
|
tr
[
A-Z]
[
a-z]
)
SESSIONDIR
=
$TMPDIR
/session/
$DOMAINNAME
USERNAME
=
`
echo
$DOMAINNAME
|
sed
-e
"s|
\.
.*||g"
`
SITE
=
$HOSTBASE
/
$DOMAINNAME
echo
$USERNAME
.
./config
set_vars
cd
/etc/httpd2/conf/sites-enabled
||
exit
#if ! grep $SITE /etc/postfix/mydestination 2>/dev/null ; then
...
...
@@ -23,7 +17,7 @@ cd /etc/httpd2/conf/sites-enabled || exit
# echo $1 >>/etc/postfix/mydestination
# cat >>/etc/postfix/virtual <<EOF
#$1 anything
#@$1 $
USER
NAME
#@$1 $
TECH
NAME
#EOF
#
# service postfix adjust
...
...
@@ -56,28 +50,12 @@ chmod g+rwx $SITE/
chmod
o-rwx
$SITE
/
chmod
g+s
$SITE
/
cat
<<
EOF
>
$DOMAINNAME
.conf
#NameVirtualHost *
check_dirs
# -----
$1
-----
<VirtualHost *>
ServerName
$DOMAINNAME
ServerAlias www.
$DOMAINNAME
$USERNAME
.
$TECHHOST
AssignUserID
$2
$2
php_admin_value session.save_path "
$SESSIONDIR
"
php_admin_value open_basedir "
$HOMEDIR
"
php_admin_value upload_tmp_dir "
$TMPDIR
"
php_admin_value safe_mode_include_dir "
$HOMEDIR
"
php_admin_value safe_mode_exec_dir "
$HOMEDIR
"
ServerAdmin
$ADMINMAIL
DocumentRoot "
$SITE
"
ErrorLog
$LOGDIR
/
${
USERNAME
}
_error.log
CustomLog
$LOGDIR
/
${
USERNAME
}
_access.log common
</VirtualHost>
EOF
create_site_config
service httpd2 reload
service httpd2 status
&&
echo
OK
echo
"You can use technical name:
$
USERNAME
.
$TECHHOST
"
echo
"You can use technical name:
$
TECHNAME
.
$TECHHOST
for access to the site.
"
web/config
View file @
89898ffe
# Хост mysql для вписывания в hosts
MYSQLHOST=192.168.3.91
MYSQLHOST=192.168.3.
1
91
# Технический домен
TECHHOST=site.
host03.eterhost
.ru
TECHHOST=site.
azbyka
.ru
# Адрес системого администратора
ADMINMAIL=support@eterhost.ru
# Удалённый каталог backup
BACKUPDIR=/var/local/backup-hosting/azbyka-vps/
# uses USERNAME, DOMAINNAME
set_vars()
{
HOMEDIR=/home/$USERNAME
test -d "$HOMEDIR" || exit 1
HOSTBASE=$HOMEDIR/www
LOGDIR=$HOMEDIR/log
USERTMPDIR=$HOMEDIR/tmp
SESSIONDIR=$USERTMPDIR/session/$DOMAINNAME
TECHNAME=`echo $DOMAINNAME | sed -e "s|\..*||g"`
SITE=$HOSTBASE/$DOMAINNAME
}
check_dir()
{
local dir=$1
test -d ${!dir} && return
echo "Missed dir ${!dir}"
exit 1
}
check_dirs()
{
for i in HOSTBASE LOGDIR USERTMPDIR SESSIONDIR SITE ; do
check_dir $i
done
}
# needs: DOMAINNAME
create_site_config()
{
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 -----
<VirtualHost *>
ServerName $DOMAINNAME
ServerAlias www.$DOMAINNAME $TECHNAME.$TECHHOST
AssignUserID $USERNAME $USERNAME
php_admin_value session.save_path "$SESSIONDIR"
php_admin_value open_basedir "$SITE:$USERTMPDIR:$PHPINCLUDE"
php_admin_value upload_tmp_dir "$USERTMPDIR"
php_admin_value auto_prepend_file "$PHPINCLUDE/prepend.php"
ServerAdmin $ADMINMAIL
DocumentRoot "$SITE"
ErrorLog $LOGDIR/${TECHNAME}_error.log
CustomLog $LOGDIR/${TECHNAME}_access.log common
</VirtualHost>
EOF
}
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