Compare commits

..

1 commit

Author SHA1 Message Date
5c53a90821 fix bug in ROOTPATH 2024-04-04 20:27:18 +02:00
3 changed files with 3 additions and 37 deletions

11
poddoc
View file

@ -3,7 +3,7 @@
# CONSTANTS
readonly PKGVER="0.1.0"
readonly LICENSE="GNU AGPLv3"
readonly ROOTPATH="$(dirname $(readlink -f $0))"
readonly ROOTPATH="$(dirname $(readlink -f $(which $0)))"
readonly CONFIG="/usr/local/noveria/etc/poddoc/poddoc.json"
for util in ${ROOTPATH}/utils/*; do
@ -24,7 +24,6 @@ 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}"
@ -42,8 +41,8 @@ the terms of the ${LICENSE}"
# SCRIPT START
##
OPT_SHORT="hVvnp:d:s:x:i:"
OPT_LONG="help,version,verbose,dryrun,noconfirm,pull:,delete:,start:,stop:,inspect:"
OPT_SHORT="hVvnp:s:x:i:"
OPT_LONG="help,version,verbose,dryrun,noconfirm,pull:,start:,stop:,inspect:"
TEMP=$(getopt -o ${OPT_SHORT} --long ${OPT_LONG} -n $(basename ${0}) -- "$@")
if [ "$?" != 0 ]; then
@ -76,10 +75,6 @@ while true; do
shift
pullpod "$1"
;;
-d|--delete)
shift
deletepod "$1"
;;
-s|--start)
shift
startpod "$1"

View file

@ -1,16 +0,0 @@
#!/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,19 +21,6 @@ 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}"