From 7ad91c61322f6047587adb8fcb1fc7a8820fda49 Mon Sep 17 00:00:00 2001 From: smf Date: Fri, 8 Mar 2024 17:59:30 +0800 Subject: [PATCH] fixed if condition --- docker-entrypoint.sh | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7f21a7d..5da245f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,35 +1,31 @@ #!/bin/sh set -eu -if [ -z "${INPUT_REMOTE_DOCKER_PORT+x}" ]; then +if [ -z "${INPUT_REMOTE_DOCKER_PORT+x}" ] || [ -z "$INPUT_REMOTE_DOCKER_PORT" ]; then INPUT_REMOTE_DOCKER_PORT=22 fi -if [ -z "${INPUT_REMOTE_DOCKER_HOST+x}" ]; then +if [ -z "${INPUT_REMOTE_DOCKER_HOST+x}" ] || [ -z "$INPUT_REMOTE_DOCKER_HOST" ]; then echo "Input remote_docker_host is required!" exit 1 fi -if [ -z "${INPUT_REMOTE_DOCKER_USER+x}" ]; then +if [ -z "${INPUT_REMOTE_DOCKER_USER+x}" ] || [ -z "$INPUT_REMOTE_DOCKER_USER" ]; then echo "Input remote_docker_user is required!" exit 1 fi -if [ -z "${INPUT_SSH_PRIVATE_KEY+x}" ]; then +if [ -z "${INPUT_SSH_PRIVATE_KEY+x}" ] || [ -z "$INPUT_SSH_PRIVATE_KEY" ]; then echo "Input ssh_private_key is required!" exit 1 fi -if [ -z "${INPUT_ARGS+x}" ]; then +if [ -z "${INPUT_ARGS+x}" ] || [ -z "$INPUT_ARGS" ]; then echo "Input input_args is required!" exit 1 fi -CHANGE_DIR=true -if [ -z "${INPUT_DEPLOY_PATH+x}" ]; then - CHANGE_DIR=false -fi -if $CHANGE_DIR ; then +if ! [ -z "${INPUT_DEPLOY_PATH+x}" ] && ! [ -z "$INPUT_DEPLOY_PATH" ]; then echo "Change working directory" echo "Current: `pwd`" echo "Target: $INPUT_DEPLOY_PATH" @@ -38,7 +34,7 @@ if $CHANGE_DIR ; then cd $INPUT_DEPLOY_PATH fi -if [ -z "${INPUT_DOCKER_REGISTRY_URI+x}" ]; then +if [ -z "${INPUT_DOCKER_REGISTRY_URI+x}" ] || [ -z "$INPUT_DOCKER_REGISTRY_URI" ]; then INPUT_DOCKER_REGISTRY_URI=https://registry.hub.docker.com fi @@ -52,10 +48,6 @@ chmod 600 ~/.ssh/id_rsa eval $(ssh-agent) ssh-add ~/.ssh/id_rsa -SSH_PROXY=true -if [ -z "${INPUT_SSH_PROXY_CMD+x}" ]; then - SSH_PROXY=false -fi echo "Add REMOTE_DOCKER_HOST alias to ~/.ssh/config" touch ~/.ssh/config echo >> ~/.ssh/config @@ -66,7 +58,7 @@ echo " Port $INPUT_REMOTE_DOCKER_PORT" >> ~/.ssh/config echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config echo " StrictHostKeyChecking no" >> ~/.ssh/config echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config -if $SSH_PROXY ; then +if ! [ -z "${INPUT_SSH_PROXY_CMD+x}" ] && ! [ -z "$INPUT_SSH_PROXY_CMD" ]; then echo "Add ProxyCommand: $INPUT_SSH_PROXY_CMD" echo " ProxyCommand $INPUT_SSH_PROXY_CMD" >> ~/.ssh/config fi