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

21
ynh-dev
View file

@ -134,14 +134,19 @@ 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
sudo lxc image info $BOX-base &>/dev/null || critical "You should first build the base YunoHost LXC using ./ynh-dev rebuild" then
set -eu sudo lxc image info $BOX-base &>/dev/null || critical "You should first build the base YunoHost LXC using ./ynh-dev rebuild"
set -x set -eu
sudo lxc launch $BOX-base $BOX set -x
sudo lxc config set $BOX security.privileged true sudo lxc launch $BOX-base $BOX
sudo lxc config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$PWD" sudo lxc config set $BOX security.privileged true
set +x sudo lxc config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$PWD"
set +x
info "Now attaching to the container"
else
info "Attaching to existing container"
fi
attach_ynhdev $BOX attach_ynhdev $BOX
} }