rbm.conf: Handle SIGINT case

pull/88/head
Jeremy Rand 3 years ago
parent a72f41b5a3
commit 0c1c248443
No known key found for this signature in database
GPG Key ID: FD7550C2EB800711

@ -504,6 +504,18 @@ runc:
remote_start: |
#!/bin/sh
set -e
# Handle SIGINT case
if [ -d '[% c("rbm_tmp_dir") %]'/../interrupted_dirs/'[% c("var/build_id") %]' ]
then
# We previously did this build but it was manually interrupted.
# Restore the container's saved state instead of making a new container.
mkdir -p '[% c("var/container/dir") %]'
rmdir '[% c("var/container/dir") %]'
mv '[% c("rbm_tmp_dir") %]'/../interrupted_dirs/'[% c("var/build_id") %]' '[% c("var/container/dir") %]'
exit
fi
if [ $(ls -1 '[% c("remote_srcdir", { error_if_undef => 1 }) %]/container-image_'* | wc -l) -ne 1 ]
then
echo "Can't find container image in input files" >&2
@ -580,6 +592,19 @@ runc:
remote_finish: |
#!/bin/sh
set -e
# Handle SIGINT case
if [ -e '[% c("rbm_tmp_dir") %]'/../interrupted ]
then
# This build was manually interrupted via tools/container-interrupt.sh.
# Save the container's state instead of deleting, so we can resume
# the build later.
mkdir -p '[% c("rbm_tmp_dir") %]'/../interrupted_dirs
mv '[% c("var/container/dir") %]' '[% c("rbm_tmp_dir") %]'/../interrupted_dirs/'[% c("var/build_id") %]'
rm '[% c("rbm_tmp_dir") %]'/../interrupted
exit
fi
sudo rm -Rf '[% c("var/container/dir", { error_if_undef => 1 }) %]'/rootfs '[% c("var/container/dir", { error_if_undef => 1 }) %]'/config.json
rmdir '[% c("var/container/dir") %]'

Loading…
Cancel
Save