Smarter ./ynh-dev start that will attach to the container if it already exists

This commit is contained in:
Alexandre Aubin 2019-10-11 19:00:06 +02:00
parent b27bc5deea
commit 20dafd3827

View file

@ -134,7 +134,8 @@ function start_ynhdev()
local BOX=${1:-ynh-dev} local BOX=${1:-ynh-dev}
sudo lxc info $BOX &>/dev/null && critical "The container already exist. Use 'attach' to enter the LXC, or 'destroy' if you aim to recreate it." if ! sudo lxc info $BOX &>/dev/null
then
sudo lxc image info $BOX-base &>/dev/null || critical "You should first build the base YunoHost LXC using ./ynh-dev rebuild" sudo lxc image info $BOX-base &>/dev/null || critical "You should first build the base YunoHost LXC using ./ynh-dev rebuild"
set -eu set -eu
set -x set -x
@ -142,6 +143,10 @@ function start_ynhdev()
sudo lxc config set $BOX security.privileged true sudo lxc config set $BOX security.privileged true
sudo lxc config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$PWD" sudo lxc config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$PWD"
set +x set +x
info "Now attaching to the container"
else
info "Attaching to existing container"
fi
attach_ynhdev $BOX attach_ynhdev $BOX
} }