2021-01-27 00:35:18 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
function get_arch()
|
|
|
|
{
|
|
|
|
local architecture
|
|
|
|
if uname -m | grep -q "arm64" || uname -m | grep -q "aarch64"; then
|
|
|
|
architecture="aarch64"
|
|
|
|
elif uname -m | grep -q "64"; then
|
|
|
|
architecture="amd64"
|
|
|
|
elif uname -m | grep -q "86"; then
|
|
|
|
architecture="i386"
|
|
|
|
elif uname -m | grep -q "arm"; then
|
|
|
|
architecture="armhf"
|
|
|
|
else
|
|
|
|
architecture="unknown"
|
|
|
|
fi
|
|
|
|
echo $architecture
|
|
|
|
}
|
|
|
|
|
2021-02-03 16:48:22 +01:00
|
|
|
function rotate_image()
|
|
|
|
{
|
|
|
|
local instance_to_publish=$1
|
|
|
|
local alias_image=$2
|
|
|
|
|
|
|
|
# Save the finger print to delete the old image later
|
|
|
|
local finger_print_to_delete=$(lxc image info "$alias_image" | grep Fingerprint | awk '{print $2}')
|
|
|
|
local should_restart=0
|
|
|
|
|
|
|
|
# If the container is running, stop it
|
|
|
|
if [ "$(lxc info $instance_to_publish | grep Status | awk '{print $2}')" = "Running" ]
|
|
|
|
then
|
|
|
|
should_restart=1
|
|
|
|
lxc stop "$instance_to_publish"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create image before install
|
|
|
|
lxc publish "$instance_to_publish" --alias "$alias_image" --public "${@:3}"
|
|
|
|
# Remove old image
|
|
|
|
lxc image delete "$finger_print_to_delete"
|
|
|
|
|
|
|
|
if [ $should_restart = 1 ]
|
|
|
|
then
|
|
|
|
lxc start "$instance_to_publish"
|
|
|
|
sleep 5
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-01-27 00:35:18 +01:00
|
|
|
function rebuild_base_lxc()
|
|
|
|
{
|
|
|
|
local YNH_BRANCH=${1:-stable}
|
|
|
|
local DIST=${2:-buster}
|
|
|
|
local ARCH=${3:-amd64}
|
|
|
|
local img_name=$YNH_BRANCH-$DIST-$ARCH
|
|
|
|
|
|
|
|
set -x
|
|
|
|
lxc info $img_name >/dev/null && lxc delete $img_name --force
|
|
|
|
|
|
|
|
if [ $(get_arch) = $ARCH ];
|
|
|
|
then
|
|
|
|
lxc launch images:debian/$DIST/$ARCH $img_name -c security.privileged=true -c security.nesting=true
|
|
|
|
else
|
|
|
|
lxc image info $img_name >/dev/null && lxc image delete $img_name
|
|
|
|
|
|
|
|
tmp_dir=$(mktemp -d)
|
|
|
|
pushd $tmp_dir
|
|
|
|
|
|
|
|
lxc image export images:debian/$DIST/$ARCH
|
|
|
|
|
|
|
|
tar xJf lxd.tar.xz
|
|
|
|
local current_arch=$(get_arch)
|
|
|
|
sed -i "0,/architecture: $ARCH/s//architecture: $current_arch/" metadata.yaml
|
|
|
|
tar cJf lxd.tar.xz metadata.yaml templates
|
|
|
|
lxc image import lxd.tar.xz rootfs.squashfs --alias $img_name
|
|
|
|
popd
|
|
|
|
rm -rf "$tmp_dir"
|
|
|
|
|
|
|
|
lxc launch $img_name $img_name -c security.privileged=true -c security.nesting=true
|
|
|
|
fi
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
IN_LXC="lxc exec $img_name --"
|
|
|
|
|
2022-01-20 17:50:00 +01:00
|
|
|
local INSTALL_SCRIPT="https://install.yunohost.org/$DIST"
|
|
|
|
|
2021-01-27 00:35:18 +01:00
|
|
|
$IN_LXC apt install curl -y
|
|
|
|
$IN_LXC /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $YNH_BRANCH"
|
|
|
|
|
|
|
|
$IN_LXC systemctl -q stop apt-daily.timer
|
|
|
|
$IN_LXC systemctl -q stop apt-daily-upgrade.timer
|
|
|
|
$IN_LXC systemctl -q stop apt-daily.service
|
|
|
|
$IN_LXC systemctl -q stop apt-daily-upgrade.service
|
|
|
|
$IN_LXC systemctl -q disable apt-daily.timer
|
|
|
|
$IN_LXC systemctl -q disable apt-daily-upgrade.timer
|
|
|
|
$IN_LXC systemctl -q disable apt-daily.service
|
|
|
|
$IN_LXC systemctl -q disable apt-daily-upgrade.service
|
|
|
|
$IN_LXC rm -f /etc/cron.daily/apt-compat
|
|
|
|
$IN_LXC cp /bin/true /usr/lib/apt/apt.systemd.daily
|
|
|
|
|
|
|
|
# Publish ynh-dev image
|
|
|
|
local LXC_BASE="ynh-dev-$DIST-$ARCH-$YNH_BRANCH-base"
|
2021-02-03 16:48:22 +01:00
|
|
|
rotate_image $img_name $LXC_BASE "os=YunoHost" "ynh-release=$YNH_BRANCH" "stage=ynh-dev" "release=${DIST^}" "architecture=$ARCH" "description=YunoHost $DIST $YNH_BRANCH ynh-dev $ARCH ($(date '+%Y%m%d'))"
|
2021-01-27 00:35:18 +01:00
|
|
|
|
|
|
|
local YUNO_PWD="admin"
|
|
|
|
local DOMAIN="domain.tld"
|
|
|
|
local SUBDOMAIN="sub.$DOMAIN"
|
|
|
|
local TEST_USER="package_checker"
|
|
|
|
|
|
|
|
# Disable password strength check
|
|
|
|
$IN_LXC yunohost tools postinstall --domain $DOMAIN --password $YUNO_PWD --force-password
|
|
|
|
|
|
|
|
$IN_LXC yunohost settings set security.password.admin.strength -v -1
|
|
|
|
$IN_LXC yunohost settings set security.password.user.strength -v -1
|
|
|
|
|
|
|
|
$IN_LXC yunohost domain add $SUBDOMAIN
|
|
|
|
TEST_USER_DISPLAY=${TEST_USER//"_"/""}
|
2021-02-03 16:48:22 +01:00
|
|
|
$IN_LXC yunohost user create $TEST_USER --firstname $TEST_USER_DISPLAY --lastname $TEST_USER_DISPLAY --domain $DOMAIN --password "$YUNO_PWD"
|
2021-01-27 00:35:18 +01:00
|
|
|
|
2021-02-03 16:48:22 +01:00
|
|
|
$IN_LXC "yunohost --version"
|
2021-01-27 00:35:18 +01:00
|
|
|
|
|
|
|
LXC_BASE="ynh-appci-$DIST-$ARCH-$YNH_BRANCH-base"
|
|
|
|
lxc stop $img_name
|
2021-02-03 16:48:22 +01:00
|
|
|
rotate_image $img_name $LXC_BASE "os=YunoHost" "ynh-release=$YNH_BRANCH" "stage=ynh-appci" "release=${DIST^}" "architecture=$ARCH" "description=YunoHost $DIST $YNH_BRANCH ynh-appci $ARCH ($(date '+%Y%m%d'))"
|
2021-01-27 00:35:18 +01:00
|
|
|
lxc delete $img_name
|
|
|
|
set +x
|
|
|
|
}
|
|
|
|
|
|
|
|
function from_stable_to_another_version()
|
|
|
|
{
|
|
|
|
local YNH_BRANCH=${1:-testing}
|
|
|
|
local DIST=${2:-buster}
|
|
|
|
local ARCH=${3:-amd64}
|
|
|
|
local OLD_LXC_BASE="ynh-dev-$DIST-$ARCH-stable-base"
|
|
|
|
local NEW_LXC_BASE="ynh-dev-$DIST-$ARCH-$YNH_BRANCH-base"
|
|
|
|
|
|
|
|
if [ "$YNH_BRANCH" == "testing" ]; then
|
|
|
|
source="testing"
|
|
|
|
else
|
|
|
|
source="testing unstable"
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
|
|
|
IN_LXC="lxc exec $NEW_LXC_BASE --"
|
|
|
|
|
|
|
|
lxc launch $OLD_LXC_BASE $NEW_LXC_BASE -c security.privileged=true -c security.nesting=true
|
|
|
|
sleep 5
|
|
|
|
|
2021-06-17 15:18:24 +02:00
|
|
|
$IN_LXC /bin/bash -c "echo deb http://forge.yunohost.org/debian/ $DIST stable $source > /etc/apt/sources.list.d/yunohost.list"
|
2021-01-27 00:35:18 +01:00
|
|
|
$IN_LXC /bin/bash -c "apt-get update"
|
|
|
|
$IN_LXC /bin/bash -c "apt-get dist-upgrade -y"
|
|
|
|
|
|
|
|
lxc stop $NEW_LXC_BASE
|
2021-02-03 17:15:58 +01:00
|
|
|
rotate_image $NEW_LXC_BASE $NEW_LXC_BASE "os=YunoHost" "ynh-release=$YNH_BRANCH" "stage=ynh-dev" "release=${DIST^}" "architecture=$ARCH" "description=YunoHost $DIST $YNH_BRANCH ynh-dev $ARCH ($(date '+%Y%m%d'))"
|
2021-01-27 00:35:18 +01:00
|
|
|
lxc delete $NEW_LXC_BASE
|
|
|
|
|
|
|
|
OLD_LXC_BASE="ynh-appci-$DIST-$ARCH-stable-base"
|
|
|
|
NEW_LXC_BASE="ynh-appci-$DIST-$ARCH-$YNH_BRANCH-base"
|
|
|
|
IN_LXC="lxc exec $NEW_LXC_BASE --"
|
|
|
|
|
|
|
|
lxc launch $OLD_LXC_BASE $NEW_LXC_BASE -c security.privileged=true -c security.nesting=true
|
|
|
|
sleep 5
|
|
|
|
|
2021-06-17 15:18:24 +02:00
|
|
|
$IN_LXC /bin/bash -c "echo deb http://forge.yunohost.org/debian/ $DIST stable $source > /etc/apt/sources.list.d/yunohost.list"
|
2021-01-27 00:35:18 +01:00
|
|
|
$IN_LXC /bin/bash -c "apt-get update"
|
|
|
|
$IN_LXC /bin/bash -c "apt-get dist-upgrade -y"
|
|
|
|
|
|
|
|
lxc stop $NEW_LXC_BASE
|
2021-02-03 17:15:58 +01:00
|
|
|
rotate_image $NEW_LXC_BASE $NEW_LXC_BASE "os=YunoHost" "ynh-release=$YNH_BRANCH" "stage=ynh-appci" "release=${DIST^}" "architecture=$ARCH" "description=YunoHost $DIST $YNH_BRANCH ynh-appci $ARCH ($(date '+%Y%m%d'))"
|
2021-01-27 00:35:18 +01:00
|
|
|
lxc delete $NEW_LXC_BASE
|
|
|
|
set +x
|
|
|
|
}
|
|
|
|
|
2021-06-17 15:18:24 +02:00
|
|
|
for DIST in "buster" # Add new debian version here
|
2021-01-27 00:35:18 +01:00
|
|
|
do
|
2021-06-17 15:39:09 +02:00
|
|
|
for ARCH in "$(get_arch)"
|
2021-01-27 00:35:18 +01:00
|
|
|
do
|
2021-06-17 15:39:09 +02:00
|
|
|
rebuild_base_lxc "stable" $DIST $ARCH
|
|
|
|
|
|
|
|
for YNH_BRANCH in "testing" "unstable"
|
2021-01-27 00:35:18 +01:00
|
|
|
do
|
2021-06-17 15:39:09 +02:00
|
|
|
from_stable_to_another_version $YNH_BRANCH $DIST $ARCH
|
2021-01-27 00:35:18 +01:00
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
2021-06-17 15:18:24 +02:00
|
|
|
|
|
|
|
for DIST in "bullseye" # Add new debian version here
|
|
|
|
do
|
2021-06-17 15:39:09 +02:00
|
|
|
for ARCH in "$(get_arch)"
|
2021-06-17 15:18:24 +02:00
|
|
|
do
|
2022-05-18 03:31:34 +02:00
|
|
|
rebuild_base_lxc "stable" $DIST $ARCH
|
|
|
|
|
|
|
|
for YNH_BRANCH in "testing" "unstable"
|
|
|
|
do
|
|
|
|
from_stable_to_another_version $YNH_BRANCH $DIST $ARCH
|
|
|
|
done
|
2021-06-17 15:18:24 +02:00
|
|
|
done
|
|
|
|
done
|