Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
podman_tools
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
conesphere
podman
tools
podman_tools
Merge requests
!11
debugged shellcheck comlpaints
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
debugged shellcheck comlpaints
patch-issue#26#27#28#30#31
into
master
Overview
0
Commits
2
Pipelines
2
Changes
2
Merged
Julian Steiner
requested to merge
patch-issue#26#27#28#30#31
into
master
3 years ago
Overview
0
Commits
2
Pipelines
2
Changes
2
Expand
0
0
Merge request reports
Compare
master
version 1
97db24b2
3 years ago
master (base)
and
latest version
latest version
75526909
2 commits,
3 years ago
version 1
97db24b2
1 commit,
3 years ago
2 files
+
214
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
tool/container-tool.sh
+
100
−
0
Options
@@ -125,6 +125,25 @@ cfg_get_file() {
done
}
cfg_get_vars
()
{
for
base
in
${
loc_sys_rev
}
"
${
loc_home
}
"
do
local
path
=
"
${
base
}
/default.vars"
if
[[
-e
"
${
path
}
"
]]
then
grep
-P
'^_\S+'
"
${
path
}
"
fi
done
for
base
in
${
loc_sys_rev
}
"
${
loc_home
}
"
do
local
path
=
"
${
base
}
/repo
${
sub_base
}
/pod.vars"
if
[[
-e
"
${
path
}
"
]]
then
grep
-P
'^_\S+'
"
${
path
}
"
fi
done
}
cfg_all
()
{
# the container conf itself
cfg_get_file
||
exit
$?
@@ -169,12 +188,33 @@ render_podman_cmdline() {
declare
-A
opt+
=([
${
key
#_
}
]=
"
${
val
}
"
)
continue
fi
# access any registered (_var value) variable via ${var} like
# _myvar myval
# option ${myvar}
if
[[
"
${
val
}
"
=
*
\$\{
*
\}
*
]]
then
optkeyArray
=
$(
echo
"
${
val
}
"
|
grep
-o
-P
'\$\{.*?\}'
)
for
optkey
in
$optkeyArray
do
optkey
=
${
optkey
:2:-1
}
optval
=
"
${
opt
[
${
optkey
}
]
}
"
filterstring
=
"s/
\$
{
${
optkey
}
}/
${
optval
}
/"
val
=
$(
echo
"
${
val
}
"
|
sed
"
${
filterstring
}
"
)
done
unset
optkeyArray optkey optval
fi
echo
-n
" --
${
key
}
${
val
}
"
done
echo
"
${
opt
[image]
}
${
opt
[cmd]
}
"
}
create_cntnr
()
{
[[
$d_flag
-eq
1
]]
&&
{
echo
"podman container create
$(
cfg_all | render_podman_cmdline
)
"
||
exit
$?
return
0
}
if
podman container exists
"
${
name
}
"
then
echo
"The container
${
name
}
already exists, cant create"
@@ -214,6 +254,66 @@ rm_cntnr() {
fi
}
#################################
# ARGUMENT HANDLING AND GLOBALS #
#################################
# filtering out options and setting flags before actual program runs, in
# in order to retain function of positional arguments
newArgString
=
""
for
((
iter
=
1
;
iter<
=
$#;
iter++
))
do
case
$(
eval echo
\$
"
$iter
"
)
in
-h
)
print_usage_and_exit
;;
-d
)
d_flag
=
1
continue
;;
*
)
newArgString
=
$newArgString
$(
eval echo
\$
"
$iter
"
)
" "
;;
esac
done
# shellcheck disable=SC2086
set
$newArgString
unset
newArgString
action
=
"
${
1
}
"
pod
=
"
${
3
}
"
# number of imaged to rotate
rotate_count
=
3
# home directory and system locations are separated as one could do spaces in $HOME
loc_home
=
"
${
HOME
}
/.local/share/containers/tool"
loc_sys
=
"/etc/containers/tool /var/lib/containers/tool"
# we need this one to produce reverse order of search directories for env files
loc_sys_rev
=
"/var/lib/containers/tool /etc/containers/tool"
# we add the pods name to the containers name as we might have another container
# with the same name running standalone
if
[[
-z
"
${
pod
}
"
]]
then
name
=
"
${
2
}
"
relative_name
=
"
${
2
}
"
# if we have a pod we add sub_base to
# our container search dir
sub_base
=
""
else
name
=
"
${
pod
}
_
${
2
}
"
relative_name
=
"
${
2
}
"
# we also want to have a shared pod socket dir
sub_base
=
"/
${
pod
}
.pod"
fi
#################
# MAIN PROGRAM #
#################
case
"
${
action
}
"
in
create
)
rm_cntnr
Loading