Skip to content

Commit

Permalink
Merge pull request #288 from mekanix/feature/export
Browse files Browse the repository at this point in the history
Add destination to export script
  • Loading branch information
mekanix authored Feb 21, 2023
2 parents f6abb73 + 117c2dd commit 4baf76f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mk/base-jail.mk
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export:
.if !exists(build)
@mkdir build
.endif
@sudo reggae export ${SERVICE}
@sudo reggae export ${SERVICE} build
@echo "Chowning ${SERVICE}.img to ${UID}:${GID} ..."
@sudo chown ${UID}:${GID} build/${SERVICE}.img
.if target(post_export)
Expand Down
10 changes: 8 additions & 2 deletions scripts/export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
set -e

SERVICE="${1}"
DESTINATION="${2}"
if [ -z "${SERVICE}" -o -z "${DESTINATION}" ]; then
echo "Usage: $0 <service> <destination>" >&2
exit 1
fi

BASE_WORKDIR="$(reggae get-config BASE_WORKDIR)"
JAIL_PATH="${BASE_WORKDIR}/${SERVICE}"
CONFIG="$(cat "/etc/jail.conf.d/${SERVICE}.conf")"


service jail stop "${SERVICE}"
tar --zstd -c -p -f "build/${SERVICE}.img" --cd "${JAIL_PATH}" .
setextattr system config "${CONFIG}" "build/${SERVICE}.img"
tar --zstd -c -p -f "${DESTINATION}/${SERVICE}.img" --cd "${JAIL_PATH}" .
setextattr system config "${CONFIG}" "${DESTINATION}/${SERVICE}.img"

0 comments on commit 4baf76f

Please sign in to comment.