added podman options

This commit is contained in:
= 2022-11-15 11:50:10 +01:00
parent c74abfbb99
commit 9e4da0f7f7

View File

@ -19,27 +19,32 @@ function create_container() {
if ! podman container exists {{ container }};then if ! podman container exists {{ container }};then
podman container create \ podman container create \
--name {{ container }} \ --name {{ container }} \
{%- if args['volumes'] is defined %} {%- if args['podman_options'] is defined %}
{%- for option, value in args['podman_options'].items() %}
--{{ option }} {{ value }} \
{%- endfor %}
{%- endif %}
{%- if args['volumes'] is defined %}
{%- for volume, mount in args['volumes'].items() %} {%- for volume, mount in args['volumes'].items() %}
-v {{ container }}-{{ volume }}:{{ mount }} \ -v {{ container }}-{{ volume }}:{{ mount }} \
{%- endfor %}
{%- endif %}
{%- if args['ports'] is defined %}
{%- for ports in args['ports'] %}
-p {{ ports['host'] }}:{{ ports['container'] }}{% if ports['protocol'] is defined %}/{{ ports['protocol'] }}{% endif %} \
{%- endfor %} {%- endfor %}
{%- endif %}
{%- if args['env'] is defined %}
{%- for key, value in args['env'].items() %}
-e {{ key }}={{ value }} \
{%- endfor %}
{%- endif %}
{%- if args['devices'] is defined %}
{%- for key, value in args['devices'].items() %}
--device {{ key }}:{{ value}} \
{%- endfor %}
{%- endif %} {%- endif %}
{{ args['image'] }}:{{ args['tag'] }} {%- if args['ports'] is defined %}
{%- for ports in args['ports'] %}
-p {{ ports['host'] }}:{{ ports['container'] }}{% if ports['protocol'] is defined %}/{{ ports['protocol'] }}{% endif %} \
{%- endfor %}
{%- endif %}
{%- if args['env'] is defined %}
{%- for key, value in args['env'].items() %}
-e {{ key }}={{ value }} \
{%- endfor %}
{%- endif %}
{%- if args['devices'] is defined %}
{%- for key, value in args['devices'].items() %}
--device {{ key }}:{{ value}} \
{%- endfor %}
{%- endif %}
{{ args['image'] }}:{{ args['tag'] }}
fi fi
} }
@ -52,10 +57,10 @@ function check_update() {
podman pull {{ args['image'] }}:{{ args['tag'] }} podman pull {{ args['image'] }}:{{ args['tag'] }}
if [[ "$(podman image inspect {{ args['image'] }}:{{ args['tag'] }} --format "{% raw %}{{.Id}}{% endraw %}")" == "$(podman inspect {{ container }} --format "{% raw %}{{ .Image }}{% endraw %}")" ]];then if [[ "$(podman image inspect {{ args['image'] }}:{{ args['tag'] }} --format "{% raw %}{{.Id}}{% endraw %}")" == "$(podman inspect {{ container }} --format "{% raw %}{{ .Image }}{% endraw %}")" ]];then
echo "No image updates available" echo "No image updates available"
return 0 return 0
else else
echo "Image update available" echo "Image update available"
return 1 return 1
fi fi
} }
@ -105,31 +110,31 @@ while :; do
create_container create_container
shift shift
;; ;;
-s|--start) -s|--start)
systemctl --user enable --now {{ container }}.service systemctl --user enable --now {{ container }}.service
shift shift
;; ;;
-S|--stop) -S|--stop)
systemctl --user stop {{ container }}.service systemctl --user stop {{ container }}.service
shift shift
;; ;;
-i|--is-running) -i|--is-running)
systemctl --user is-active {{ container }}.service systemctl --user is-active {{ container }}.service
exit $? exit $?
shift shift
;; ;;
-g|--generate-systemd) -g|--generate-systemd)
generate_systemd_unit_file generate_systemd_unit_file
shift shift
;; ;;
-u|--check-update) -u|--check-update)
check_update check_update
shift shift
;; ;;
--update) --update)
update update
shift shift
;; ;;
--) #End of all options --) #End of all options
shift shift
break break
@ -143,4 +148,3 @@ while :; do
esac esac
shift shift
done done