Browse Source

dry-run option for pdm-launch

master
Fernando Alegre 8 months ago
parent
commit
79e053cdb0
  1. 23
      .install/bin/pdm-launch

23
.install/bin/pdm-launch

@ -9,33 +9,36 @@ badarg() {
exit 2
}
help="Usage: $(basename $0) [-fch] [-l label] [-e options] image [container]
help="Usage: $(basename $0) [-fcdh] [-l label] [-e options] image [container]
Create and start a container from a local image, and assign it the given name.
If second argument is omitted, defaults to assigning the container the same name
as the image.
Options:
-f Force overwrite if a container with the given name already exists
-c Configure the container with deploy options stored in the image
metadata. By default, uses the metadata tag labeled 'config_default'
-l [label] Label from which to get the deploy options. Automatically sets -c
-d Dry-run
-e [options] Extra deploy options to assign to the container. If -e and -c are
both used, options from image metadata and command line are combined
-f Force overwrite if a container with the given name already exists
-l [label] Label from which to get the deploy options. Automatically sets -c
-h Display this help and exit"
# Handle options
opt_force=0
opt_dryrun=0
opt_config=0
opt_label='config_default'
opt_extras=''
while getopts ':fcl:e:h' arg; do
while getopts ':fcdl:e:h' arg; do
case $arg in
f) opt_force=1;;
c) opt_config=1;;
l) opt_config=1; opt_label="${OPTARG}";;
d) opt_dryrun=1;;
e) opt_extras="${OPTARG}";;
f) opt_force=1;;
h) echo "$help"; exit 0;;
l) opt_config=1; opt_label="${OPTARG}";;
:) badarg "Argument missing for option '-$OPTARG'";;
?) badarg "Invalid option '-$OPTARG'";;
esac
@ -76,5 +79,9 @@ if [[ $opt_force -eq 1 ]]; then
podman rm -i -f "$container"
fi
podman run -itd --name "$container" --hostname "$container" $deployconf "$image"
echo "Done!"
if [[ $opt_dryrun -eq 1 ]]; then
echo podman run -itd --name "$container" --hostname "$container" $deployconf "$image"
else
podman run -itd --name "$container" --hostname "$container" $deployconf "$image"
fi

Loading…
Cancel
Save