Add support for buster dev LXCs

This commit is contained in:
Alexandre Aubin 2020-02-08 03:29:51 +01:00
parent 3bdb65cd87
commit 913003acb3

36
ynh-dev
View file

@ -6,9 +6,9 @@ function show_usage() {
${BLUE}On the host, to manage the LXC${NORMAL}
${BLUE}==============================${NORMAL}
start [NAME] (Create and) starts a LXC (ynh-dev by default)
attach [NAME] Attach an already started LXC (ynh-dev by default)
destroy [NAME] Destroy the ynh-dev LXC (ynh-dev by default)
start [DIST] (Create and) starts a LXC (stretch by default)
attach [DIST] Attach an already started LXC (stretch by default)
destroy [DIST] Destroy the ynh-dev LXC (stretch by default)
rebuild Rebuild a fresh, up-to-date box
${BLUE}Inside the dev instance${NORMAL}
@ -132,7 +132,8 @@ function start_ynhdev()
{
check_lxd_setup
local BOX=${1:-ynh-dev}
local DIST=${1:-stretch}
local BOX=ynh-dev-$DIST
if ! sudo lxc info $BOX &>/dev/null
then
@ -141,6 +142,10 @@ function start_ynhdev()
set -x
sudo lxc launch $BOX-base $BOX
sudo lxc config set $BOX security.privileged true
if [[ "$DIST" == "buster" ]]
then
sudo lxc config set $BOX-rebuild security.nesting true # Need this for buster because it is using apparmor
fi
sudo lxc config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$PWD"
set +x
info "Now attaching to the container"
@ -148,7 +153,7 @@ function start_ynhdev()
info "Attaching to existing container"
fi
attach_ynhdev $BOX
attach_ynhdev $DIST
}
function attach_ynhdev()
@ -166,7 +171,7 @@ function attach_ynhdev()
fi
check_lxd_setup
local BOX=${1:-ynh-dev}
local BOX=ynh-dev-${1:-stretch}
sudo lxc start $BOX 2>/dev/null || true
sudo lxc exec $BOX --cwd /ynh-dev -- /bin/bash
}
@ -174,7 +179,7 @@ function attach_ynhdev()
function destroy_ynhdev()
{
check_lxd_setup
local BOX=${1:-ynh-dev}
local BOX=ynh-dev-${1:-stretch}
sudo lxc stop $BOX
sudo lxc delete $BOX
}
@ -183,15 +188,26 @@ function rebuild_ynhdev()
{
check_lxd_setup
local BOX=${1:-ynh-dev}
local DIST=${1:-stretch}
local BOX=ynh-dev-${DIST}
set -x
sudo lxc info $BOX-rebuild >/dev/null && sudo lxc delete $BOX-rebuild --force
sudo lxc launch images:debian/stretch/amd64 $BOX-rebuild
sudo lxc launch images:debian/$DIST/amd64 $BOX-rebuild
sudo lxc config set $BOX-rebuild security.privileged true
if [[ "$DIST" == "buster" ]]
then
sudo lxc config set $BOX-rebuild security.nesting true # Need this for buster because it is using apparmor
fi
sudo lxc restart $BOX-rebuild
sudo lxc exec $BOX-rebuild -- apt install curl -y
sudo lxc exec $BOX-rebuild -- /bin/bash -c "curl https://install.yunohost.org | bash -s -- -a -d unstable"
if [[ "$DIST" == "buster" ]]
then
INSTALL_SCRIPT="https://raw.githubusercontent.com/YunoHost/install_script/buster-unstable/install_yunohost"
else
INSTALL_SCRIPT="https://install.yunohost.org"
fi
sudo lxc exec $BOX-rebuild -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d unstable"
sudo lxc stop $BOX-rebuild
sudo lxc publish $BOX-rebuild --alias $BOX-base
set +x