Runtime 2020.08-1

* New versions of PHP, Node.js and Python
* Updated rosti.sh to support arguments
This commit is contained in:
Adam Štrauch 2020-08-23 00:49:52 +02:00
parent b54c01cadd
commit 31e63245e1
Signed by: cx
GPG Key ID: 018304FFA8988F8D
5 changed files with 231 additions and 176 deletions

View File

@ -45,28 +45,27 @@ ENV TERM xterm
WORKDIR /usr/src
ADD build_node.sh /usr/local/bin/build_node.sh
# 2020/01
RUN build_node.sh 13.7.0
RUN build_node.sh 13.12.0
RUN build_node.sh 14.8.0
# 2020/01
RUN build_node.sh 12.14.1
RUN build_node.sh 12.16.1
RUN build_node.sh 12.18.3
## Python
WORKDIR /usr/src
ADD build_python.sh /usr/local/bin/build_python.sh
# 2020/01
RUN build_python.sh 3.8.1
RUN build_python.sh 3.8.2
RUN build_python.sh 3.8.5
## PHP
WORKDIR /usr/src
ADD build_php.sh /usr/local/bin/build_php.sh
# 2020/01
RUN build_php.sh 7.2.29
RUN build_php.sh 7.4.2
RUN build_php.sh 7.4.4
RUN build_php.sh 7.4.9
## Roští script

View File

@ -1,5 +1,5 @@
DOCKER=docker
VERSION=2020.05-1
VERSION=2020.08-1
all: build

View File

@ -10,15 +10,14 @@ The image is based on Debian 10 Buster and it's size is around 2.5 GB when it's
** Supported languages **
* Python 3.8.1
* Python 3.8.2
* Node.js 13.7.0
* Python 3.8.5
* Node.js 13.12.0
* Node.js 14.8.0
* Node.js 12.14.1
* Node.js 12.16.1
* PHP 7.2.29
* PHP 7.4.2
* PHP 7.4.4
* PHP 7.4.9
** Additional tools **

177
rosti.sh
View File

@ -8,6 +8,15 @@ HEIGHT=25
TECHDIR=/opt/techs
PRIMARYDIR=/srv/bin/primary_tech
# Usage: rosti php|python|node|memcached|redis OPTINAL_VERSION
#
# This script helps to configure the environment for selected
# language/technology/service. The language or service can be
# selected via TUI menu or optinal arguments.
QUICK_TECH=$1
QUICK_VERSION=$2
# These environment variables can be set for testing:
# TESTMODE - 1 if test mode is enabled, it skips whiptail
# MENUITEM - selected menu item
@ -15,47 +24,8 @@ PRIMARYDIR=/srv/bin/primary_tech
# SERVICE - selected service
# We will use EDITOR environment variables if possible
if [ "$EDITOR" = "" ]; then
export EDITOR=nano
fi
while /bin/true; do
if [ ! "$TESTMODE" = "1" ]; then
menuitem=$(whiptail --menu "Choose what to do" $HEIGHT $WIDTH 6 \
"tech" " Activaton of primary tech" \
"services" " Enable additional services (Redis, Memcached, ..)" \
"cron" " Update crontab" \
"exit" " Exit" \
3>&1 1>&2 2>&3)
else
menuitem=$MENUITEM
fi
case $menuitem in
# Activation of one of the available tech
# Only one tech can be enabled same time but it's possible to use any of them from /opt/techs
"tech")
if [ ! "$TESTMODE" = "1" ]; then
tech=$(whiptail --menu "Select tech" $HEIGHT $WIDTH 6 \
"python-3.8.1" " Python 3.8.1" \
"python-3.8.2" " Python 3.8.2" \
"node-13.7.0" " Node 13.7.0" \
"node-13.12.0" " Node 13.12.0" \
"node-12.14.1" " Node 12.14.1" \
"node-12.16.1" " Node 12.16.1" \
"php-7.2.29" " PHP 7.2.29" \
"php-7.4.2" " PHP 7.4.2" \
"php-7.4.4" " PHP 7.4.4" \
"back" " Go back" \
3>&1 1>&2 2>&3)
else
tech=$TECH
fi
if [ "$tech" = "back" -o "$tech" = "" ]; then
continue
fi
function setTech() {
tech=$1
# Activation of primary tech bin directory
test ! -e $PRIMARYDIR || unlink $PRIMARYDIR
@ -67,12 +37,12 @@ while /bin/true; do
# If /srv/app doesn't exist we will use examples files to create it
if [ ! -e /srv/app ]; then
mkdir -p /srv/conf/supervisor.d
echo "NOTE: /srv/app doesn't exists, creating from $tech example application"
echo "NOTE: /srv/app doesn't exists, creating it from $tech example application"
mkdir -p /srv/app
cp -a /opt/examples/$name/* /srv/app/
mv /srv/app/supervisor.conf /srv/conf/supervisor.d/$name.conf
else
echo "IMPORTANT: /srv/app found so no configuration or files are copied, make sure the application is ok after its process is restarted"
echo "IMPORTANT: /srv/app found so no configuration or files are copied, make sure the application is ok after this process"
fi
# Pythoon specific stuff
@ -137,23 +107,15 @@ while /bin/true; do
echo "NOTE: this tool doesn't restart existing processes, if it's needed, please, do it manually"
echo
if [ ! "$TESTMODE" = "1" ]; then
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
;;
# Services like small tools, databases or so to support the running app
"services")
if [ ! "$TESTMODE" = "1" ]; then
service=$(whiptail --menu "Select service to be enabled" $HEIGHT $WIDTH 6 \
"memcached" " Memcached" \
"redis" " Redis" \
"back" " Go back" \
3>&1 1>&2 2>&3)
else
service=$SERVICE
fi
}
function setService() {
service=$1
case $service in
"redis")
@ -167,7 +129,7 @@ while /bin/true; do
echo "NOTE: Redis server is available at localhost:6379"
echo
if [ ! "$TESTMODE" = "1" ]; then
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
@ -181,7 +143,7 @@ while /bin/true; do
echo "NOTE: Memcached server is available at localhost:11211"
echo
if [ ! "$TESTMODE" = "1" ]; then
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
@ -191,6 +153,103 @@ while /bin/true; do
continue
;;
esac
}
# Use two parameters to handle everything this script allows to user
function quickTech() {
TECH=$1
VERSION=$2
case $TECH in
"python")
if [ -z "$VERSION" ]; then
VERSION=3.8.5
fi
setTech $TECH-$VERSION
;;
"php")
if [ -z "$VERSION" ]; then
VERSION=7.4.9
fi
setTech $TECH-$VERSION
;;
"node")
if [ -z "$VERSION" ]; then
VERSION=14.8.0
fi
setTech $TECH-$VERSION
;;
"memcached")
setService $TECH
;;
"redis")
setService $TECH
;;
esac
}
# If parameters with tech and possibly version are given we just use those
if [ -n "$QUICK_TECH" ]; then
quickTech $QUICK_TECH $QUICK_VERSION
exit 0
fi
# We will use EDITOR environment variables if possible
if [ "$EDITOR" = "" ]; then
export EDITOR=nano
fi
while /bin/true; do
if [ "$MENUITEM" = "" ]; then
menuitem=$(whiptail --menu "Choose what to do" $HEIGHT $WIDTH 6 \
"tech" " Activaton of primary tech" \
"services" " Enable additional services (Redis, Memcached, ..)" \
"cron" " Update crontab" \
"exit" " Exit" \
3>&1 1>&2 2>&3)
else
menuitem=$MENUITEM
fi
case $menuitem in
# Activation of one of the available tech
# Only one tech can be enabled same time but it's possible to use any of them from /opt/techs
"tech")
if [ "$TECH" = "" ]; then
tech=$(whiptail --menu "Select tech" $HEIGHT $WIDTH 6 \
"python-3.8.2" " Python 3.8.2" \
"python-3.8.5" " Python 3.8.5" \
"node-13.12.0" " Node 13.12.0" \
"node-14.8.0" " Node 14.8.0" \
"node-12.16.1" " Node 12.16.1" \
"node-12.18.3" " Node 12.18.3" \
"php-7.4.4" " PHP 7.4.4" \
"php-7.4.9" " PHP 7.4.9" \
"back" " Go back" \
3>&1 1>&2 2>&3)
else
tech=$TECH
fi
if [ "$tech" = "back" -o "$tech" = "" ]; then
continue
fi
setTech $tech
;;
# Services like small tools, databases or so to support the running app
"services")
if [ "$SERVICE" = "" ]; then
service=$(whiptail --menu "Select service to be enabled" $HEIGHT $WIDTH 6 \
"memcached" " Memcached" \
"redis" " Redis" \
"back" " Go back" \
3>&1 1>&2 2>&3)
else
service=$SERVICE
fi
setService $service
;;
# Simpler crontab editor
"cron")
@ -198,7 +257,7 @@ while /bin/true; do
crontab /srv/conf/crontab
echo
if [ ! "$TESTMODE" = "1" ]; then
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0

View File

@ -32,23 +32,6 @@ I=$((I+1))
stop
###############
# Node.js 12.14.1
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-12.14.1 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 3
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT Node.js 12.14.1 response correct"
else
echo "$I/$COUNT Node.js 12.14.1 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
# Node.js 12.16.1
run
@ -64,23 +47,23 @@ fi
I=$((I+1))
stop
###############
# Node.js 13.12.0
# Node.js 12.18.3
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-13.12.0 $CONTAINER_NAME su app -c rosti > /dev/null
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-12.18.3 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 3
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT Node.js 13.12.0 response correct"
echo "$I/$COUNT Node.js 12.18.3 response correct"
else
echo "$I/$COUNT Node.js 13.12.0 response incorrect"
echo "$I/$COUNT Node.js 12.18.3 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
###############
# Node.js 13.7.0
run
@ -97,24 +80,23 @@ fi
I=$((I+1))
stop
###############
# Python 3.8.1
# Node.js 14.8.0
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=python-3.8.1 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 5
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "app.py" > /dev/null
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-14.8.0 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 3
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT Python 3.8.1 response correct"
echo "$I/$COUNT Node.js 14.8.0 response correct"
else
echo "$I/$COUNT Python 3.8.1 response incorrect"
echo "$I/$COUNT Node.js 14.8.0 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
###############
# Python 3.8.2
run
@ -131,23 +113,23 @@ fi
I=$((I+1))
stop
###############
# PHP 7.4.2
# Python 3.8.5
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=php-7.4.2 $CONTAINER_NAME su app -c rosti > /dev/null
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=python-3.8.5 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 5
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "PHP aplikaci" > /dev/null
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "app.py" > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT PHP 7.4.2 response correct"
echo "$I/$COUNT Python 3.8.5 response correct"
else
echo "$I/$COUNT PHP 7.4.2 response incorrect"
echo "$I/$COUNT Python 3.8.5 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
###############
# PHP 7.4.4
run
@ -165,6 +147,22 @@ fi
I=$((I+1))
stop
# PHP 7.4.9
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=php-7.4.9 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 5
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "PHP aplikaci" > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT PHP 7.4.9 response correct"
else
echo "$I/$COUNT PHP 7.4.9 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
###############
if [ "$PROBLEM" = "0" ]; then