Skip to content
Snippets Groups Projects
Commit 19c7cd2f authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'limit-backup-count' into 'master'

fix shellcheck; fix returncode of ssh command

See merge request !40
parents 7b4e92ba 664a39b0
Branches
No related tags found
1 merge request!40fix shellcheck; fix returncode of ssh command
......@@ -8,6 +8,7 @@
# ah - Axel Hahn <axel.hahn@iml.unibe.ch>
#
# 2021-05-31 ah v1.0 first lines
# 2022-02-11 ah v1.1 fix shellcheck; fix returncode of ssh command
# ================================================================================
# --------------------------------------------------------------------------------
......@@ -19,33 +20,36 @@
# param string action; one of register|unregrister|status
# param string hostname; given for register and unregister
function _runssh(){
sProtocol=`j_getFullTarget "" | cut -f 1 -d ":"`
if [ ${sProtocol} = "rsync" -o ${sProtocol} = "scp" -o ${sProtocol} = "sftp" ]; then
local _rc=0
sProtocol=$(j_getFullTarget "" | cut -f 1 -d ":")
if [ "${sProtocol}" = "rsync" -o "${sProtocol}" = "scp" -o "${sProtocol}" = "sftp" ]; then
sSshTarget=`j_getFullTarget "" | cut -f 3 -d "/"`
if [ ! -z $sSshTarget ]; then
sSshTarget=$(j_getFullTarget "" | cut -f 3 -d "/")
if [ -n "$sSshTarget" ]; then
sSshParams=
sFileSshPrivkey=`_j_getvar ${STORAGEFILE} "ssh-privatekey"`
if [ ! -z $sFileSshPrivkey ]; then
sFileSshPrivkey=$(_j_getvar ${STORAGEFILE} "ssh-privatekey")
if [ -n "$sFileSshPrivkey" ]; then
sSshParams="${sSshParams} -i ${sFileSshPrivkey}"
fi
sSshCmd=`_j_getvar ${STORAGEFILE} "storage-registercmd"`
sSshCmd=$(_j_getvar "${STORAGEFILE}" "storage-registercmd")
if [ -z "$sSshCmd" ]; then
echo "WARNING: Missing storage-registercmd = ... in ${STORAGEFILE} for a command to execute via SSH."
_rc=1
else
echo ssh ${sSshParams} ${sSshTarget} ${sSshCmd} $*
echo "ssh ${sSshParams} ${sSshTarget} ${sSshCmd} $*"
color cmd
ssh ${sSshParams} ${sSshTarget} ${sSshCmd} $*
_rc=$?
color reset
fi
fi
else
echo INFO: storage protocol is $sProtocol - skipping register via ssh.
echo "INFO: storage protocol is $sProtocol - skipping register via ssh."
fi
return $_rc
}
# --------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment