From 189129bd102ad4ee2a9fc0ef9d47a38867abba46 Mon Sep 17 00:00:00 2001 From: "nap.liu" Date: Sat, 1 Jul 2023 12:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=A4=E6=96=AD=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20[[?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Please enter the commit message for your changes. Lines starting with '' will be ignored, and an empty message aborts the commit. On branch master Changes to be committed: modified: auto-add-bt-trackerlist.sh modified: auto-reload-web-station-docker-reverse-proxy.sh modified: enable-web-station-websocket.sh --- auto-add-bt-trackerlist.sh | 4 +-- ...reload-web-station-docker-reverse-proxy.sh | 28 +++++++++---------- enable-web-station-websocket.sh | 12 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/auto-add-bt-trackerlist.sh b/auto-add-bt-trackerlist.sh index efca660..ee23968 100755 --- a/auto-add-bt-trackerlist.sh +++ b/auto-add-bt-trackerlist.sh @@ -20,7 +20,7 @@ LIGHT_CYAN="\e[96m" WHITE="\e[97m" END="\e[0m" -if [ $DISABLE_COLOR == true ]; then +if [[ $DISABLE_COLOR == true ]]; then BLACK="" RED="" GREEN="" @@ -113,7 +113,7 @@ pakcageList=$(synowebapi --exec api=SYNO.Core.Package method=list version=2 addi isRunning=$(jq -r 'map(select(.id == "DownloadStation") | .additional.status) | .[]' <<<$pakcageList) -if [ $isRunning != "running" ]; then +if [[ $isRunning != "running" ]]; then echo -e "Download Station$RED not running$END exit" exit fi diff --git a/auto-reload-web-station-docker-reverse-proxy.sh b/auto-reload-web-station-docker-reverse-proxy.sh index 0246137..ce3b41e 100755 --- a/auto-reload-web-station-docker-reverse-proxy.sh +++ b/auto-reload-web-station-docker-reverse-proxy.sh @@ -19,7 +19,7 @@ LIGHT_CYAN="\e[96m" WHITE="\e[97m" END="\e[0m" -if [ $DISABLE_COLOR == true ]; then +if [[ $DISABLE_COLOR == true ]]; then BLACK="" RED="" GREEN="" @@ -42,13 +42,13 @@ fi restartDockerContainer() { stop=$(synowebapi --exec api=SYNO.Docker.Container method=stop version=1 name=$1 2>/dev/null) status=$(jq '.success' <<<$stop) - if [ $status == false ]; then + if [[ $status == false ]]; then echo -e $RED"stop container: $1 error: $stop"$END fi start=$(synowebapi --exec api=SYNO.Docker.Container method=start version=1 name=$1 2>/dev/null) status=$(jq '.success' <<<$start) - if [ $status == false ]; then + if [[ $status == false ]]; then echo -e $RED"start container: $1 error: $stop"$END fi @@ -58,7 +58,7 @@ restartDockerContainer() { checkServiceIsOffline() { echo -e "checking container: $GREEN$1$END url: $GREEN$2$END" result=$(curl -I $2 2>/dev/null | grep 200) - if [ ${#result} -eq 0 ]; then + if [[ ${#result} -eq 0 ]]; then echo -e "conatiner need restarted: $RED$1$END" return 1 else @@ -71,7 +71,7 @@ pakcageList=$(synowebapi --exec api=SYNO.Core.Package method=list version=2 addi isRunning=$(jq -r 'map(select(.id == "WebStation") | .additional.status) | .[]' <<<$pakcageList) -if [ $isRunning != "running" ]; then +if [[ $isRunning != "running" ]]; then echo -e "Web Station$RED not running$END exit" exit 0 fi @@ -79,7 +79,7 @@ echo "Web Station is running go next step" isRunning=$(jq -r 'map(select(.id == "ContainerManager") | .additional.status) | .[]' <<<$pakcageList) -if [ $isRunning != "running" ]; then +if [[ $isRunning != "running" ]]; then echo -e "Container Manager$RED not running$END exit" exit 0 fi @@ -88,7 +88,7 @@ echo "Container Manager is running go next step" webStationPortal=$(synowebapi --exec api=SYNO.WebStation.WebService.Portal method=list version=1 2>/dev/null | jq -c '.data.portals | map({host: .fqdn, http: .http_port[0], https: .https_port[0], service: .service, display_name: .shortcut.display_name})') webStationPortalCount=$(jq 'length' <<<$webStationPortal) -if [ $webStationPortalCount -eq 0 ]; then +if [[ $webStationPortalCount -eq 0 ]]; then echo -e $RED"not found Web Station portal"$END exit 0 fi @@ -98,7 +98,7 @@ echo -e "found Web Station portal count: $RED$webStationPortalCount"$END webStationService=$(synowebapi --exec api=SYNO.WebStation.WebService.Service method=list version=1 2>/dev/null | jq -c '.data.services | map(select(.category == "Docker"))') webStationServiceCount=$(jq 'length' <<<$webStationService) -if [ $webStationServiceCount -eq 0 ]; then +if [[ $webStationServiceCount -eq 0 ]]; then echo -e $RED"not found Web Station services exit"$END exit 0 fi @@ -121,15 +121,15 @@ for idx in $(seq 0 $(($webStationServiceCount - 1))); do echo -e "service: $GREEN$serviceName$END enable: $BLUE$serviceEnable$END" - if [ $serviceEnable == true ]; then + if [[ $serviceEnable == true ]]; then echo -e "reverse proxy: $GREEN$portalHost$END ➡️ $GREEN$serviceName$END is$BLUE running$END skip" continue fi - if [ ${#portal} -ne 0 ]; then + if [[ ${#portal} -ne 0 ]]; then container=$(jq -c "map(select(.service.service == $serviceId)) | .[]" <<<$dockerContainer) - if [ ${#container} -eq 0 ]; then + if [[ ${#container} -eq 0 ]]; then echo "service: $GREEN$serviceName$END container$RED is not found skip$END" continue fi @@ -139,7 +139,7 @@ for idx in $(seq 0 $(($webStationServiceCount - 1))); do echo -e "service container: $GREEN$containerName$END status: $GREEN$containerStatus$END" - if [ $containerStatus != 'running' ]; then + if [[ $containerStatus != 'running' ]]; then echo -e "contianer$GREEN $containerName$END is$RED not running$END skip" continue fi @@ -150,13 +150,13 @@ for idx in $(seq 0 $(($webStationServiceCount - 1))); do httpOffline=0 httpsOffline=0 - if [ ${#httpPort} -ne 0 ]; then + if [[ ${#httpPort} -ne 0 ]]; then echo -e "reverse proxy found$GREEN http://$portalHost:$httpsPort $END➡️ $GREEN $proxyTarget $END" checkServiceIsOffline $containerName "http://$portalHost:$httpPort" httpOffline=$? fi - if [ ${#httpsPort} -ne 0 ]; then + if [[ ${#httpsPort} -ne 0 ]]; then echo -e "reverse proxy found$GREEN https://$portalHost:$httpsPort $END➡️ $GREEN $proxyTarget $END" checkServiceIsOffline $containerName "https://$portalHost:$httpsPort" httpsOffline=$? diff --git a/enable-web-station-websocket.sh b/enable-web-station-websocket.sh index 1f1bcbe..a3fe341 100644 --- a/enable-web-station-websocket.sh +++ b/enable-web-station-websocket.sh @@ -20,7 +20,7 @@ LIGHT_CYAN="\e[96m" WHITE="\e[97m" END="\e[0m" -if [ $DISABLE_COLOR == true ]; then +if [[ $DISABLE_COLOR == true ]]; then BLACK="" RED="" GREEN="" @@ -46,7 +46,7 @@ pakcageList=$(synowebapi --exec api=SYNO.Core.Package method=list version=2 addi isRunning=$(jq -r 'map(select(.id == "WebStation") | .additional.status) | .[]' <<<$pakcageList) -if [ $isRunning != "running" ]; then +if [[ $isRunning != "running" ]]; then echo -e "Web Station$RED not running$END exit" exit 0 fi @@ -54,7 +54,7 @@ echo "Web Station is running go next step" isRunning=$(jq -r 'map(select(.id == "ContainerManager") | .additional.status) | .[]' <<<$pakcageList) -if [ $isRunning != "running" ]; then +if [[ $isRunning != "running" ]]; then echo -e "Container Manager$RED not running$END exit" exit 0 fi @@ -63,7 +63,7 @@ echo "Container Manager is running go next step" webStationService=$(synowebapi --exec api=SYNO.WebStation.WebService.Service method=list version=1 2>/dev/null | jq -c '.data.services | map(select(.category == "Docker"))') webStationServiceCount=$(jq 'length' <<<$webStationService) -if [ $webStationServiceCount -eq 0 ]; then +if [[ $webStationServiceCount -eq 0 ]]; then echo -e $RED"not found Web Station services exit"$END exit 0 fi @@ -173,13 +173,13 @@ EOF restartDockerContainer() { stop=$(synowebapi --exec api=SYNO.Docker.Container method=stop version=1 name=$1 2>/dev/null) status=$(jq '.success' <<<$stop) - if [ $status == false ]; then + if [[ $status == false ]]; then echo -e $RED"stop container: $1 error: $stop"$END fi start=$(synowebapi --exec api=SYNO.Docker.Container method=start version=1 name=$1 2>/dev/null) status=$(jq '.success' <<<$start) - if [ $status == false ]; then + if [[ $status == false ]]; then echo -e $RED"start container: $1 error: $stop"$END fi