Abort on invalid option, always set ssh keytype so it doesn't stay on last selected

This commit is contained in:
Clemens Schwaighofer
2023-01-31 13:29:00 +09:00
parent 8808b94413
commit fb00036ab9

View File

@@ -35,6 +35,11 @@ while getopts ":ti" opt; do
i|info)
INFO=1;
;;
\?)
echo -e "\n Option does not exist: ${OPTARG}\n";
echo "Use -t for test and -i for info";
exit 1;
;;
esac;
done;
# hostname for output file only
@@ -52,7 +57,9 @@ output_zip_folder='zip/';
output_zip="users.${timestamp}.zip"
ssh_keygen_folder='ssh-keygen/';
ssh_keygen_folder_created_pub='ssh-keygen-created-pub/';
ssh_keytype='ed25519';
# set default key tpye
default_ssh_keytype='ed25519';
ssh_keytype='';
# sshallow or sshforward
ssh_group='';
ssh_forward_ok=0;
@@ -148,6 +155,8 @@ while read i; do
if [ "${_ssh_keytype}" = "rsa" ]; then
ssh_keytype="${_ssh_keytype}";
#echo "[!!] BACKWARDS COMPATIBLE RSA TYPE SELECTION [!!]";
else
ssh_keytype=${default_ssh_keytype};
fi;
# user & group not set
if [ -z "${username}" ] || [ -z "${_group}" ]; then