Add default values for SSH parameters in backup service functions
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
gyurix
2025-08-26 09:39:33 +02:00
parent 7125f17b22
commit 81dd98b952

View File

@@ -156,6 +156,20 @@ generate_backup_server_secrets () {
}' | jq -r . > $SECRET_DIR/backup/server/backup.json
}
defaulting_missing_paramaters() {
if [ "$SSH_PORT" == "" ] || [ "$SSH_PORT" == "null" ]; then
SSH_PORT="10022"
fi
if [ "$SSH_USER" == "" ] || [ "$SSH_USER" == "null" ]; then
SSH_USER="backup"
fi
if [ "$SSH_PASSWORD" == "" ] || [ "$SSH_PASSWORD" == "null" ]; then
SSH_PASSWORD="backup"
fi
}
create_backup_service () {
ADDITIONAL=""
@@ -236,11 +250,13 @@ backup_set_service() {
local BACKUP_VPN_CLIENTS="$8"
local VPN="$9"
local SSH_PORT="${10:-20022}"
local SSH_USER="${11:-"backup"}"
local SSH_PASSWORD="${12:-"backup"}"
local SSH_PORT="${10}"
local SSH_USER="${11}"
local SSH_PASSWORD="${12}"
local OPERATION="${13}"
defaulting_missing_paramaters
if [ "$OPERATION" == "DELETE" ]; then
sed -i '/service-backup/d' /etc/user/data/cron/crontab.txt
@@ -293,12 +309,14 @@ backup_set_client() {
local NAME="$1"
local SIZE="$2"
local VPN="$3"
local SSH_PORT="${4:-20022}"
local SSH_USER="${5:-"backup"}"
local SSH_PASSWORD="${6:-"backup"}"
local SSH_PORT="$4"
local SSH_USER="$5"
local SSH_PASSWORD="$6"
local OPERATION="$7"
local VPN_KEY="$8"
defaulting_missing_paramaters
if [ "$OPERATION" == "DELETE" ]; then
# delete service
if [ -f "/etc/user/config/services/service-backup-client-$NAME.json" ]; then