From 76124f312d7ed26801bde3d9cf5e7353f7e0be17 Mon Sep 17 00:00:00 2001 From: scream314 Date: Sun, 4 Jul 2021 14:27:45 +0200 Subject: [PATCH 1/7] feat(testrail-php): update default dependencies * php: 7.3 * ioncube: 10.4.5 * testrail: latest-ion72 --- Dockerfiles/testrail_php/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfiles/testrail_php/Dockerfile b/Dockerfiles/testrail_php/Dockerfile index e9cb163..1b4c1a2 100644 --- a/Dockerfiles/testrail_php/Dockerfile +++ b/Dockerfiles/testrail_php/Dockerfile @@ -1,10 +1,10 @@ -ARG ARG_PHP_VERSION=7.2 +ARG ARG_PHP_VERSION=7.3 FROM php:${ARG_PHP_VERSION}-fpm -ARG ARG_PHP_VERSION=7.2 -ARG ARG_IONCUBE_VERSION=10.3.2 -ARG ARG_URL=https://secure.gurock.com/downloads/testrail/testrail-latest-ion71.zip +ARG ARG_PHP_VERSION=7.3 +ARG ARG_IONCUBE_VERSION=10.4.5 +ARG ARG_URL=https://secure.gurock.com/downloads/testrail/testrail-latest-ion72.zip ENV TR_DEFAULT_TASK_EXECUTION=60 ENV TR_CONFIGPATH="/var/www/testrail/config/" From c2168455217031b8471779bc367167bb767616bd Mon Sep 17 00:00:00 2001 From: scream314 Date: Sun, 4 Jul 2021 14:28:38 +0200 Subject: [PATCH 2/7] fix(testrail-php): add missing apt packages * libonig-dev * libzip-dev --- Dockerfiles/testrail_php/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfiles/testrail_php/Dockerfile b/Dockerfiles/testrail_php/Dockerfile index 1b4c1a2..97f6397 100644 --- a/Dockerfiles/testrail_php/Dockerfile +++ b/Dockerfiles/testrail_php/Dockerfile @@ -23,7 +23,7 @@ LABEL vendor="TestRail" \ RUN \ apt-get update && \ apt-get install -y --no-install-recommends curl zip unzip wget iputils-ping mariadb-client openssl && \ - apt-get install -y --no-install-recommends zlib1g-dev libcurl4-gnutls-dev libldap2-dev zlib1g-dev libxml2-dev libfontconfig1 && \ + apt-get install -y --no-install-recommends libonig-dev libzip-dev zlib1g-dev libcurl4-gnutls-dev libldap2-dev zlib1g-dev libxml2-dev libfontconfig1 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* From a713e14e5c1e978edc0bf97ad86ab9be501f2d59 Mon Sep 17 00:00:00 2001 From: scream314 Date: Sun, 4 Jul 2021 14:29:40 +0200 Subject: [PATCH 3/7] fix(testrail-php): add pdo and pdo_mysql php libraries --- Dockerfiles/testrail_php/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfiles/testrail_php/Dockerfile b/Dockerfiles/testrail_php/Dockerfile index 97f6397..0434d3c 100644 --- a/Dockerfiles/testrail_php/Dockerfile +++ b/Dockerfiles/testrail_php/Dockerfile @@ -35,7 +35,9 @@ RUN \ docker-php-ext-install curl && \ docker-php-ext-install zip && \ docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu && \ - docker-php-ext-install ldap + docker-php-ext-install ldap && \ + docker-php-ext-install pdo && \ + docker-php-ext-install pdo_mysql RUN \ mkdir -p /var/www/testrail && \ From aaf39ac1a14e68e721b7d49223fbc003ebcea58a Mon Sep 17 00:00:00 2001 From: scream314 Date: Sun, 4 Jul 2021 20:45:15 +0200 Subject: [PATCH 4/7] fix(testrail-php): use uname to figure out arch Use `uname -m` to get the architecture for the `docker-php-ext-configure ldap --with-libdir=...` command. This aides multiarch builds (with `docker buildx build`). --- Dockerfiles/testrail_php/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfiles/testrail_php/Dockerfile b/Dockerfiles/testrail_php/Dockerfile index 0434d3c..1f9ca3d 100644 --- a/Dockerfiles/testrail_php/Dockerfile +++ b/Dockerfiles/testrail_php/Dockerfile @@ -34,7 +34,7 @@ RUN \ fi && \ docker-php-ext-install curl && \ docker-php-ext-install zip && \ - docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu && \ + docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu && \ docker-php-ext-install ldap && \ docker-php-ext-install pdo && \ docker-php-ext-install pdo_mysql From 40758720a8f155b52324e66c0bd4c24f6035322f Mon Sep 17 00:00:00 2001 From: scream314 Date: Sun, 4 Jul 2021 22:59:14 +0200 Subject: [PATCH 5/7] fix: yamllint issues in composefiles --- docker-compose.yml | 5 ++--- docker-compose_documented.yml | 6 +++--- docker-compose_external_db.yml | 3 +-- docker-compose_nginx.yml | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c70fc28..bdb1993 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ - # An explanation for docker or docker-compose newcomers can be found in the 'docker-compose_documents.yml' file # Please also use the official docker documentation as a reference: # https://docs.docker.com/ and https://docs.docker.com/compose/ @@ -29,7 +28,7 @@ services: volumes: - 'testrail_mysql:/var/lib/mysql' environment: - MYSQL_USER: "${DB_USER:-testrail}" + MYSQL_USER: "${DB_USER:-testrail}" MYSQL_PASSWORD: "${DB_PWD:-testrail}" MYSQL_DATABASE: "${DB_NAME:-testrail}" MYSQL_ROOT_PASSWORD: "${DB_ROOT_PWD:-my-secret-password}" @@ -60,4 +59,4 @@ volumes: driver_opts: type: none device: "$PWD/${CONFIG_PATH:-_config}" - o: bind \ No newline at end of file + o: bind diff --git a/docker-compose_documented.yml b/docker-compose_documented.yml index 2585bbe..70db1a1 100644 --- a/docker-compose_documented.yml +++ b/docker-compose_documented.yml @@ -33,7 +33,7 @@ services: volumes: # This configuration file is needed when you have an already configured TestRail instance with a DB set up. It needs to get copied # from the container to the '_config' folder first. Pls. read our documentation for the necessary steps. - #- './_config/config.php:/var/www/testrail/config.php:ro' + # - './_config/config.php:/var/www/testrail/config.php:ro' # DON'T DELETE OR MODIFY THIS # This are volumes which is shared across services. The location of the 'opt' volume, which contains attachments, @@ -115,12 +115,12 @@ services: DB_URL: '${DB_URL:-}' -#DON'T DELETE -- This creates the network which connects all services +# DON'T DELETE -- This creates the network which connects all services networks: testrail: driver: bridge -#DON'T DELETE -- This creates volumes needed by testrail +# DON'T DELETE -- This creates volumes needed by testrail # testrail_root contains the testrail installation and is shared between the srv and php services # The 'testrail_opt' and 'testrail_mysql' volumes map to a local folder, as they contain stateful information # With this volume-mapping to e.g. the local folder '_mysql', the database is stored locally (and not in the container). So if the container gets diff --git a/docker-compose_external_db.yml b/docker-compose_external_db.yml index 1ed2e50..eec4d4e 100644 --- a/docker-compose_external_db.yml +++ b/docker-compose_external_db.yml @@ -1,4 +1,3 @@ - # An explanation for docker or docker-compose newcomers can be found in the 'docker-compose_documents.yml' file # Please also use the official docker documentation as a reference: # https://docs.docker.com/ and https://docs.docker.com/compose/ @@ -36,4 +35,4 @@ volumes: driver_opts: type: none device: "$PWD/${CONFIG_PATH:-_config}" - o: bind \ No newline at end of file + o: bind diff --git a/docker-compose_nginx.yml b/docker-compose_nginx.yml index b0f588b..2ef49b2 100644 --- a/docker-compose_nginx.yml +++ b/docker-compose_nginx.yml @@ -1,4 +1,3 @@ - # An explanation for docker or docker-compose newcomers can be found in the 'docker-compose_documents.yml' file # Please also use the official docker documentation as a reference: # https://docs.docker.com/ and https://docs.docker.com/compose/ @@ -76,4 +75,4 @@ volumes: driver_opts: type: none device: "$PWD/${CONFIG_PATH:-_config}" - o: bind \ No newline at end of file + o: bind From 1cbd662dc1f545721ca483dce76098dc9b5fe8aa Mon Sep 17 00:00:00 2001 From: scream314 Date: Sun, 4 Jul 2021 23:08:24 +0200 Subject: [PATCH 6/7] fix: shellcheck errors --- .../testrail_apache/custom-entrypoint.sh | 22 +-- .../testrail_mariadb/custom-entrypoint.sh | 8 +- .../testrail_mysql/custom-entrypoint.sh | 8 +- .../testrail_nginx/custom-entrypoint.sh | 2 +- Dockerfiles/testrail_php/custom-entrypoint.sh | 18 +-- cleanup.sh | 4 +- createSupportInfo.sh | 17 +-- quickstart.sh | 133 ++++++++---------- upgradeTestRail.sh | 4 +- 9 files changed, 95 insertions(+), 121 deletions(-) diff --git a/Dockerfiles/testrail_apache/custom-entrypoint.sh b/Dockerfiles/testrail_apache/custom-entrypoint.sh index e7f05c2..881be1d 100755 --- a/Dockerfiles/testrail_apache/custom-entrypoint.sh +++ b/Dockerfiles/testrail_apache/custom-entrypoint.sh @@ -2,19 +2,19 @@ #set -e function createOptDirectory { - if [ ! -d $1 ] + if [ ! -d "$1" ] then - echo "Creating " $1 - mkdir -p $1 + echo "Creating $1" + mkdir -p "$1" fi - chown -R www-data:www-data $1 + chown -R www-data:www-data "$1" } rm -f /etc/apache2/sites-enabled/ssl_apache_testrail.conf cp /apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf -if [ ! -z "$SSL" ] +if [ -n "$SSL" ] then echo echo "####################################################" @@ -25,15 +25,15 @@ then # Enable SSL a2enmod ssl cp -f /apache-conf/ssl_apache_testrail.conf /etc/apache2/sites-enabled/ssl_apache_testrail.conf - # Perform redirection from HTTP to HTTPS + # Perform redirection from HTTP to HTTPS a2enmod rewrite cp -f /apache-conf/.htaccess /var/www/testrail/.htaccess fi -createOptDirectory $TR_DEFAULT_LOG_DIR -createOptDirectory $TR_DEFAULT_AUDIT_DIR -createOptDirectory $TR_DEFAULT_REPORT_DIR -createOptDirectory $TR_DEFAULT_ATTACHMENT_DIR +createOptDirectory "$TR_DEFAULT_LOG_DIR" +createOptDirectory "$TR_DEFAULT_AUDIT_DIR" +createOptDirectory "$TR_DEFAULT_REPORT_DIR" +createOptDirectory "$TR_DEFAULT_ATTACHMENT_DIR" chown -R www-data:www-data /var/www/testrail/config @@ -49,7 +49,7 @@ done echo "Starting background task" while /bin/true; do php /var/www/testrail/task.php || true - sleep $TR_DEFAULT_TASK_EXECUTION + sleep "$TR_DEFAULT_TASK_EXECUTION" done & echo "##############" diff --git a/Dockerfiles/testrail_mariadb/custom-entrypoint.sh b/Dockerfiles/testrail_mariadb/custom-entrypoint.sh index 36a8f40..de06220 100755 --- a/Dockerfiles/testrail_mariadb/custom-entrypoint.sh +++ b/Dockerfiles/testrail_mariadb/custom-entrypoint.sh @@ -1,19 +1,19 @@ #!/bin/bash set -e -if [ ! -z "$DB_URL" ] && [ "${#DB_URL}" != 0 ] +if [ -n "$DB_URL" ] && [ "${#DB_URL}" != 0 ] then echo echo "####################################################" - echo " Downloading existing TestRail DB dump from URL: " $DB_URL + echo " Downloading existing TestRail DB dump from URL: " "$DB_URL" echo "####################################################" echo - wget --no-check-certificate -O /docker-entrypoint-initdb.d/db.sql $DB_URL + wget --no-check-certificate -O /docker-entrypoint-initdb.d/db.sql "$DB_URL" echo "DB downloaded" echo "####################################################" fi -exec docker-entrypoint.sh mysqld"$@" +exec docker-entrypoint.sh mysqld "$@" diff --git a/Dockerfiles/testrail_mysql/custom-entrypoint.sh b/Dockerfiles/testrail_mysql/custom-entrypoint.sh index 36a8f40..de06220 100755 --- a/Dockerfiles/testrail_mysql/custom-entrypoint.sh +++ b/Dockerfiles/testrail_mysql/custom-entrypoint.sh @@ -1,19 +1,19 @@ #!/bin/bash set -e -if [ ! -z "$DB_URL" ] && [ "${#DB_URL}" != 0 ] +if [ -n "$DB_URL" ] && [ "${#DB_URL}" != 0 ] then echo echo "####################################################" - echo " Downloading existing TestRail DB dump from URL: " $DB_URL + echo " Downloading existing TestRail DB dump from URL: " "$DB_URL" echo "####################################################" echo - wget --no-check-certificate -O /docker-entrypoint-initdb.d/db.sql $DB_URL + wget --no-check-certificate -O /docker-entrypoint-initdb.d/db.sql "$DB_URL" echo "DB downloaded" echo "####################################################" fi -exec docker-entrypoint.sh mysqld"$@" +exec docker-entrypoint.sh mysqld "$@" diff --git a/Dockerfiles/testrail_nginx/custom-entrypoint.sh b/Dockerfiles/testrail_nginx/custom-entrypoint.sh index 320126f..da2984f 100755 --- a/Dockerfiles/testrail_nginx/custom-entrypoint.sh +++ b/Dockerfiles/testrail_nginx/custom-entrypoint.sh @@ -4,7 +4,7 @@ set -e rm -f /etc/nginx/conf.d/ssl_testrail.conf cp -f /nginx-conf/default.conf /etc/nginx/conf.d/default.conf -if [ ! -z "$SSL" ] +if [ -n "$SSL" ] then echo echo "####################################################" diff --git a/Dockerfiles/testrail_php/custom-entrypoint.sh b/Dockerfiles/testrail_php/custom-entrypoint.sh index 467fa79..c4c0661 100755 --- a/Dockerfiles/testrail_php/custom-entrypoint.sh +++ b/Dockerfiles/testrail_php/custom-entrypoint.sh @@ -2,20 +2,20 @@ #set -e function createOptDirectory { - if [ ! -d $1 ] + if [ ! -d "$1" ] then - echo "Creating " $1 - mkdir -p $1 + echo "Creating $1" + mkdir -p "$1" fi - chown -R www-data:www-data $1 + chown -R www-data:www-data "$1" } -createOptDirectory $TR_DEFAULT_LOG_DIR -createOptDirectory $TR_DEFAULT_AUDIT_DIR -createOptDirectory $TR_DEFAULT_REPORT_DIR -createOptDirectory $TR_DEFAULT_ATTACHMENT_DIR +createOptDirectory "$TR_DEFAULT_LOG_DIR" +createOptDirectory "$TR_DEFAULT_AUDIT_DIR" +createOptDirectory "$TR_DEFAULT_REPORT_DIR" +createOptDirectory "$TR_DEFAULT_ATTACHMENT_DIR" chown -R www-data:www-data /var/www/testrail/config @@ -31,7 +31,7 @@ done echo "Starting background task" while /bin/true; do php /var/www/testrail/task.php || true - sleep $TR_DEFAULT_TASK_EXECUTION + sleep "$TR_DEFAULT_TASK_EXECUTION" done & echo "##############" diff --git a/cleanup.sh b/cleanup.sh index c2d6667..7bde958 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -15,7 +15,7 @@ echo echo "###################################################################################" echo -read -p " Type 'yes' to continue or use 'Ctrl+C' to abort: " confirm +read -r -p " Type 'yes' to continue or use 'Ctrl+C' to abort: " confirm if [ "$confirm" = 'yes' ]; then sudo rm -rf _opt/* _mysql/* _config/config.php @@ -23,5 +23,5 @@ if [ "$confirm" = 'yes' ]; then else echo echo "Aborting..." - exit -1 + exit 1 fi \ No newline at end of file diff --git a/createSupportInfo.sh b/createSupportInfo.sh index cb8774e..c733509 100755 --- a/createSupportInfo.sh +++ b/createSupportInfo.sh @@ -5,13 +5,11 @@ echo " This script will create a quick dump with information that helps troubles echo " Results will be put into the 'support-info.txt' file." echo "###################################################################################" - - - supportFile="support-info.txt" rm $supportFile +# shellcheck disable=SC2129 echo "-----------------------------------------------------" >> $supportFile echo "Root directory:" >> $supportFile ls -ahls ./ >> $supportFile @@ -57,31 +55,28 @@ echo "" >> $supportFile echo "-----------------------------------------------------" >> $supportFile echo ".env:" >> $supportFile - envFile=.env if test -f "$envFile"; then - cat $envFile >> $supportFile + cat $envFile >> $supportFile else - echo ".env file does not exist" >> $supportFile + echo ".env file does not exist" >> $supportFile fi - +# shellcheck disable=SC2129 echo "" >> $supportFile echo "-----------------------------------------------------" >> $supportFile echo "config.php in '_config' folder:" >> $supportFile configFile=./_config/config.php if test -f "$configFile"; then - cat $configFile >> $supportFile + cat $configFile >> $supportFile else - echo "config.php not existent in '_config' folder" >> $supportFile + echo "config.php not existent in '_config' folder" >> $supportFile fi - echo "-----------------------------------------------------" >> $supportFile echo echo " --> File successfully created" echo " Please send this file over to TestRail support. Thank you." echo - diff --git a/quickstart.sh b/quickstart.sh index 2ee051d..3368ad6 100755 --- a/quickstart.sh +++ b/quickstart.sh @@ -14,8 +14,7 @@ echo " Please be aware that you will need 'sudo' installed to run this script." echo "###################################################################################" echo - -read -p "Press 'Enter' to continue (or Ctrl+C to abort)" +read -r -p "Press 'Enter' to continue (or Ctrl+C to abort)" echo #variables definition @@ -32,41 +31,39 @@ httpPort=8000 timeStamp=$(date "+%Y.%m.%d-%H.%M.%S") dockerPSOutput=$(docker ps | grep testrail) -mkdir -p $backupDir +mkdir -p $backupDir -if [ -n "${dockerPSOutput}" ]; -then - echo " ### Seems like a TestRail instance is already running" - echo " To shut it down run 'docker-compose down -v' in this folder and then call this script again." - echo - read -n1 -r -p " Press 'c' to continue or any other key to abort..." key +if [ -n "${dockerPSOutput}" ]; then + echo " ### Seems like a TestRail instance is already running" + echo " To shut it down run 'docker-compose down -v' in this folder and then call this script again." + echo + read -n1 -r -p " Press 'c' to continue or any other key to abort..." key - if [ "$key" = 'c' ]; then - continue - else - exit -1 - fi + if [ "$key" = 'c' ]; then + : + else + exit 1 + fi fi echo ##################################### # port -while($true) -do - read -p " Please enter the port number testrail use (default 8000) or press 'c' to continue: " port - - if [[ "$port" = 'c' ]]; then - echo " --> Using port 8000 (default value)" - echo - break - elif ! [[ "$port" =~ ^[0-9]+$ ]]; then - echo " --> Sorry integers only!" - continue - else - echo " --> Using port ${port}" - httpPort=$port - break - fi +while (true); do + read -r -p " Please enter the port number testrail use (default 8000) or press 'c' to continue: " port + + if [[ "$port" == 'c' ]]; then + echo " --> Using port 8000 (default value)" + echo + break + elif ! [[ "$port" =~ ^[0-9]+$ ]]; then + echo " --> Sorry integers only!" + continue + else + echo " --> Using port ${port}" + httpPort=$port + break + fi done echo "" @@ -76,17 +73,17 @@ echo "" echo "These TestRail versions are available" echo -wget -q https://registry.hub.docker.com/v1/repositories/testrail/apache/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' +wget -q https://registry.hub.docker.com/v1/repositories/testrail/apache/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' echo read -r -p "Press 'l' to use 'latest', 'b' for 'beta' or type in the version you want to use: " version echo if [ "$version" = 'l' ]; then - testrailVersion="latest" + testrailVersion="latest" elif [ "$version" = 'b' ]; then - testrailVersion="beta" + testrailVersion="beta" else - testrailVersion=$version + testrailVersion=$version fi ##################################### @@ -97,58 +94,58 @@ echo "An empty database named 'testrail' is automatically created together with echo "In succession, please enter a password for this user. During the installation, use 'testrail' for the database name and the database-user and utilize the password you'll enter now." echo -read -p " Enter a password for the database user: " pwd +read -r -p " Enter a password for the database user: " pwd echo echo "The database also needs a secure root password (needed for debugging/emergency cases)" echo -read -p " Enter a database root password: " root_pwd +read -r -p " Enter a database root password: " root_pwd echo echo echo "The database will be stored in the local folders '_mysql' and files created by TestRail will be placed in '_opt'." if [ "$(ls -A $dbFolder)" ]; then - echo " ... The db-folder already contains files -- moving it to '${backupDir}'" + echo " ... The db-folder already contains files -- moving it to '${backupDir}'" - sudo mv $dbFolder $backupDir/"${dbFolder}_${timeStamp}" - mkdir -p $dbFolder + sudo mv $dbFolder $backupDir/"${dbFolder}_${timeStamp}" + mkdir -p $dbFolder fi ##################################### # opt if [ "$(ls -A $optFolder)" ]; then - echo " ... The opt-folder already contains files -- moving it to '${backupDir}'" + echo " ... The opt-folder already contains files -- moving it to '${backupDir}'" - sudo mv $optFolder $backupDir/"${optFolder}_${timeStamp}" - mkdir -p $optFolder + sudo mv $optFolder $backupDir/"${optFolder}_${timeStamp}" + mkdir -p $optFolder fi ##################################### # .env if test -f "$envFile"; then - echo " ... A '.env' file already exists -- moving it to '${backupDir}'" - - mv .env $backupDir/.env_$timeStamp + echo " ... A '.env' file already exists -- moving it to '${backupDir}'" + mv .env "${backupDir}/.env_${timeStamp}" fi touch $envFile -echo "HTTP_PORT=${httpPort}" >> .env +# shellcheck disable=SC2129 +echo "HTTP_PORT=${httpPort}" >> .env echo "DB_USER=testrail" >> .env echo "DB_NAME=testrail" >> .env -echo "DB_PWD=${pwd}" >> .env +echo "DB_PWD=${pwd}" >> .env echo "DB_ROOT_PWD=${root_pwd}" >> .env -echo "OPT_PATH=${optFolder}" >> .env -echo "MYSQL_PATH=${dbFolder}" >> .env +echo "OPT_PATH=${optFolder}" >> .env +echo "MYSQL_PATH=${dbFolder}" >> .env echo "TESTRAIL_VERSION=${testrailVersion}" >> .env ##################################### # config.php if test -f "$configFile"; then - echo "A 'config.php' file already exists -- it will be saved and a new one will be created during the installation" + echo "A 'config.php' file already exists -- it will be saved and a new one will be created during the installation" - sudo mv $configFile $backupDir/config.php_$timeStamp + sudo mv $configFile "${backupDir}/config.php_${timeStamp}" fi ##################################### @@ -157,7 +154,6 @@ fi echo echo "TestRail will be started now with HTTP and will listen on port ${httpPort}." - docker-compose up -d sleep 5 @@ -172,18 +168,18 @@ echo "If your firewall is not blocking the port, it should also be reachable via # getting network adapters IPs to quickly provide TestRail links netAdapters=$(ip -o link show | awk -F': ' '{print $2}') -(IFS=' +( + IFS=' ' -for adapter in ${netAdapters} -do - : - if [ $adapter == "lo" ] || [[ $adapter == "docker"* ]] || [[ $adapter == "br-"* ]] || [[ $adapter == "veth"* ]]; then - continue + for adapter in ${netAdapters}; do + : + if [ "$adapter" == "lo" ] || [[ $adapter == "docker"* ]] || [[ $adapter == "br-"* ]] || [[ $adapter == "veth"* ]]; then + continue fi - ip=$(ip addr | grep inet | grep "${adapter}" | awk -F" " '{print $2}'| sed -e 's/\/.*$//') + ip=$(ip addr | grep inet | grep "${adapter}" | awk -F" " '{print $2}' | sed -e 's/\/.*$//') echo " --> http://${ip}:${httpPort}" -done + done ) echo @@ -204,20 +200,3 @@ echo echo echo "To shut down TestRail again run the following command in this folder:" echo "docker-compose down -v" - - - - - - - - - - - - - - - - - diff --git a/upgradeTestRail.sh b/upgradeTestRail.sh index 93d0556..53fab8b 100755 --- a/upgradeTestRail.sh +++ b/upgradeTestRail.sh @@ -19,7 +19,7 @@ echo " Please be aware that you will need 'sudo' installed to run this script." echo "###################################################################################" echo -read -p "Press 'Enter' to continue (or Ctrl+C to abort)" +read -r -p "Press 'Enter' to continue (or Ctrl+C to abort)" echo echo "Upgrading TestRail" @@ -57,7 +57,7 @@ echo "########################################################################## echo -read -p "Press 'Enter' to continue (or Ctrl+C to abort)" +read -r -p "Press 'Enter' to continue (or Ctrl+C to abort)" echo From 414247948ace130d41584e57dfccfdbbc9be56c5 Mon Sep 17 00:00:00 2001 From: scream314 Date: Mon, 5 Jul 2021 00:31:01 +0200 Subject: [PATCH 7/7] fix: hadolint --- Dockerfiles/testrail_apache/Dockerfile | 10 +++++++--- Dockerfiles/testrail_mariadb/Dockerfile | 2 ++ Dockerfiles/testrail_mysql/Dockerfile | 2 ++ Dockerfiles/testrail_php/Dockerfile | 12 ++++++++---- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Dockerfiles/testrail_apache/Dockerfile b/Dockerfiles/testrail_apache/Dockerfile index 44741f9..8810a37 100644 --- a/Dockerfiles/testrail_apache/Dockerfile +++ b/Dockerfiles/testrail_apache/Dockerfile @@ -19,6 +19,7 @@ LABEL vendor="TestRail" \ type="TestRail php-fpm apache image including ionCube loader." \ description="This is an image which runs apache php-fpm with ionCube for testrail." +# hadolint ignore=DL3008 RUN \ apt-get update && \ apt-get install -y --no-install-recommends curl zip unzip wget iputils-ping mariadb-client openssl && \ @@ -26,9 +27,10 @@ RUN \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# hadolint ignore=DL4006 RUN \ docker-php-ext-install mbstring && \ - if [ "x$ARG_PHP_VERSION" = "5."* ] ; then docker-php-ext-install mysql; \ + if echo "x$ARG_PHP_VERSION" | grep '^x5.*$'; then docker-php-ext-install mysql; \ else docker-php-ext-install mysqli; \ fi && \ docker-php-ext-install curl && \ @@ -38,8 +40,9 @@ RUN \ docker-php-ext-install pdo && \ docker-php-ext-install pdo_mysql +# hadolint ignore=DL3059 RUN \ - wget --no-check-certificate -O /tmp/testrail.zip ${ARG_URL} && \ + wget -nv --no-check-certificate -O /tmp/testrail.zip ${ARG_URL} && \ mkdir -p /var/www/testrail && \ mkdir -p /opt/testrail/attachments /opt/testrail/reports /opt/testrail/logs /opt/testrail/audit && \ unzip /tmp/testrail.zip -d /var/www/ && \ @@ -50,12 +53,13 @@ RUN \ COPY php.ini /usr/local/etc/php/conf.d/php.ini RUN \ - wget -O /tmp/ioncube.tar.gz http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64_${ARG_IONCUBE_VERSION}.tar.gz && \ + wget -nv -O /tmp/ioncube.tar.gz http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64_${ARG_IONCUBE_VERSION}.tar.gz && \ tar -xzf /tmp/ioncube.tar.gz -C /tmp && \ mv /tmp/ioncube /opt/ioncube && \ echo zend_extension=/opt/ioncube/ioncube_loader_lin_${ARG_PHP_VERSION}.so >> /usr/local/etc/php/php.ini && \ rm -f /tmp/ioncube.tar.gz +# hadolint ignore=DL3059 RUN mkdir -p /apache-conf VOLUME /apache-conf diff --git a/Dockerfiles/testrail_mariadb/Dockerfile b/Dockerfiles/testrail_mariadb/Dockerfile index f31c654..17e30a9 100644 --- a/Dockerfiles/testrail_mariadb/Dockerfile +++ b/Dockerfiles/testrail_mariadb/Dockerfile @@ -6,6 +6,8 @@ LABEL vendor="TestRail" \ email="cbreitwieser@ranorex.com" \ type="TestRail mariadb image" \ description="This is an image which runs mariadb and accepts a link to a db-dump for initialization." + +# hadolint ignore=DL3008 RUN \ apt-get update && \ apt-get install -y --no-install-recommends wget iputils-ping && \ diff --git a/Dockerfiles/testrail_mysql/Dockerfile b/Dockerfiles/testrail_mysql/Dockerfile index 23ceda6..981b875 100644 --- a/Dockerfiles/testrail_mysql/Dockerfile +++ b/Dockerfiles/testrail_mysql/Dockerfile @@ -6,6 +6,8 @@ LABEL vendor="TestRail" \ email="cbreitwieser@ranorex.com" \ type="TestRail mariadb image" \ description="This is an image which runs mysql and accepts a link to a db-dump for initialization." + +# hadolint ignore=DL3008 RUN \ apt-get update && \ apt-get install -y --no-install-recommends wget && \ diff --git a/Dockerfiles/testrail_php/Dockerfile b/Dockerfiles/testrail_php/Dockerfile index 1f9ca3d..ef90cf8 100644 --- a/Dockerfiles/testrail_php/Dockerfile +++ b/Dockerfiles/testrail_php/Dockerfile @@ -20,6 +20,7 @@ LABEL vendor="TestRail" \ type="TestRail php-fpm image including ionCube loader." \ description="This is an image which runs php-fpm with ionCube for testrail." +# hadolint ignore=DL3008 RUN \ apt-get update && \ apt-get install -y --no-install-recommends curl zip unzip wget iputils-ping mariadb-client openssl && \ @@ -27,22 +28,25 @@ RUN \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# hadolint ignore=DL3059 +# hadolint ignore=DL4006 RUN \ docker-php-ext-install mbstring && \ - if [ "x$ARG_PHP_VERSION" = "5."* ] ; then docker-php-ext-install mysql; \ + if echo "x$ARG_PHP_VERSION" | grep '^x5.*$'; then docker-php-ext-install mysql; \ else docker-php-ext-install mysqli; \ fi && \ docker-php-ext-install curl && \ docker-php-ext-install zip && \ - docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu && \ + docker-php-ext-configure ldap --with-libdir="lib/$(uname -m)-linux-gnu" && \ docker-php-ext-install ldap && \ docker-php-ext-install pdo && \ docker-php-ext-install pdo_mysql +# hadolint ignore=DL3059 RUN \ mkdir -p /var/www/testrail && \ mkdir -p /opt/testrail/attachments /opt/testrail/reports /opt/testrail/logs /opt/testrail/audit && \ - wget --no-check-certificate -O /tmp/testrail.zip ${ARG_URL} && \ + wget -nv --no-check-certificate -O /tmp/testrail.zip ${ARG_URL} && \ unzip /tmp/testrail.zip -d /var/www/ && \ rm /tmp/testrail.zip && \ chown -R www-data:www-data /var/www/testrail && \ @@ -51,7 +55,7 @@ RUN \ COPY php.ini /usr/local/etc/php/conf.d/php.ini RUN \ - wget -O /tmp/ioncube.tar.gz http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64_${ARG_IONCUBE_VERSION}.tar.gz && \ + wget -nv -O /tmp/ioncube.tar.gz http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64_${ARG_IONCUBE_VERSION}.tar.gz && \ tar -xzf /tmp/ioncube.tar.gz -C /tmp && \ mv /tmp/ioncube /opt/ioncube && \ echo zend_extension=/opt/ioncube/ioncube_loader_lin_${ARG_PHP_VERSION}.so >> /usr/local/etc/php/php.ini && \