Commit 2cf5e8f6 authored by Vitaly Lipatov's avatar Vitaly Lipatov

cleanup and rewrite

parent 15a732c2
...@@ -31,3 +31,19 @@ SERVICES="crond" ...@@ -31,3 +31,19 @@ SERVICES="crond"
A2ENMOD="mod_php7 status mpm_itk remoteip setenvif rewrite session include" A2ENMOD="mod_php7 status mpm_itk remoteip setenvif rewrite session include"
# A2DISMOD= # A2DISMOD=
# for every task
# required:
# VEID - unique ID (formely container ID, it is source for IP, for port)
# can be overrided:
# NAME - project name (get from filename if empty)
# AUSER - system user (only from standalone projects)
# STANDALONE - not subproject on BASESITE
# TODO: detect by dots in name?
# ADOMAIN - domain (don't used) like name.site.azbyka.ru (real domain for standalone site)
# ACONF - config name (usually the same like name) for nginx and apache
# VEIP - IP of the container
# HOSTHOME - host dir for home
...@@ -28,9 +28,6 @@ assure $ACONF ...@@ -28,9 +28,6 @@ assure $ACONF
assure $ADOMAIN assure $ADOMAIN
assure $VEID assure $VEID
# Выделяем начальное слово в домене
FDOMAINPART="$(echo "$ADOMAIN" | sed -e "s|\..*||")"
# TODO: external config # TODO: external config
ADMINEMAIL=lav@etersoft.ru ADMINEMAIL=lav@etersoft.ru
...@@ -161,9 +158,9 @@ check process httpd2 with pidfile /var/run/httpd2/httpd.pid ...@@ -161,9 +158,9 @@ check process httpd2 with pidfile /var/run/httpd2/httpd.pid
stop program = "/sbin/service httpd2 stop" stop program = "/sbin/service httpd2 stop"
# stop program = "/usr/local/sbin/stophttpd2" # stop program = "/usr/local/sbin/stophttpd2"
if failed host localhost port 80 protocol http if failed host localhost port 80 protocol http
and request "/server-status" timeout 10 seconds 2 times within 3 cycles then alert and request "/server-status/" timeout 10 seconds 2 times within 3 cycles then alert
if failed host localhost port 80 protocol http if failed host localhost port 80 protocol http
and request "/server-status" timeout 20 seconds 3 times within 4 cycles then restart and request "/server-status/" timeout 20 seconds 3 times within 4 cycles then restart
EOF EOF
# TODO: enable /server-status for localhost/server-status # TODO: enable /server-status for localhost/server-status
...@@ -204,7 +201,7 @@ tune_apache2() ...@@ -204,7 +201,7 @@ tune_apache2()
# See https://bugzilla.altlinux.org/show_bug.cgi?id=39115 # See https://bugzilla.altlinux.org/show_bug.cgi?id=39115
local F=/etc/httpd2/conf/mods-start.d/090-etersoft-default.conf local F=/etc/httpd2/conf/mods-start.d/090-etersoft-default.conf
truncate $F truncate -s0 $F
for i in $A2ENMOD ; do for i in $A2ENMOD ; do
docmd a2enmod $i docmd a2enmod $i
...@@ -217,7 +214,7 @@ tune_apache2() ...@@ -217,7 +214,7 @@ tune_apache2()
done done
F=/etc/httpd2/conf/extra-start.d/090-etersoft-default.conf F=/etc/httpd2/conf/extra-start.d/090-etersoft-default.conf
truncate $F truncate -s0 $F
for i in httpd-multilang-errordoc ; do for i in httpd-multilang-errordoc ; do
docmd a2disextra $i docmd a2disextra $i
echo "$i=no" >>$F echo "$i=no" >>$F
...@@ -234,7 +231,7 @@ EOF ...@@ -234,7 +231,7 @@ EOF
cp /tmp/prepend.php /etc/httpd2/conf/include/prepend.php || fatal cp /tmp/prepend.php /etc/httpd2/conf/include/prepend.php || fatal
# TODO # TODO
if [ -s /tmp/$ACONF.conf ] ; then if true || [ -s /tmp/$ACONF.conf ] ; then
cp /tmp/$ACONF.conf /etc/httpd2/conf/sites-enabled/$ACONF.conf || fatal cp /tmp/$ACONF.conf /etc/httpd2/conf/sites-enabled/$ACONF.conf || fatal
subst "s|^NameVirtualHost.*||g" /etc/httpd2/conf/sites-enabled/$ACONF.conf subst "s|^NameVirtualHost.*||g" /etc/httpd2/conf/sites-enabled/$ACONF.conf
subst "s|^<VirtualHost.*|<VirtualHost *:80>|g" /etc/httpd2/conf/sites-enabled/$ACONF.conf subst "s|^<VirtualHost.*|<VirtualHost *:80>|g" /etc/httpd2/conf/sites-enabled/$ACONF.conf
...@@ -337,6 +334,12 @@ EOF ...@@ -337,6 +334,12 @@ EOF
serv httpd2 restart || fatal serv httpd2 restart || fatal
} }
tune_local_memcached_redis()
{
serv redis on
serv memcached on
}
tune_php7_fpm() tune_php7_fpm()
{ {
# /etc/fpm7/php-fpm.d/mediawiki.conf # /etc/fpm7/php-fpm.d/mediawiki.conf
...@@ -379,6 +382,7 @@ for i in $PKGPROFILE ; do ...@@ -379,6 +382,7 @@ for i in $PKGPROFILE ; do
epmi --auto --skip-installed $PHP7BASE epmi --auto --skip-installed $PHP7BASE
tune_php /etc/php/7.?/apache2-mod_php/php.ini tune_php /etc/php/7.?/apache2-mod_php/php.ini
tune_apache2 tune_apache2
tune_local_memcached_redis
tune_monit_apache2 tune_monit_apache2
;; ;;
apache2-php7-mediawiki) apache2-php7-mediawiki)
...@@ -389,6 +393,7 @@ for i in $PKGPROFILE ; do ...@@ -389,6 +393,7 @@ for i in $PKGPROFILE ; do
epmi --auto --skip-installed $PHP7BASE epmi --auto --skip-installed $PHP7BASE
tune_php /etc/php/7.1/apache2-mod_php/php.ini tune_php /etc/php/7.1/apache2-mod_php/php.ini
tune_apache2_mediawiki tune_apache2_mediawiki
tune_local_memcached_redis
tune_monit_apache2 tune_monit_apache2
;; ;;
apache2-php5) apache2-php5)
...@@ -402,6 +407,7 @@ for i in $PKGPROFILE ; do ...@@ -402,6 +407,7 @@ for i in $PKGPROFILE ; do
# missed: intl yaml xdebug tidy # missed: intl yaml xdebug tidy
epmi --auto --skip-installed $PHP7BASE epmi --auto --skip-installed $PHP7BASE
tune_php7_fpm tune_php7_fpm
tune_local_memcached_redis
;; ;;
esac esac
done done
......
...@@ -121,44 +121,33 @@ if [ -z "$DOCKID" ] ; then ...@@ -121,44 +121,33 @@ if [ -z "$DOCKID" ] ; then
fi fi
# common projects (copy from base container) # copy nginx config from old server
if [ -n "$VEIDORIG" ] ; then if false && [ ! -s "/etc/nginx/sites-enabled.d/azbyka.d/$NAME.conf" ] && [ -z "$STANDALONE" ] ; then
# copy nginx config from a06
if [ ! -s "/etc/nginx/sites-enabled.d/azbyka.d/$NAME.conf" ] && [ -n "$STANDALONE" ] ; then
hostserver cat /etc/nginx/sites-enabled.d/azbyka.d/$NAME.conf | sed -e "s|/home/|/azbyka/|" > /etc/nginx/sites-enabled.d/azbyka.d/$NAME.conf hostserver cat /etc/nginx/sites-enabled.d/azbyka.d/$NAME.conf | sed -e "s|/home/|/azbyka/|" > /etc/nginx/sites-enabled.d/azbyka.d/$NAME.conf
hostserver cat /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf | sed -e "s|/home/|/azbyka/|"> /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf hostserver cat /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf | sed -e "s|/home/|/azbyka/|"> /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf
[ -s /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf ] || rm -f /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf [ -s /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf ] || rm -f /etc/nginx/sites-enabled.d/azbyka.d/$NAME-manual.conf
hostserver cat /etc/nginx/include/static-fallback-$NAME.conf > /etc/nginx/include/static-fallback-$NAME.conf hostserver cat /etc/nginx/include/static-fallback-$NAME.conf > /etc/nginx/include/static-fallback-$NAME.conf
fi serv nginx reload
# hack
#VEPORT=$(printf "%03d" $(($VEID-100)))
#cat <<EOF > /etc/nginx/httpconf-enabled.d/upstream_$ACONF.conf
## for site $ADOMAIN/$NAME
#upstream sites8$VEPORT {
# server $VEIP;
#}
#EOF
serv nginx reload
#if [ ! -s "apache/$ACONF.conf" ] ; then #if [ ! -s "apache/$ACONF.conf" ] ; then
# hostserver cat /var/lib/vz/root/$VEIDORIG/etc/httpd2/conf/sites-enabled/$ACONF.conf > apache/$ACONF.conf # hostserver cat /var/lib/vz/root/$VEIDORIG/etc/httpd2/conf/sites-enabled/$ACONF.conf > apache/$ACONF.conf
#fi #fi
if [ -s apache/$ACONF.conf ] ; then #if [ ! -s apache/prepend.php ] ; then
cat apache/$ACONF.conf | st tee /tmp/$ACONF.conf >/dev/null # hostserver cat /var/lib/vz/root/$VEIDORIG/etc/httpd2/conf/include/prepend.php > apache/prepend.php
else #fi
echo "Empty apache/$ACONF.conf, skipped"
fi fi
#if [ ! -s apache/prepend.php ] ; then # TODO: generate apache config inside...
# hostserver cat /var/lib/vz/root/$VEIDORIG/etc/httpd2/conf/include/prepend.php > apache/prepend.php if [ -s apache/$ACONF.conf ] ; then
#fi cat apache/$ACONF.conf | st tee /tmp/$ACONF.conf >/dev/null
cat apache/prepend.php | st tee /tmp/prepend.php >/dev/null else
st test -s /tmp/prepend.php || fatal "Empty prepend.php" fatal "Empty apache/$ACONF.conf, skipped"
fi fi
cat apache/prepend.php | st tee /tmp/prepend.php >/dev/null
st test -s /tmp/prepend.php || fatal "Empty prepend.php"
# copy task into # copy task into
ATASK=/tmp/$(basename $TASK) ATASK=/tmp/$(basename $TASK)
( [ -s "base.task" ] && cat base.task ; echo ; cat $TASK ; ) | st tee $ATASK >/dev/null ( [ -s "base.task" ] && cat base.task ; echo ; cat $TASK ; ) | st tee $ATASK >/dev/null
......
...@@ -27,7 +27,8 @@ hostserver() ...@@ -27,7 +27,8 @@ hostserver()
load_config() { load_config() {
TASK="$1" TASK="$1"
PKGINSTALL= PKGINSTALL=''
STANDALONE=''
if [ -s "base.task" ] ; then if [ -s "base.task" ] ; then
. ./base.task . ./base.task
...@@ -42,39 +43,38 @@ fi ...@@ -42,39 +43,38 @@ fi
# TODO # TODO
[ -n "$VEIP" ] || VEIP=$BASEIP.$VEID [ -n "$VEIP" ] || VEIP=$BASEIP.$VEID
STANDALONE='' # Если указан системный пользователь AUSER или указано STANDALONE, что это отдельный проект на домене
# Если не указан системный пользователь AUSER, считаем, что это отдельный проект [ -n "$AUSER" ] && STANDALONE=1 || AUSER="$NAME"
if [ -z "$AUSER" ] ; then
STANDALONE=1 # Проект на BASESITE (с префиксом BASENAME при его наличии)
if [ -n "$BASENAME" ] ; then if [ -z "$STANDALONE" ] ; then
AUSER=${BASENAME}_$NAME [ -n "$BASENAME" ] && AUSER=${BASENAME}_$NAME
ADOMAIN="$NAME.$DOMAIN" ADOMAIN="$NAME.$DOMAIN"
ACONF="$AUSER" ACONF="$AUSER"
else
AUSER="$NAME"
ADOMAIN="$NAME.$DOMAIN"
ACONF="$AUSER"
fi
fi fi
# TODO: # Не используется:
# Если домен не был явно задан в конфиге, берём из NAME # Если домен не был явно задан в конфиге, берём из NAME
if [ -z "$ADOMAIN" ] ; then [ -n "$ADOMAIN" ] || ADOMAIN="$NAME"
ADOMAIN="$NAME"
fi
# Если название конфига явно не задано, берём из NAME # Если название конфига явно не задано
if [ -z "$ACONF" ] ; then [ -n "$ACONF" ] || ACONF="site_$AUSER"
ACONF="$NAME"
fi
[ -n "$HOSTHOME" ] || HOSTHOME=/$BASENAME [ -z "$HOSTHOME" ] && [ -n "$BASENAME" ] && HOSTHOME=/$BASENAME
# system user
assure $AUSER assure $AUSER
# domain (don't used) like name.site.azbyka.ru
assure $ADOMAIN assure $ADOMAIN
# config name (usually the same like name) for nginx and apache
assure $ACONF assure $ACONF
# project name
assure $NAME assure $NAME
# unique ID (formely container ID, it is source for IP, for port)
assure $VEID assure $VEID
# IP of the container
assure $VEIP
# host dir for home
assure $HOSTHOME assure $HOSTHOME
} }
...@@ -33,7 +33,6 @@ AUSER=azbyka_$NAME ...@@ -33,7 +33,6 @@ AUSER=azbyka_$NAME
assure $NAME assure $NAME
assure $VEID assure $VEID
#assure $VEIDORIG
st() st()
{ {
......
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