Browse Source

updated script descriptions

feature/startup-from-labels
root 5 years ago
parent
commit
5d064ae00b
  1. 13
      bin/pdm-build
  2. 39
      bin/pdm-launch

13
bin/pdm-build

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
################################################################################
# Functions/variables # Functions/variables
quit() { quit() {
if [[ $1 == 0 || $FLAGS_debug == $FLAGS_FALSE ]]; then if [[ $1 == 0 || $FLAGS_debug == $FLAGS_FALSE ]]; then
@ -16,12 +16,13 @@ source shflags
DEFINE_boolean 'squash' false 'squash newly built layers into a single new layer' 's' DEFINE_boolean 'squash' false 'squash newly built layers into a single new layer' 's'
DEFINE_boolean 'debug' false "Don't delete temporary container on build fail" 'd' DEFINE_boolean 'debug' false "Don't delete temporary container on build fail" 'd'
DEFINE_string 'tag' 'latest' 'Tag (other than date) to assign to the image' 't' DEFINE_string 'tag' 'latest' 'Tag (other than date) to assign to the image' 't'
FLAGS_HELP="Usage: $0 [-s] [-d] [-t tag] [directory] [name]
Builds an image from the Containerfile and (optionally) Systemdfile in a FLAGS_HELP="Usage: $0 [-sd] [-t tag] [directory] [name]
directory passed as the first argument, and names the image after the second
argument. If no first argument is given, the current working directory is Builds an image from the Containerfile and (optionally) Systemdfile in the
used. If no second argument is given, the image is named after the directory. specified directory, and tags the image with the given name. If no directory
argument is given, the current working directory is used. If no name argument
is given, the image is named after the directory.
" "
FLAGS "$@" || exit $? FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"

39
bin/pdm-launch

@ -1,28 +1,36 @@
#!/bin/bash #!/bin/bash
################################################################################
# Handle flags # Handle flags
source shflags source shflags
DEFINE_boolean 'overwrite' false 'Overwrite container if one with same name already exists.' 'o' DEFINE_boolean 'overwrite' false 'Overwrite container if one with same name already exists.' 'o'
DEFINE_boolean 'config' false "Automatically configure container with deploy options stored in image metadata." 'c' DEFINE_boolean 'config' false 'Automatically configure container with deploy options stored in image metadata.' 'c'
DEFINE_string 'deployopts' 'deployopts' 'Image metadata label from which to get the deploy options.' 'd' DEFINE_string 'label' 'deployopts' 'Image metadata label from which to get the deploy options.' 'l'
FLAGS_HELP="Usage: $0 [-o] [-d label] image [name]
FLAGS_HELP="Usage: $0 [-oc] [-d label] [image] [name]
Creates and starts a container from the specified image. If a second Creates and starts a container from the specified image, and assigns it the
argument is given, the container name is set to that string. Otherwise, the specified name. If no image argument is given, uses the current working
container is given the same name as the image. directory as the name of the image. If no name argument is given, the container
is given the same name as the image.
" "
FLAGS "$@" || exit $? FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
if [[ -n $1 ]]; then # Handle errors/arguments/cases
image=$1 if [[ $# -gt 2 ]]; then
else echo "Error: too many arguments"
echo "Error: need image name"
echo "" echo ""
flags_help flags_help
exit 1 exit 1
fi fi
if [[ -n $1 ]]; then
image=$1
else
echo "Warning: No image name given. Assuming image name from current working directory."
image=$(basename $(pwd))
fi
if [[ -n $2 ]]; then if [[ -n $2 ]]; then
name=$2 name=$2
else else
@ -30,10 +38,10 @@ else
fi fi
if [[ $FLAGS_config == $FLAGS_TRUE ]]; then if [[ $FLAGS_config == $FLAGS_TRUE ]]; then
echo "Getting deploy options from image metadata label \"$FLAGS_deployopts\" ..." echo "Getting deploy options from image metadata label \"$FLAGS_label\" ..."
deployopts=$(podman image inspect -f "{{ .Config.Labels.${FLAGS_deployopts} }}" $image) deployopts=$(podman image inspect -f "{{ .Config.Labels.${FLAGS_label} }}" $image)
if [[ $deployopts == "<no value>" ]]; then if [[ $deployopts == "<no value>" ]]; then
echo "Error: image metadata label \"$FLAGS_deployopts\" is empty or nonexistent." echo "Error: image metadata label \"$FLAGS_label\" is empty or nonexistent."
exit 2 exit 2
fi fi
else else
@ -44,6 +52,5 @@ if [[ $FLAGS_overwrite ]]; then
podman rm -i -f $name podman rm -i -f $name
fi fi
podman create --name $name $deployopts $image podman run -itd --name $name --hostname $name $deployopts $image
podman start $name
echo "Done!" echo "Done!"

Loading…
Cancel
Save