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

cleanup and rewrite

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