From 46ea9598042eb6f43f9b7df5608f485fb6302e78 Mon Sep 17 00:00:00 2001 From: asandikci Date: Fri, 22 Dec 2023 22:26:23 +0300 Subject: [PATCH] test: update nginx local test docker --- nginx_docker_localtest.sh | 80 ++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/nginx_docker_localtest.sh b/nginx_docker_localtest.sh index b304ab6f..341b2fdb 100755 --- a/nginx_docker_localtest.sh +++ b/nginx_docker_localtest.sh @@ -5,7 +5,7 @@ CONT_NAME="IFLRANDEVU_NGINX_LOCALTEST" # nginx docker name MOUNT_PATH="/source" # binded mount path in nginx docker SCRIPT_NAME="nginx_docker_localtest.sh" # name of the *this* file -DEBUG="FALSE" +DEBUG="FALSE" ### REMOTE RELEASE ### LATEST_RELEASE="1.4.3-ifl.2" @@ -14,17 +14,27 @@ DOWNLOAD_LINK=https://git.aliberksandikci.com.tr/ifl/iflrandevu/releases/downloa WEB_ROOT_FOLDER="/usr/share/nginx/html/" +############################ +############################ + +_RED='\033[0;31m' +_NC='\033[0m \e[0m' # No Color, No Effect + HELP=""" Usage: dock [command] [subcommand] COMMANDS: + ${_RED}ini:${_NC} initialize dock command install: install iflrandevu local: get from local /source/ remote: get from git service reconf : reconfigure configs + debug: change application debug status [ON / OFF] restart: restart services (nginx, mariadb, php-fpm) update: update source files with new build on /source/ + status: see current webserver status + root: move to root web folder help : see this help text @@ -162,12 +172,6 @@ php_admin_value[upload_max_filesize] = 50M php_admin_value[post_max_size] = 50M """ -############################ -############################ - -_RED='\033[0;31m' -_NC='\033[0m \e[0m' # No Color, No Effect - _exit() { echo echo @@ -175,6 +179,24 @@ _exit() { exit } +_status() { + set +x + echo + echo + echo "----------------------------------" + echo -e "${_RED}SYSTEM STATUS HEAD${_NC}" + echo "----------------------------------" + service nginx status + service mariadb status + service php8.2-fpm status + echo "----------------------------------" + echo -e "${_RED}SYSTEM STATUS HEAD${_NC}" + echo "----------------------------------" + echo + echo + set -x +} + if [[ $# -eq 0 ]]; then if [[ $(pwd) != *iflrandevu ]]; then echo "PLEASE CHANGE DIRECTORY TO \`iflrandevu/\` BEFORE STARTING SCRIPT" @@ -189,32 +211,43 @@ if [[ $# -eq 0 ]]; then echo "removed" docker run -it -d --name "$CONT_NAME" --mount type=bind,source=".",target=/source/,readonly --publish 8000:80 nginx bash - echo -e "RUN SCRIPT: \`${_RED}bash $MOUNT_PATH/$SCRIPT_NAME docker${_NC}\`" + echo -e "RUN SCRIPT: \`${_RED}bash $MOUNT_PATH/$SCRIPT_NAME docker ini${_NC}\`" docker attach $CONT_NAME --detach-keys="ctrl-k" _exit elif [[ $1 == "attach" ]]; then - docker start $CONT_NAME + if [ -n "$(docker ps -f "name=$CONT_NAME" -f "status=running" -q)" ]; then + echo "the container is already running!" + else + docker start $CONT_NAME + fi + docker attach $CONT_NAME --detach-keys="ctrl-k" elif [[ $1 == "docker" ]]; then set -x - echo "alias dock=\"bash /source/$SCRIPT_NAME docker\"" >>/root/.bashrc - sleep 1 - if [[ $2 == "restart" ]]; then - service mariadb restart - service php8.2-fpm restart + if [[ $2 == "ini" ]]; then + echo "alias dock=\"bash /source/$SCRIPT_NAME docker\"" >>/root/.bashrc + echo "alias root=\"cd $WEB_ROOT_FOLDER\"" >>/root/.bashrc sleep 1 + exec bash + + elif [[ $2 == "debug" ]]; then + case "$3" in + ["oO"]["nN"] | ["tT"]["rR"]["uU"]["eE"] | 1) sed -i "s/\(DEBUG_MODE * = *\).*/\1TRUE;/" "$WEB_ROOT_FOLDER/config.php" ;; + ["oO"]["fF"]["fF"] | ["fF"]["aA"]["lL"]["sS"]["eE"] | 0) sed -i "s/\(DEBUG_MODE * = *\).*/\1FALSE;/" "$WEB_ROOT_FOLDER/config.php" ;; + *) echo -e "$_RED please input ON or OFF $_NC" ;; + esac + + elif [[ $2 == "restart" ]]; then + service mariadb restart + sleep 3 + service php8.2-fpm restart + sleep 3 service nginx restart - echo - echo - echo - - service nginx status - service mariadb status - service php8.2-fpm status + _status elif [[ $2 == "reconf" ]]; then @@ -226,7 +259,9 @@ elif [[ $1 == "docker" ]]; then _exit elif [[ $2 == "update" ]]; then echo "updating sources!" - rsync -av --progress /source/build/ $WEB_ROOT_FOLDER --exclude config.php --exclude storage + rsync -a --progress /source/build/ $WEB_ROOT_FOLDER --exclude config.php --exclude storage + elif [[ $2 == "status" ]]; then + _status elif [[ $2 == "install" ]]; then if [[ $# -eq 2 || ! ($3 == "local" || $3 == "remote") ]]; then @@ -277,7 +312,6 @@ elif [[ $1 == "docker" ]]; then echo -e "$_RED ! COMMAND NOT FOUND ! $_NC" echo echo -e "$HELP" - exec bash fi else