Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iml-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
iml-backup
Commits
664a39b0
Commit
664a39b0
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix shellcheck; fix returncode of ssh command
parent
7b4e92ba
No related branches found
No related tags found
1 merge request
!40
fix shellcheck; fix returncode of ssh command
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/register/ssh.sh
+14
-10
14 additions, 10 deletions
plugins/register/ssh.sh
with
14 additions
and
10 deletions
plugins/register/ssh.sh
+
14
−
10
View file @
664a39b0
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
# ah - Axel Hahn <axel.hahn@iml.unibe.ch>
# ah - Axel Hahn <axel.hahn@iml.unibe.ch>
#
#
# 2021-05-31 ah v1.0 first lines
# 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 @@
...
@@ -19,33 +20,36 @@
# param string action; one of register|unregrister|status
# param string action; one of register|unregrister|status
# param string hostname; given for register and unregister
# param string hostname; given for register and unregister
function
_runssh
(){
function
_runssh
(){
local
_rc
=
0
sProtocol
=
`
j_getFullTarget
""
|
cut
-f
1
-d
":"
`
sProtocol
=
$(
j_getFullTarget
""
|
cut
-f
1
-d
":"
)
if
[
${
sProtocol
}
=
"rsync"
-o
${
sProtocol
}
=
"scp"
-o
${
sProtocol
}
=
"sftp"
]
;
then
if
[
"
${
sProtocol
}
"
=
"rsync"
-o
"
${
sProtocol
}
"
=
"scp"
-o
"
${
sProtocol
}
"
=
"sftp"
]
;
then
sSshTarget
=
`
j_getFullTarget
""
|
cut
-f
3
-d
"/"
`
sSshTarget
=
$(
j_getFullTarget
""
|
cut
-f
3
-d
"/"
)
if
[
!
-z
$sSshTarget
]
;
then
if
[
-n
"
$sSshTarget
"
]
;
then
sSshParams
=
sSshParams
=
sFileSshPrivkey
=
`
_j_getvar
${
STORAGEFILE
}
"ssh-privatekey"
`
sFileSshPrivkey
=
$(
_j_getvar
${
STORAGEFILE
}
"ssh-privatekey"
)
if
[
!
-z
$sFileSshPrivkey
]
;
then
if
[
-n
"
$sFileSshPrivkey
"
]
;
then
sSshParams
=
"
${
sSshParams
}
-i
${
sFileSshPrivkey
}
"
sSshParams
=
"
${
sSshParams
}
-i
${
sFileSshPrivkey
}
"
fi
fi
sSshCmd
=
`
_j_getvar
${
STORAGEFILE
}
"storage-registercmd"
`
sSshCmd
=
$(
_j_getvar
"
${
STORAGEFILE
}
"
"storage-registercmd"
)
if
[
-z
"
$sSshCmd
"
]
;
then
if
[
-z
"
$sSshCmd
"
]
;
then
echo
"WARNING: Missing storage-registercmd = ... in
${
STORAGEFILE
}
for a command to execute via SSH."
echo
"WARNING: Missing storage-registercmd = ... in
${
STORAGEFILE
}
for a command to execute via SSH."
_rc
=
1
else
else
echo
ssh
${
sSshParams
}
${
sSshTarget
}
${
sSshCmd
}
$*
echo
"
ssh
${
sSshParams
}
${
sSshTarget
}
${
sSshCmd
}
$*
"
color cmd
color cmd
ssh
${
sSshParams
}
${
sSshTarget
}
${
sSshCmd
}
$*
ssh
${
sSshParams
}
${
sSshTarget
}
${
sSshCmd
}
$*
_rc
=
$?
color reset
color reset
fi
fi
fi
fi
else
else
echo
INFO: storage protocol is
$sProtocol
- skipping register via ssh.
echo
"
INFO: storage protocol is
$sProtocol
- skipping register via ssh.
"
fi
fi
return
$_rc
}
}
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment