From 716a0c2bfbb9f4385e9e56b03a832663d110c56c Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 2 Dec 2022 09:41:25 +0900 Subject: [PATCH] Fix root/base folder problem --- bin/create_user.sh | 2 +- bin/unlock_user.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/create_user.sh b/bin/create_user.sh index 7148f52..343097c 100755 --- a/bin/create_user.sh +++ b/bin/create_user.sh @@ -45,7 +45,7 @@ separator="#"; # base folder for all data # root_folder=$(pwd)'/'; BASE_FOLDER=$(dirname $(readlink -f $0))"/"; -root_folder="${BASE_FOLDER}"; +root_folder="${BASE_FOLDER}../"; input_file='user_list.txt'; output_file="user_password.${timestamp}.txt"; output_zip_folder='zip/'; diff --git a/bin/unlock_user.sh b/bin/unlock_user.sh index d3474ea..05f74dd 100755 --- a/bin/unlock_user.sh +++ b/bin/unlock_user.sh @@ -42,6 +42,7 @@ if [ ! -z "${SSH_GROUP_ADD}" ] && [ "${SSH_GROUP_ADD}" != "allow" ] && [ "${SSH_ fi; BASE_FOLDER=$(dirname $(readlink -f $0))"/"; +root_folder="${BASE_FOLDER}../"; input_file='user_list.txt'; # ignore users (root and admin users) ignore_users=('root' 'ec2-user' 'ubuntu' 'admin'); @@ -86,8 +87,8 @@ for username in "$@"; do # else try to set from option # if not valid use allow ssh_add_group="${SSH_GROUP_ADD}"; - if [ -z "${SSH_GROUP_ADD}" ] && [ -f "${BASE_FOLDER}${input_file}" ]; then - ssh_add_group=$(grep "${username}" "${BASE_FOLDER}${input_file}" | cut -d ";" -f 4 | tr A-Z a-z | tr -d ' '); + if [ -z "${SSH_GROUP_ADD}" ] && [ -f "${root_folder}${input_file}" ]; then + ssh_add_group=$(grep "${username}" "${root_folder}${input_file}" | cut -d ";" -f 4 | tr A-Z a-z | tr -d ' '); fi; if [ "${ssh_access_type}" != "allow" ] && [ "${ssh_access_type}" != "forward" ]; then ssh_add_group="allow";