From 1d1c4e01d6642ced5ed9134e0fdb5136f846ebe5 Mon Sep 17 00:00:00 2001 From: Ravinou Date: Sun, 3 Sep 2023 15:31:15 +0200 Subject: [PATCH] fix: remove \n in end of the error msg --- helpers/shells/createRepo.sh | 10 +++++----- helpers/shells/deleteRepo.sh | 8 ++++---- helpers/shells/updateRepo.sh | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/helpers/shells/createRepo.sh b/helpers/shells/createRepo.sh index 6c08fe2..dfd34ce 100755 --- a/helpers/shells/createRepo.sh +++ b/helpers/shells/createRepo.sh @@ -32,7 +32,7 @@ authorized_keys="${home}/.ssh/authorized_keys" # Check args if [ "$1" == "" ] || [ "$2" == "" ];then - echo "This shell takes 2 arguments : SSH Public Key, Quota in Go [e.g. : 10] " + echo -n "This shell takes 2 arguments : SSH Public Key, Quota in Go [e.g. : 10] " exit 1 fi @@ -41,19 +41,19 @@ fi pattern='(ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29t|ssh-rsa AAAAB3NzaC1yc2)[0-9A-Za-z+/]+[=]{0,3}(\s.*)?' if [[ ! "$1" =~ $pattern ]] then - echo "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)" + echo -n "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)" exit 2 fi # Check if SSH pub key is already present in authorized_keys if grep -q "$1" "$authorized_keys"; then - echo "SSH pub key already present in authorized_keys" + echo -n "SSH pub key already present in authorized_keys" exit 3 fi # Check if borgbackup is installed if ! [ -x "$(command -v borg)" ]; then - echo "You must install borgbackup package." + echo -n "You must install borgbackup package." exit 4 fi @@ -65,7 +65,7 @@ repositoryName=$(randRepositoryName) ## Check if authorized_keys exists if [ ! -f "${authorized_keys}" ];then - echo "${authorized_keys} must be present" + echo -n "${authorized_keys} must be present" exit 5 fi diff --git a/helpers/shells/deleteRepo.sh b/helpers/shells/deleteRepo.sh index 9058760..e4652c5 100755 --- a/helpers/shells/deleteRepo.sh +++ b/helpers/shells/deleteRepo.sh @@ -21,7 +21,7 @@ authorized_keys="${home}/.ssh/authorized_keys" # Check arg if [[ $# -ne 1 || $1 = "" ]]; then - echo "You must provide a repositoryName in argument." + echo -n "You must provide a repositoryName in argument." exit 1 fi @@ -29,7 +29,7 @@ fi # If we receive another length there is necessarily a problem. repositoryName=$1 if [ ${#repositoryName} != 8 ]; then - echo "Error with the length of the repositoryName." + echo -n "Error with the length of the repositoryName." exit 2 fi @@ -39,11 +39,11 @@ if [ -d "$1" ]; then rm -rf "${pool}/${repositoryName}" # Delete the line in the authorized_keys file sed -i "/${repositoryName}/d" "${authorized_keys}" - echo "The folder "${pool}/${repositoryName}" and all its data have been deleted. The line associated in the authorized_keys file has been deleted." + echo -n "The folder "${pool}/${repositoryName}" and all its data have been deleted. The line associated in the authorized_keys file has been deleted." exit 3 else # Delete the line in the authorized_keys file sed -i "/${repositoryName}/d" "${authorized_keys}" - echo "The folder "${pool}/${repositoryName}" did not exist (repository never initialized or used). The line associated in the authorized_keys file has been deleted." + echo -n "The folder "${pool}/${repositoryName}" did not exist (repository never initialized or used). The line associated in the authorized_keys file has been deleted." exit 3 fi \ No newline at end of file diff --git a/helpers/shells/updateRepo.sh b/helpers/shells/updateRepo.sh index 9484dbe..6660037 100755 --- a/helpers/shells/updateRepo.sh +++ b/helpers/shells/updateRepo.sh @@ -17,7 +17,7 @@ fi # Check args if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then - echo "This shell takes 3 args: [repositoryName] [new SSH pub key] [quota]" + echo -n "This shell takes 3 args: [repositoryName] [new SSH pub key] [quota]" exit 1 fi @@ -26,7 +26,7 @@ fi pattern='(ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29t|ssh-rsa AAAAB3NzaC1yc2)[0-9A-Za-z+/]+[=]{0,3}(\s.*)?' if [[ ! "$2" =~ $pattern ]] then - echo "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)" + echo -n "Invalid public SSH KEY format. Provide a key in OpenSSH format (rsa, ed25519, ed25519-sk)" exit 2 fi @@ -34,13 +34,13 @@ fi # If we receive another length, there is necessarily a problem. repositoryName=$1 if [ ${#repositoryName} != 8 ]; then - echo "Error with the length of the repositoryName." + echo -n "Error with the length of the repositoryName." exit 3 fi # Check if a line in authorized_keys contains repository_name if ! grep -q "command=\".*${repositoryName}.*\",restrict" "$home/.ssh/authorized_keys"; then - echo "No line containing $repositoryName found in authorized_keys" + echo -n "No line containing $repositoryName found in authorized_keys" exit 4 fi @@ -64,7 +64,7 @@ while IFS= read -r line; do fi done < "$home/.ssh/authorized_keys" if [ "$found" = true ]; then - echo "The new SSH pub key $2 is already present in authorized_keys on a different line." + echo -n "The new SSH pub key $2 is already present in authorized_keys on a different line." exit 5 fi