dustin
/
jenkinsagent
Archived
1
0
Fork 0
This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
jenkinsagent/rootfs/overlay/usr/libexec/copy-var.sh

24 lines
464 B
Bash
Executable File

#!/bin/sh
set -e
cleanup() {
if [ -n "${tmpdir}" ] && [ -d "${tmpdir}" ] && [ / != "${tmpdir}" ]; then
if mountpoint -q "${tmpdir}"; then
umount "${tmpdir}"
fi
rm -rf "${tmpdir}"
fi
unset tmpdir
}
tmpdir=$(TMPDIR=/run mktemp -d)
trap cleanup INT QUIT TERM EXIT
mount -o bind / "${tmpdir}"
cp -a "${tmpdir}"/var/. /var/
if [ -x "$(command -v selinuxenabled)" ] && selinuxenabled; then
restorecon -RF /var
fi