Commit 3e4fcd9b authored by Vitaly Lipatov's avatar Vitaly Lipatov

update createbytask

parent 63205798
...@@ -10,3 +10,6 @@ PHP_max_execution_time=15 ...@@ -10,3 +10,6 @@ PHP_max_execution_time=15
# Site # Site
DOMAIN=site.azbyka.ru DOMAIN=site.azbyka.ru
# Original container
VEIDORIG=193
#!/bin/sh
CONFDIR=/vz/root/900/etc/nginx/sites-enabled.d/azbyka.d
#for task in crosswords miloserdie propovedi katehizacija ; do
for task in fiction zdorovie rabota news ; do
veid=$(grep sites80 $CONFDIR/$task.conf | sed -e "s|.*//sites80\([0-9][0-9]\).*|\1|")
[ -n "$veid" ] || { echo "skip $task" ; continue ; }
cat <<EOF >task.task
VEID=1$veid
NAME=$task
EOF
cat task.task
#continue
./createbytask.sh task.task
done
...@@ -6,13 +6,23 @@ fatal() ...@@ -6,13 +6,23 @@ fatal()
exit 1 exit 1
} }
# TODO
assure()
{
[ -n "$1" ] || fatal "empty"
}
TASK="$1" TASK="$1"
[ -s "$TASK" ] || fatal [ -s "$TASK" ] || fatal
. $TASK . $TASK
assure $AUSER
tune_php7() tune_php7()
{ {
local aphp=/etc/php/7.1/apache2-mod_php/php.ini # FIXME: php version
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
...@@ -31,6 +41,10 @@ cat <<EOF > /etc/httpd2/conf/mods-available/remoteip.conf ...@@ -31,6 +41,10 @@ cat <<EOF > /etc/httpd2/conf/mods-available/remoteip.conf
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
# TODO
cp /tmp/$AUSER.conf /etc/httpd2/conf/sites-enabled/$AUSER.conf || fatal
cp /tmp/prepend.php /etc/httpd2/conf/include/prepend.php || fatal
subst "s|^NameVirtualHost.*||g" /etc/httpd2/conf/sites-enabled/$AUSER.conf subst "s|^NameVirtualHost.*||g" /etc/httpd2/conf/sites-enabled/$AUSER.conf
subst "s|^<VirtualHost.*|<VirtualHost *:80>|g" /etc/httpd2/conf/sites-enabled/$AUSER.conf subst "s|^<VirtualHost.*|<VirtualHost *:80>|g" /etc/httpd2/conf/sites-enabled/$AUSER.conf
......
...@@ -17,26 +17,27 @@ if [ -s "base.task" ] ; then ...@@ -17,26 +17,27 @@ if [ -s "base.task" ] ; then
fi fi
TASK="$1" TASK="$1"
[ -n "$TASK" ] || TASK=php7.task #[ -n "$TASK" ] || TASK=php7.task
#[ -n "$TASK" ] || TASK=php7.task
[ -s "$TASK" ] || fatal [ -s "$TASK" ] || fatal
. $TASK . $TASK
# detect name by filename
[ -n "$NAME" ] || NAME=$(basename $TASK .task) [ -n "$NAME" ] || NAME=$(basename $TASK .task)
# TODO # TODO
#STARTVEID=101
#VEID=101
VEIP=192.168.3.$VEID VEIP=192.168.3.$VEID
#VEIDORIG=193
AUSER=azbyka_$NAME AUSER=azbyka_$NAME
assure $NAME assure $NAME
assure $VEID assure $VEID
assure $VEIDORIG
if ! vzlist -a | grep $VEIP ; then if ! vzlist -a | grep " $VEIP " ; then
vzctl create $VEID --ostemplate=$TEMPLATE vzctl create $VEID --ostemplate=$TEMPLATE || fatal
vzctl set $VEID --name $NAME --hostname $NAME.$DOMAIN --onboot yes --ipadd $VEIP --save vzctl set $VEID --name $NAME --hostname $NAME.$DOMAIN --onboot yes --ipadd $VEIP --save || fatal
vzctl set $VEID --shmpages 300M --physpages 1G --privvmpages 2G --tcprcvbuf unlimited --kmemsize 40M:45M --numproc 512 --dcachesize unlimited --save vzctl set $VEID --shmpages 300M --physpages 1G --privvmpages 2G --tcprcvbuf unlimited --kmemsize 40M:45M --numproc 512 --dcachesize unlimited --save || fatal
fi fi
if [ ! -s /etc/vz/conf/$VEID.mount ] ; then if [ ! -s /etc/vz/conf/$VEID.mount ] ; then
...@@ -66,19 +67,30 @@ st() ...@@ -66,19 +67,30 @@ st()
} }
# TODO # TODO
cat /var/lib/vz/root/193/etc/httpd2/conf/sites-enabled/azbyka_$NAME.conf | st tee /etc/httpd2/conf/sites-enabled/azbyka_$NAME.conf cat /var/lib/vz/root/$VEIDORIG/etc/httpd2/conf/sites-enabled/$AUSER.conf | st tee /tmp/$AUSER.conf
# /etc/httpd2/conf/sites-enabled/$AUSER.conf || fatal
cat /var/lib/vz/root/193/etc/httpd2/conf/include/prepend.php | st tee /etc/httpd2/conf/include/prepend.php cat /var/lib/vz/root/$VEIDORIG/etc/httpd2/conf/include/prepend.php | st tee /tmp/prepend.php
# etc/httpd2/conf/include/prepend.php || fatal
cat createbytask.int.sh | st tee /tmp/createbytask.int.sh # copy task into
st chmod 0755 /tmp/createbytask.int.sh
ATASK=/tmp/$(basename $TASK) ATASK=/tmp/$(basename $TASK)
cat $TASK | st tee $ATASK ( [ -s "base.task" ] && cat base.task ; echo ; cat $TASK ; ) | st tee $ATASK
# if we detected it before
echo "NAME=$NAME" | st tee -a $ATASK echo "NAME=$NAME" | st tee -a $ATASK
echo "AUSER=$AUSER" | st tee -a $ATASK echo "AUSER=$AUSER" | st tee -a $ATASK
echo "AUSERID=$(vzctl exec $VEIDORIG id -u $AUSER)" | st tee -a $ATASK
echo "AGROUPID=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK auserid=$(vzctl exec $VEIDORIG id -u $AUSER)
[ -n "$auserid" ] || fatal "can't get user id"
echo "AUSERID=$auserid" | st tee -a $ATASK
agroupid=$(vzctl exec $VEIDORIG id -g $AUSER)
[ -n "$agroupid" ] || fatal "can't get group id"
echo "AGROUPID=$agroupid" | st tee -a $ATASK
#echo "WEBMASTER=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK #echo "WEBMASTER=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK
cat createbytask.int.sh | st tee /tmp/createbytask.int.sh
st chmod 0755 /tmp/createbytask.int.sh
st /tmp/createbytask.int.sh $ATASK || fatal st /tmp/createbytask.int.sh $ATASK || fatal
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