diff --git a/spsp b/spsp index aed4ce2a348e94e25d832df3b0825b0cd42cb6b3..5ed9a71914715d19048f68ef5062155344ff1852 100755 --- a/spsp +++ b/spsp @@ -2,7 +2,7 @@ # SPSP transfer-tool is developed and maintained by SIB. For more information, please contact spsp-support@sib.swiss -VERSION="1.11.0" # bumped to support spsp --help, spsp --version +VERSION="1.12.0" # bumped to support spsp --help, spsp --version # Define colors that are used in the help screen @@ -120,14 +120,14 @@ initMode() { if [ ! -x "$(command -v sftp)" ]; then printf "${BACK_RED} ERROR ${COL_RESET} ${COL_RED}Stopped with 1 error${COL_RESET} ${COL_GREY} ${TIME} ${COL_RESET}\n" printf "${BACK_RED} error ${COL_RESET} command unavailable: the sftp command is not available on this system and is mandatory for the pipeline.\n" - printf "${BACK_CYAN} INFO ${COL_RESET} Check out OpenSSH at ${COL_CYAN}https://www.openssh.com/${COL_RESET}" + printf "${BACK_CYAN} INFO ${COL_RESET} Check out OpenSSH at ${COL_CYAN} https://www.openssh.com/ ${COL_RESET}" exit 22 fi if [ ! -x "$(command -v nc)" ]; then printf "${BACK_RED} ERROR ${COL_RESET} ${COL_RED}Stopped with 1 error${COL_RESET} ${COL_GREY} ${TIME} ${COL_RESET}\n" printf "${BACK_RED} error ${COL_RESET} command unavailable: the nc command is not available on this system and is mandatory for the pipeline.\n" - printf "${BACK_CYAN} INFO ${COL_RESET} Check out Netcat at ${COL_CYAN}http://netcat.sourceforge.net/${COL_RESET}" + printf "${BACK_CYAN} INFO ${COL_RESET} Check out Netcat at ${COL_CYAN} http://netcat.sourceforge.net/ ${COL_RESET}" exit 22 fi @@ -841,6 +841,21 @@ if [ $# -gt 0 ]; then echo " - Ignoring .env file..." else if [ -f .env ]; then + if [ "$MACHINE" == "linux" ]; then + if [ "$(stat -c "%a" .env)" != "600" ]; then + printf "${BACK_RED} ERROR ${COL_RESET} ${COL_RED}Stopped with 1 error${COL_RESET} ${COL_GREY} ${TIME} ${COL_RESET}\n" + printf "${BACK_RED} error ${COL_RESET} permissions incorrect: the configuration file should be configured with 600 permissions (chmod 600 .env).\n" + printf "${BACK_CYAN} INFO ${COL_RESET} More info at ${COL_CYAN} https://gitlab.sib.swiss/SPSP/transfer-tool/-/wikis/Installation#configure-the-env-file ${COL_RESET}" + exit 22 + fi + elif [ "$MACHINE" == "mac" ]; then + if [ "$(stat -f "%Lp" .env)" != "600" ]; then + printf "${BACK_RED} ERROR ${COL_RESET} ${COL_RED}Stopped with 1 error${COL_RESET} ${COL_GREY} ${TIME} ${COL_RESET}\n" + printf "${BACK_RED} error ${COL_RESET} permissions incorrect: the configuration file should be configured with 600 permissions (chmod 600 .env).\n" + printf "${BACK_CYAN} INFO ${COL_RESET} More info at ${COL_CYAN} https://gitlab.sib.swiss/SPSP/transfer-tool/-/wikis/Installation#configure-the-env-file ${COL_RESET}" + exit 22 + fi + fi source .env else echo " - Creating a new .env file..." @@ -852,6 +867,7 @@ if [ $# -gt 0 ]; then echo "ID=$identifier" >.env echo 'HOST=spsp.sib.swiss' >>.env echo 'SFTP_URL=${ID}@${HOST}:data' >>.env + chmod 600 .env answer=true else echo ""