Compare commits

...

6 commits

Author SHA1 Message Date
0446e1eae1 wip 2024-03-01 13:55:47 +01:00
aa3b81913d wip 2024-03-01 13:53:14 +01:00
d4190b4144 wip 2024-03-01 13:37:09 +01:00
13d3e412a2 wip 2024-03-01 13:35:20 +01:00
1b33823464 wip 2024-03-01 13:33:42 +01:00
e11b0b7ba2 Add dynamic serviceIP lookup 2024-03-01 13:29:06 +01:00
3 changed files with 36 additions and 2 deletions

9
poddoc
View file

@ -24,6 +24,7 @@ operations:
$(basename ${0}) {-n --dryrun}
$(basename ${0}) {--noconfirm}
$(basename ${0}) {-p --pull}
$(basename ${0}) {-d --delete}
$(basename ${0}) {-i --inspect}
$(basename ${0}) {-s --start}
$(basename ${0}) {-x --stop}"
@ -41,8 +42,8 @@ the terms of the ${LICENSE}"
# SCRIPT START
##
OPT_SHORT="hVvnp:s:x:i:"
OPT_LONG="help,version,verbose,dryrun,noconfirm,pull:,start:,stop:,inspect:"
OPT_SHORT="hVvnp:d:s:x:i:"
OPT_LONG="help,version,verbose,dryrun,noconfirm,pull:,delete:,start:,stop:,inspect:"
TEMP=$(getopt -o ${OPT_SHORT} --long ${OPT_LONG} -n $(basename ${0}) -- "$@")
if [ "$?" != 0 ]; then
@ -75,6 +76,10 @@ while true; do
shift
pullpod "$1"
;;
-d|--delete)
shift
deletepod "$1"
;;
-s|--start)
shift
startpod "$1"

16
utils/delete Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
##
# description: deletes the specified docker-compose.yml from local storage
# usage: deletepod <pod-name>
##
function deletepod() {
if [[ ! -d "$(getValueByKey 'PODMAN_DIRECTORY')/${1}" ]]; then
log e "$1 does not exist on local storage"
exit 1
fi
rm -rf "$(getValueByKey 'PODMAN_DIRECTORY')/${1}"
log s "${1} deleted"
exit 0
}

View file

@ -21,6 +21,19 @@ function pullpod() {
done
fi
if [[ $(getLocalConfValue "$(getValueByKey 'PODMAN_DIRECTORY')/${1}" 'container.hasServiceIPs') == true ]]; then
local section=$(sed ''"$(cat $(getValueByKey 'PODMAN_DIRECTORY')/${1}/docker-compose.yml | nl -ba | grep "%% $(getLocalConfValue $(getValueByKey 'PODMAN_DIRECTORY')/${1} 'container.name') start %%" | awk '{print $1}')"','"$(cat $(getValueByKey 'PODMAN_DIRECTORY')/${1}/docker-compose.yml | nl -ba | grep "%% $(getLocalConfValue $(getValueByKey 'PODMAN_DIRECTORY')/${1} 'container.name') end %%" | awk '{print $1}')"'!d' "$(getValueByKey 'PODMAN_DIRECTORY')/${1}/docker-compose.yml")
local hasPorts=$(echo "$section" | grep "ports")
if [[ -z "$hasPorts" ]]; then
sed -i "/^$(echo "$section" | tail -n1)/i\ \ \ \ ports:" "$(getValueByKey 'PODMAN_DIRECTORY')/${1}/docker-compose.yml"
fi
for serviceIP in $(getLocalConfValue "$(getValueByKey 'PODMAN_DIRECTORY')/${1}" 'container.serviceIPs[]'); do
if [[ -z $(echo "$section" | grep "$serviceIP") ]]; then
sed -i "/^$(echo "$section" | tail -n1)/i\ \ \ \ \ \ - $serviceIP" "$(getValueByKey 'PODMAN_DIRECTORY')/${1}/docker-compose.yml"
fi
done
fi
exit 0
fi
cd "$(getValueByKey 'PODMAN_DIRECTORY')/${1}"