Compare commits
6 commits
main
...
serviceip_
Author | SHA1 | Date | |
---|---|---|---|
0446e1eae1 | |||
aa3b81913d | |||
d4190b4144 | |||
13d3e412a2 | |||
1b33823464 | |||
e11b0b7ba2 |
3 changed files with 36 additions and 2 deletions
9
poddoc
9
poddoc
|
@ -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
16
utils/delete
Normal 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
|
||||
}
|
13
utils/pull
13
utils/pull
|
@ -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}"
|
||||
|
|
Loading…
Reference in a new issue