mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
LOAD_LXC_SNAPSHOT to ynh_lxc_snapshot_load
This commit is contained in:
parent
efb7367e2e
commit
0a0ef64ed6
3 changed files with 21 additions and 21 deletions
14
lib/tests.sh
14
lib/tests.sh
|
@ -129,14 +129,14 @@ _LOAD_SNAPSHOT_OR_INSTALL_APP () {
|
||||||
if ! ynh_lxc_snapshot_exists $snapname
|
if ! ynh_lxc_snapshot_exists $snapname
|
||||||
then
|
then
|
||||||
log_warning "Expected to find an existing snapshot $snapname but it doesn't exist yet .. will attempt to create it"
|
log_warning "Expected to find an existing snapshot $snapname but it doesn't exist yet .. will attempt to create it"
|
||||||
LOAD_LXC_SNAPSHOT snap0 \
|
ynh_lxc_snapshot_load snap0 \
|
||||||
&& _PREINSTALL \
|
&& _PREINSTALL \
|
||||||
&& _INSTALL_APP "path=$check_path" \
|
&& _INSTALL_APP "path=$check_path" \
|
||||||
&& ynh_lxc_pc_snapshot_create $snapname
|
&& ynh_lxc_pc_snapshot_create $snapname
|
||||||
else
|
else
|
||||||
# Or uses an existing snapshot
|
# Or uses an existing snapshot
|
||||||
log_info "(Reusing existing snapshot $snapname)" \
|
log_info "(Reusing existing snapshot $snapname)" \
|
||||||
&& LOAD_LXC_SNAPSHOT $snapname
|
&& ynh_lxc_snapshot_load $snapname
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ TEST_INSTALL () {
|
||||||
[ "$install_type" = "private" ] && { start_test "Installation in private mode"; local is_public="0"; }
|
[ "$install_type" = "private" ] && { start_test "Installation in private mode"; local is_public="0"; }
|
||||||
local snapname=snap_${install_type}install
|
local snapname=snap_${install_type}install
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
ynh_lxc_snapshot_load snap0
|
||||||
|
|
||||||
_PREINSTALL
|
_PREINSTALL
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ _TEST_MULTI_INSTANCE () {
|
||||||
|
|
||||||
local check_path="$(default_install_path)"
|
local check_path="$(default_install_path)"
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
ynh_lxc_snapshot_load snap0
|
||||||
|
|
||||||
log_small_title "First installation: path=$SUBDOMAIN$check_path" \
|
log_small_title "First installation: path=$SUBDOMAIN$check_path" \
|
||||||
&& _LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path" \
|
&& _LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path" \
|
||||||
|
@ -436,7 +436,7 @@ TEST_UPGRADE () {
|
||||||
cp -a "$package_path" "${package_path}_back"
|
cp -a "$package_path" "${package_path}_back"
|
||||||
(cd "$package_path"; git checkout --force --quiet "$commit")
|
(cd "$package_path"; git checkout --force --quiet "$commit")
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
ynh_lxc_snapshot_load snap0
|
||||||
|
|
||||||
_PREINSTALL
|
_PREINSTALL
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ TEST_PORT_ALREADY_USED () {
|
||||||
local check_port="$1"
|
local check_port="$1"
|
||||||
local check_path="$(default_install_path)"
|
local check_path="$(default_install_path)"
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
ynh_lxc_snapshot_load snap0
|
||||||
|
|
||||||
# Build a service with netcat for use this port before the app.
|
# Build a service with netcat for use this port before the app.
|
||||||
echo -e "[Service]\nExecStart=/bin/netcat -l -k -p $check_port\n
|
echo -e "[Service]\nExecStart=/bin/netcat -l -k -p $check_port\n
|
||||||
|
@ -570,7 +570,7 @@ TEST_BACKUP_RESTORE () {
|
||||||
elif [ $j -eq 1 ]
|
elif [ $j -eq 1 ]
|
||||||
then
|
then
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
ynh_lxc_snapshot_load snap0
|
||||||
|
|
||||||
# Remove the previous residual backups
|
# Remove the previous residual backups
|
||||||
RUN_INSIDE_LXC rm -rf /home/yunohost.backup/archives
|
RUN_INSIDE_LXC rm -rf /home/yunohost.backup/archives
|
||||||
|
|
14
lib/ynh_lxd
14
lib/ynh_lxd
|
@ -12,3 +12,17 @@ ynh_lxc_snapshot_exists () {
|
||||||
>/dev/null
|
>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ynh_lxc_snapshot_load () {
|
||||||
|
local snapname=$1
|
||||||
|
log_debug "Loading snapshot $snapname ..."
|
||||||
|
|
||||||
|
# Remove swap files before restoring the snapshot.
|
||||||
|
CLEAN_SWAPFILES
|
||||||
|
|
||||||
|
LXC_STOP $LXC_NAME
|
||||||
|
|
||||||
|
lxc restore $LXC_NAME $snapname
|
||||||
|
lxc start $LXC_NAME
|
||||||
|
_LXC_START_AND_WAIT $LXC_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,20 +175,6 @@ ynh_lxc_pc_snapshot_create () {
|
||||||
stop_timer 1
|
stop_timer 1
|
||||||
}
|
}
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT () {
|
|
||||||
local snapname=$1
|
|
||||||
log_debug "Loading snapshot $snapname ..."
|
|
||||||
|
|
||||||
# Remove swap files before restoring the snapshot.
|
|
||||||
CLEAN_SWAPFILES
|
|
||||||
|
|
||||||
LXC_STOP $LXC_NAME
|
|
||||||
|
|
||||||
lxc restore $LXC_NAME $snapname
|
|
||||||
lxc start $LXC_NAME
|
|
||||||
_LXC_START_AND_WAIT $LXC_NAME
|
|
||||||
}
|
|
||||||
|
|
||||||
LXC_STOP () {
|
LXC_STOP () {
|
||||||
local container_to_stop=$1
|
local container_to_stop=$1
|
||||||
# (We also use timeout 30 in front of the command because sometime lxc
|
# (We also use timeout 30 in front of the command because sometime lxc
|
||||||
|
|
Loading…
Add table
Reference in a new issue