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
2f3d5890
Commit
2f3d5890
authored
Jul 11, 2018
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add alternate host support, add mediawiki support, initial php-fpm support
parent
1ed1c81a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
30 deletions
+151
-30
base.task.sample
vz/azbyka/base.task.sample
+25
-0
createbytask.int.sh
vz/azbyka/createbytask.int.sh
+104
-13
createbytask.sh
vz/azbyka/createbytask.sh
+22
-17
No files found.
vz/azbyka/base.task.sample
0 → 100644
View file @
2f3d5890
# OpenVZ
TEMPLATE=etersoft-p8
# Script
PKGPROFILE="apache2-php7"
# PHP
PHP_memory_limit=256M
PHP_max_execution_time=30
PHP_post_max_size=40M
PHP_max_file_uploads=200
# Site
#DOMAIN=site.azbyka.ru
#BASENAME=azbyka
NGINXIP=192.168.3.254
# Original container (with source apache configs)
#VEIDORIG=193
BASEIP=192.168.0
# must have services
SERVICES="crond"
vz/azbyka/createbytask.int.sh
View file @
2f3d5890
...
@@ -36,7 +36,7 @@ rewrite_if_changed()
...
@@ -36,7 +36,7 @@ rewrite_if_changed()
}
}
tune_hosts
()
tune_hosts
_azbyka
()
{
{
cat
<<
EOF
>/etc/hosts.tmpCB
cat
<<
EOF
>/etc/hosts.tmpCB
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost.localdomain localhost
...
@@ -58,6 +58,30 @@ EOF
...
@@ -58,6 +58,30 @@ EOF
rewrite_if_changed /etc/hosts.tmpCB /etc/hosts
&&
update_chrooted conf
rewrite_if_changed /etc/hosts.tmpCB /etc/hosts
&&
update_chrooted conf
}
}
tune_hosts_host03
()
{
cat
<<
EOF
>/etc/hosts.tmpCB
127.0.0.1 localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment.
$VEIP
$AUSER
.site.host03.ru
$AUSER
# Azbyka's hosts
192.168.3.188 memcached
192.168.3.188 memcached.host03
#136.243.107.44 sphinx.azbyka
192.168.3.188 redis
192.168.3.188 redis.host03
192.168.3.91 mysql.host03
192.168.3.91 mysql
192.168.3.91 mysql.
$AUSER
#192.168.3.190 mariadb.azbyka
#192.168.3.190 mariadb
#192.168.3.190 mariadb.
$AUSER
EOF
rewrite_if_changed /etc/hosts.tmpCB /etc/hosts
&&
update_chrooted conf
}
tune_logrotate
()
tune_logrotate
()
{
{
...
@@ -79,7 +103,7 @@ EOF
...
@@ -79,7 +103,7 @@ EOF
rewrite_if_changed /etc/logrotate.d/apache-home-local.tmpCB /etc/logrotate.d/apache-home-local
rewrite_if_changed /etc/logrotate.d/apache-home-local.tmpCB /etc/logrotate.d/apache-home-local
}
}
tune_monit
()
tune_monit
_apache2
()
{
{
epmi
--auto
--skip-installed
monit
epmi
--auto
--skip-installed
monit
serv monit on
serv monit on
...
@@ -105,11 +129,10 @@ EOF
...
@@ -105,11 +129,10 @@ EOF
serv monit reload
serv monit reload
}
}
tune_php7
()
# arg: path to php.ini
tune_php
()
{
{
# FIXME: php version
local
aphp
=
"
$1
"
PHPVERSION
=
7.1
local
aphp
=
/etc/php/
$PHPVERSION
/apache2-mod_php/php.ini
#[ -s php7.add ] && cat php7.add | st tee -a $aphp
#[ -s php7.add ] && cat php7.add | st tee -a $aphp
[
-n
"
$PHP_memory_limit
"
]
&&
subst
"s|^memory_limit =.*|memory_limit =
$PHP_memory_limit
|"
$aphp
[
-n
"
$PHP_memory_limit
"
]
&&
subst
"s|^memory_limit =.*|memory_limit =
$PHP_memory_limit
|"
$aphp
[
-n
"
$PHP_max_execution_time
"
]
&&
subst
"s|^max_execution_time = .*|max_execution_time =
$PHP_max_execution_time
|"
$aphp
[
-n
"
$PHP_max_execution_time
"
]
&&
subst
"s|^max_execution_time = .*|max_execution_time =
$PHP_max_execution_time
|"
$aphp
...
@@ -139,7 +162,7 @@ tune_apache2()
...
@@ -139,7 +162,7 @@ tune_apache2()
cat
<<
EOF
> /etc/httpd2/conf/mods-available/remoteip.conf
cat
<<
EOF
> /etc/httpd2/conf/mods-available/remoteip.conf
<IfModule remoteip_module>
<IfModule remoteip_module>
RemoteIPHeader X-Forwarded-For
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy
192.168.3.254
/32
RemoteIPInternalProxy
$NGINXIP
/32
</IfModule>
</IfModule>
EOF
EOF
ln
-sr
/etc/httpd2/conf/mods-available/remoteip.conf /etc/httpd2/conf/mods-enabled/remoteip.conf
ln
-sr
/etc/httpd2/conf/mods-available/remoteip.conf /etc/httpd2/conf/mods-enabled/remoteip.conf
...
@@ -206,14 +229,60 @@ EOF
...
@@ -206,14 +229,60 @@ EOF
serv httpd2 restart
||
fatal
serv httpd2 restart
||
fatal
}
}
groupadd
$AUSER
-g
$AGROUPID
tune_apache2_mediawiki
()
useradd
-M
$AUSER
-u
$AUSERID
-g
$AGROUPID
#|| fatal
{
for
i
in
mod_php7 status remoteip setenvif rewrite session include
;
do
a2enmod
$i
done
#for i in include; do
# a2dismod $i
#done
for
i
in
httpd-multilang-errordoc
;
do
a2disextra
$i
done
cat
<<
EOF
> /etc/httpd2/conf/mods-available/remoteip.conf
<IfModule remoteip_module>
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy
$NGINXIP
/32
</IfModule>
EOF
ln
-sr
/etc/httpd2/conf/mods-available/remoteip.conf /etc/httpd2/conf/mods-enabled/remoteip.conf
# cp /tmp/prepend.php /etc/httpd2/conf/include/prepend.php || fatal
# fix remoteip
subst
's|LogFormat "%h|LogFormat "%a|g'
/etc/httpd2/conf/mods-available/log_config.conf
a2dissite 000-default
a2dissite ports_all
serv httpd2 restart
||
fatal
}
tune_php7_fpm
()
{
# /etc/fpm7/php-fpm.d/mediawiki.conf
serv php7-fpm on
}
# common project
if
[
-n
"
$AUSERID
"
]
;
then
groupadd
$AUSER
-g
$AGROUPID
useradd
-M
$AUSER
-u
$AUSERID
-g
$AGROUPID
#|| fatal
fi
# locales
# locales
echo
"%_install_langs ru:en:C"
>
/etc/rpm/macros
echo
"%_install_langs ru:en:C"
>
/etc/rpm/macros
epmi
--auto
--skip-installed
glibc-locales
epmi
--auto
--skip-installed
glibc-locales
tune_hosts
# hack to drop tarball dir
rmdir
*
.tar 2>/dev/null
# common project
if
[
-n
"
$AUSERID
"
]
;
then
tune_hosts_azbyka
fi
for
i
in
$PKGPROFILE
;
do
for
i
in
$PKGPROFILE
;
do
case
$i
in
case
$i
in
...
@@ -222,13 +291,33 @@ for i in $PKGPROFILE ; do
...
@@ -222,13 +291,33 @@ for i in $PKGPROFILE ; do
# opcache intl yaml xdebug redis tidy
# opcache intl yaml xdebug redis tidy
epmi
--auto
--skip-installed
php7-mbstring php7-pdo php7-curl php7-fileinfo php7-dom php7-exif
\
epmi
--auto
--skip-installed
php7-mbstring php7-pdo php7-curl php7-fileinfo php7-dom php7-exif
\
php7-pdo_mysql php7-mysqli php7-pcntl php7-openssl php7-mcrypt php7-gd2 php7-xmlreader php7-memcached php7-xsl php7-zip php7-redis
php7-pdo_mysql php7-mysqli php7-pcntl php7-openssl php7-mcrypt php7-gd2 php7-xmlreader php7-memcached php7-xsl php7-zip php7-redis
tune_php
7
tune_php
/etc/php/7.1/apache2-mod_php/php.ini
tune_apache2
tune_apache2
tune_monit_apache2
;;
apache2-php7-mediawiki
)
# FIXME:
tune_hosts_host03
epmi
--auto
--skip-installed
apache2-mod_php7
# opcache intl yaml xdebug redis tidy
epmi
--auto
--skip-installed
php7-mbstring php7-pdo php7-curl php7-fileinfo php7-dom php7-exif
\
php7-pdo_mysql php7-mysqli php7-pcntl php7-openssl php7-mcrypt php7-gd2 php7-xmlreader php7-memcached php7-xsl php7-zip php7-redis
tune_php /etc/php/7.1/apache2-mod_php/php.ini
tune_apache2_mediawiki
tune_monit_apache2
;;
;;
apache2-php5
)
apache2-php5
)
epmi
--auto
--skip-installed
apache2-mod_mpm_itk apache2-mod_php5 php5-suhosin
epmi
--auto
--skip-installed
apache2-mod_mpm_itk apache2-mod_php5 php5-suhosin
epmi
--auto
--skip-installed
php5-opcache php5-mbstring php5-mysql php5-zip php5-pspell php5-pdo php5-intl php5-curl php5-fileinfo php5-dom php5-exif php5-xsl php5-memcache
\
epmi
--auto
--skip-installed
php5-opcache php5-mbstring php5-mysql php5-zip php5-pspell php5-pdo php5-intl php5-curl php5-fileinfo php5-dom php5-exif php5-xsl php5-memcache
\
php5-pdo_mysql php5-yaml php5-mysqli php5-xdebug php5-redis php5-pcntl php5-tidy php5-openssl php5-memcached php5-mcrypt php5-gd2 php5-xmlreader
php5-pdo_mysql php5-yaml php5-mysqli php5-xdebug php5-redis php5-pcntl php5-tidy php5-openssl php5-memcached php5-mcrypt php5-gd2 php5-xmlreader
tune_monit_apache2
;;
php7-fpm
)
epmi
--auto
--skip-installed
php7-fpm-fcgi
# opcache intl yaml xdebug redis tidy
epmi
--auto
--skip-installed
php7-mbstring php7-pdo php7-curl php7-fileinfo php7-dom php7-exif
\
php7-pdo_mysql php7-mysqli php7-pcntl php7-openssl php7-mcrypt php7-gd2 php7-xmlreader php7-memcached php7-xsl php7-zip php7-redis
tune_php7_fpm
;;
;;
esac
esac
done
done
...
@@ -239,7 +328,9 @@ for i in $SERVICES ; do
...
@@ -239,7 +328,9 @@ for i in $SERVICES ; do
serv
$i
on
serv
$i
on
done
done
tune_monit
# common project
tune_logrotate
if
[
-n
"
$AUSERID
"
]
;
then
tune_logrotate
fi
epm clean
epm clean
vz/azbyka/createbytask.sh
View file @
2f3d5890
...
@@ -38,7 +38,7 @@ TASK="$1"
...
@@ -38,7 +38,7 @@ TASK="$1"
[
-n
"
$NAME
"
]
||
NAME
=
$(
basename
$TASK
.task
)
[
-n
"
$NAME
"
]
||
NAME
=
$(
basename
$TASK
.task
)
# TODO
# TODO
VEIP
=
192.168.3
.
$VEID
VEIP
=
$BASEIP
.
$VEID
#
#
if
[
-z
"
$AUSER
"
]
;
then
if
[
-z
"
$AUSER
"
]
;
then
...
@@ -66,15 +66,15 @@ assure $ADOMAIN
...
@@ -66,15 +66,15 @@ assure $ADOMAIN
assure
$ACONF
assure
$ACONF
assure
$NAME
assure
$NAME
assure
$VEID
assure
$VEID
assure
$VEIDORIG
#
assure $VEIDORIG
if
!
vzlist
-a
|
grep
"
$VEIP
"
;
then
if
!
vzlist
-a
|
grep
"
$VEIP
"
;
then
vzctl create
$VEID
--ostemplate
=
$TEMPLATE
||
fatal
vzctl create
$VEID
--ostemplate
=
$TEMPLATE
||
fatal
vzctl
set
$VEID
--name
$NAME
--hostname
$ADOMAIN
--onboot
yes
--ipadd
$VEIP
--save
||
fatal
vzctl
set
$VEID
--name
$NAME
--hostname
$ADOMAIN
--onboot
yes
--ipadd
$VEIP
--save
||
fatal
vzctl
set
$VEID
--shmpages
300M
--physpages
1G
--privvmpages
3G
--tcprcvbuf
unlimited
--
kmemsize
70M:8
0M
--numproc
512
--dcachesize
unlimited
--save
||
fatal
vzctl
set
$VEID
--shmpages
300M
--physpages
1G
--privvmpages
3G
--tcprcvbuf
unlimited
--
swappages
512M
--kmemsize
100M:12
0M
--numproc
512
--dcachesize
unlimited
--save
||
fatal
fi
fi
if
[
!
-s
/etc/vz/conf/
$VEID
.mount
]
;
then
if
[
"
$BASENAME
"
=
"azbyka"
]
&&
[
!
-s
/etc/vz/conf/
$VEID
.mount
]
;
then
cat
>
/etc/vz/conf/
$VEID
.mount
<<
EOF
cat
>
/etc/vz/conf/
$VEID
.mount
<<
EOF
#!/bin/bash
#!/bin/bash
export VEID=\
$(
basename
\$
0 .mount
)
export VEID=\
$(
basename
\$
0 .mount
)
...
@@ -103,15 +103,18 @@ st()
...
@@ -103,15 +103,18 @@ st()
vzctl
exec
$VEID
"
$@
"
vzctl
exec
$VEID
"
$@
"
}
}
if
[
!
-s
"apache/
$AUSER
.conf"
]
;
then
# common projects
if
[
-n
"
$VEIDORIG
"
]
;
then
if
[
!
-s
"apache/
$AUSER
.conf"
]
;
then
cat
/var/lib/vz/root/
$VEIDORIG
/etc/httpd2/conf/sites-enabled/
$ACONF
.conf
>
apache/
$ACONF
.conf
cat
/var/lib/vz/root/
$VEIDORIG
/etc/httpd2/conf/sites-enabled/
$ACONF
.conf
>
apache/
$ACONF
.conf
fi
fi
[
-s
apache/
$AUSER
.conf
]
||
fatal
"Empty apache/
$AUSER
.conf"
[
-s
apache/
$AUSER
.conf
]
||
fatal
"Empty apache/
$AUSER
.conf"
cat
apache/
$AUSER
.conf | st
tee
/tmp/
$AUSER
.conf
>
/dev/null
cat
apache/
$AUSER
.conf | st
tee
/tmp/
$AUSER
.conf
>
/dev/null
hostserver
cat
/var/lib/vz/root/
$VEIDORIG
/etc/httpd2/conf/include/prepend.php | st
tee
/tmp/prepend.php
>
/dev/null
hostserver
cat
/var/lib/vz/root/
$VEIDORIG
/etc/httpd2/conf/include/prepend.php | st
tee
/tmp/prepend.php
>
/dev/null
st
test
-s
/tmp/prepend.php
||
fatal
"Empty prepend.php"
st
test
-s
/tmp/prepend.php
||
fatal
"Empty prepend.php"
fi
# copy task into
# copy task into
ATASK
=
/tmp/
$(
basename
$TASK
)
ATASK
=
/tmp/
$(
basename
$TASK
)
...
@@ -127,14 +130,16 @@ echo "ADOMAIN=$ADOMAIN" | st tee -a $ATASK
...
@@ -127,14 +130,16 @@ echo "ADOMAIN=$ADOMAIN" | st tee -a $ATASK
echo
"PKGINSTALL='
$PKGINSTALL
'"
| st
tee
-a
$ATASK
echo
"PKGINSTALL='
$PKGINSTALL
'"
| st
tee
-a
$ATASK
echo
"VEIP=
$VEIP
"
| st
tee
-a
$ATASK
echo
"VEIP=
$VEIP
"
| st
tee
-a
$ATASK
auserid
=
$(
hostserver vzctl
exec
$VEIDORIG
id
-u
$AUSER
)
# common projects
[
-n
"
$auserid
"
]
||
fatal
"can't get user id"
if
[
-n
"
$VEIDORIG
"
]
;
then
echo
"AUSERID=
$auserid
"
| st
tee
-a
$ATASK
auserid
=
$(
hostserver vzctl
exec
$VEIDORIG
id
-u
$AUSER
)
[
-n
"
$auserid
"
]
||
fatal
"can't get user id"
agroupid
=
$(
hostserver vzctl
exec
$VEIDORIG
id
-g
$AUSER
)
echo
"AUSERID=
$auserid
"
| st
tee
-a
$ATASK
[
-n
"
$agroupid
"
]
||
fatal
"can't get group id"
echo
"AGROUPID=
$agroupid
"
| st
tee
-a
$ATASK
agroupid
=
$(
hostserver vzctl
exec
$VEIDORIG
id
-g
$AUSER
)
[
-n
"
$agroupid
"
]
||
fatal
"can't get group id"
echo
"AGROUPID=
$agroupid
"
| st
tee
-a
$ATASK
fi
#echo "WEBMASTER=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK
#echo "WEBMASTER=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK
...
...
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