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 WORKDIR /usr/src
ADD build_node.sh /usr/local/bin/build_node.sh ADD build_node.sh /usr/local/bin/build_node.sh
# 2020/01 # 2020/01
RUN build_node.sh 13.7.0
RUN build_node.sh 13.12.0 RUN build_node.sh 13.12.0
RUN build_node.sh 14.8.0
# 2020/01 # 2020/01
RUN build_node.sh 12.14.1
RUN build_node.sh 12.16.1 RUN build_node.sh 12.16.1
RUN build_node.sh 12.18.3
## Python ## Python
WORKDIR /usr/src WORKDIR /usr/src
ADD build_python.sh /usr/local/bin/build_python.sh ADD build_python.sh /usr/local/bin/build_python.sh
# 2020/01 # 2020/01
RUN build_python.sh 3.8.1
RUN build_python.sh 3.8.2 RUN build_python.sh 3.8.2
RUN build_python.sh 3.8.5
## PHP ## PHP
WORKDIR /usr/src WORKDIR /usr/src
ADD build_php.sh /usr/local/bin/build_php.sh ADD build_php.sh /usr/local/bin/build_php.sh
# 2020/01 # 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.4
RUN build_php.sh 7.4.9
## Roští script ## Roští script

View File

@ -1,5 +1,5 @@
DOCKER=docker DOCKER=docker
VERSION=2020.05-1 VERSION=2020.08-1
all: build 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 ** ** Supported languages **
* Python 3.8.1
* Python 3.8.2 * Python 3.8.2
* Node.js 13.7.0 * Python 3.8.5
* Node.js 13.12.0 * Node.js 13.12.0
* Node.js 14.8.0
* Node.js 12.14.1 * Node.js 12.14.1
* Node.js 12.16.1 * Node.js 12.16.1
* PHP 7.2.29
* PHP 7.4.2
* PHP 7.4.4 * PHP 7.4.4
* PHP 7.4.9
** Additional tools ** ** Additional tools **

177
rosti.sh
View File

@ -8,6 +8,15 @@ HEIGHT=25
TECHDIR=/opt/techs TECHDIR=/opt/techs
PRIMARYDIR=/srv/bin/primary_tech 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: # These environment variables can be set for testing:
# TESTMODE - 1 if test mode is enabled, it skips whiptail # TESTMODE - 1 if test mode is enabled, it skips whiptail
# MENUITEM - selected menu item # MENUITEM - selected menu item
@ -15,47 +24,8 @@ PRIMARYDIR=/srv/bin/primary_tech
# SERVICE - selected service # SERVICE - selected service
# We will use EDITOR environment variables if possible function setTech() {
if [ "$EDITOR" = "" ]; then tech=$1
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
# Activation of primary tech bin directory # Activation of primary tech bin directory
test ! -e $PRIMARYDIR || unlink $PRIMARYDIR 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 /srv/app doesn't exist we will use examples files to create it
if [ ! -e /srv/app ]; then if [ ! -e /srv/app ]; then
mkdir -p /srv/conf/supervisor.d 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 mkdir -p /srv/app
cp -a /opt/examples/$name/* /srv/app/ cp -a /opt/examples/$name/* /srv/app/
mv /srv/app/supervisor.conf /srv/conf/supervisor.d/$name.conf mv /srv/app/supervisor.conf /srv/conf/supervisor.d/$name.conf
else 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 fi
# Pythoon specific stuff # 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 "NOTE: this tool doesn't restart existing processes, if it's needed, please, do it manually"
echo echo
if [ ! "$TESTMODE" = "1" ]; then if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue" read -p "Check the output and hit enter to continue"
else else
exit 0 exit 0
fi fi
;; }
# Services like small tools, databases or so to support the running app
"services") function setService() {
if [ ! "$TESTMODE" = "1" ]; then service=$1
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
case $service in case $service in
"redis") "redis")
@ -167,7 +129,7 @@ while /bin/true; do
echo "NOTE: Redis server is available at localhost:6379" echo "NOTE: Redis server is available at localhost:6379"
echo echo
if [ ! "$TESTMODE" = "1" ]; then if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue" read -p "Check the output and hit enter to continue"
else else
exit 0 exit 0
@ -181,7 +143,7 @@ while /bin/true; do
echo "NOTE: Memcached server is available at localhost:11211" echo "NOTE: Memcached server is available at localhost:11211"
echo echo
if [ ! "$TESTMODE" = "1" ]; then if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue" read -p "Check the output and hit enter to continue"
else else
exit 0 exit 0
@ -191,6 +153,103 @@ while /bin/true; do
continue continue
;; ;;
esac 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 # Simpler crontab editor
"cron") "cron")
@ -198,7 +257,7 @@ while /bin/true; do
crontab /srv/conf/crontab crontab /srv/conf/crontab
echo echo
if [ ! "$TESTMODE" = "1" ]; then if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue" read -p "Check the output and hit enter to continue"
else else
exit 0 exit 0

View File

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