yunohost-ci/prepare.sh

42 lines
1.2 KiB
Bash
Raw Normal View History

2019-11-25 13:11:18 +01:00
#!/usr/bin/env bash
2020-03-26 17:50:12 +01:00
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2020-05-26 19:32:46 +02:00
source $current_dir/prints.sh
2020-03-26 17:50:12 +01:00
source $current_dir/utils.sh # Get utils functions.
2019-11-25 13:11:18 +01:00
set -eo pipefail
# trap any error, and mark it as a system failure.
trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
start_container () {
2019-11-26 14:15:34 +01:00
if lxc info "$CONTAINER_ID" >/dev/null 2>/dev/null ; then
2020-05-26 19:24:01 +02:00
warn 'Found old container, deleting'
2019-11-26 14:15:34 +01:00
lxc delete -f "$CONTAINER_ID"
fi
2019-11-26 14:01:29 +01:00
2020-03-26 17:50:12 +01:00
if ! lxc image info "$BASE_IMAGE-$SNAPSHOT_NAME" &>/dev/null
2019-11-25 13:11:18 +01:00
then
2020-05-26 19:24:01 +02:00
error "$BASE_IMAGE not found, please rebuild with rebuild_all.sh"
2020-03-26 17:50:12 +01:00
# Inform GitLab Runner that this is a system failure, so it
# should be retried.
exit $SYSTEM_FAILURE_EXIT_CODE
2019-11-25 13:11:18 +01:00
fi
2020-03-19 23:52:39 +01:00
2021-03-10 10:43:18 +01:00
info "Debian version: $DEBIAN_VERSION, YunoHost version: $CURRENT_VERSION, Image used: $BASE_IMAGE-$SNAPSHOT_NAME"
2021-03-10 10:43:02 +01:00
lxc launch "$BASE_IMAGE-$SNAPSHOT_NAME" "$CONTAINER_ID" -c security.nesting=true 2>/dev/null
2020-03-19 23:52:39 +01:00
2020-03-26 17:50:12 +01:00
mkdir -p $current_dir/cache
chmod 777 $current_dir/cache
lxc config device add "$CONTAINER_ID" cache-folder disk path=/cache source="$current_dir/cache"
2019-12-23 11:36:31 +01:00
2019-11-26 15:43:38 +01:00
wait_container $CONTAINER_ID
2019-11-25 13:11:18 +01:00
}
2020-05-26 19:36:55 +02:00
info "Starting $CONTAINER_ID"
2019-11-25 13:11:18 +01:00
start_container
2020-05-26 19:36:55 +02:00
info "$CONTAINER_ID started properly"