You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
520 B
27 lines
520 B
#!/usr/bin/env bash
|
|
|
|
# CONSTANTS
|
|
|
|
CONTAINER_NAME=$1
|
|
|
|
# FUNCTIONS
|
|
|
|
function usage {
|
|
echo "$(basename "$0") <CONTAINER_NAME>|--all"
|
|
}
|
|
|
|
function lookup {
|
|
if [[ $CONTAINER_NAME == "--all" ]]; then
|
|
pct-list
|
|
else
|
|
conf=$(grep -m1 -rl --include="*.conf" "^hostname: $CONTAINER_NAME$" /etc/pve/lxc/) && conf=${conf#/etc/pve/lxc/} && conf=${conf%.conf}
|
|
[[ -z $conf ]] && (echo >&2 "ERROR: container <$CONTAINER_NAME> not found!" && exit 10)
|
|
echo $conf
|
|
fi
|
|
}
|
|
|
|
# MAIN
|
|
|
|
set -Eue
|
|
[[ "$#" -lt 1 ]] && usage && exit 1
|
|
lookup
|