Browse Source

Added funcionality to read path to containers from file

master
Josef Eberle 3 months ago
parent
commit
d568a8bea5
1 changed files with 3 additions and 5 deletions
  1. +3
    -5
      lxc-staticnet

+ 3
- 5
lxc-staticnet View File

@@ -222,15 +222,13 @@ fi
# Set up path
if [ -z "${path:-}" ]; then
if [[ $EUID -eq 0 ]] && grep -q "lxc.lxcpath" /etc/lxc/lxc.conf; then
# TODO read path from config
path=/srv/lxc/priv
path="$(cat /etc/lxc/lxc.conf | grep lxc.lxcpath | sed -e 's/=/ /g' | awk '{print $2}')"
else
path=/var/lib/lxc
fi

if [[ $EUID -ne 0 ]] && grep -q "lxc.lxcpath" ~/.config/lxc/lxc.conf; then
# TODO read path from config
path=/srv/lxc/upriv
path="$(cat ~/.config/lxc/lxc.conf | grep lxc.lxcpath | sed -e 's/=/ /g' | awk '{print $2}')"
else
path=~/.local/share/lxc
fi
@@ -258,7 +256,7 @@ elif ([ -z "${address:-}" ] || [ -z "${netmask:-}" ] || [ -z "${gateway:-}" ]) &
printUsage
fi

if [[ ! $(lxc-ls -P "$path") =~ "$name" ]]; then
if [ "$job" != "overview" ] && [[ ! $(lxc-ls -P "$path") =~ "$name" ]]; then
echo "You need to provide a valid container name"
echo
printUsage

Loading…
Cancel
Save