diff options
Diffstat (limited to 'debian-container/debian-container.sh')
| -rwxr-xr-x | debian-container/debian-container.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/debian-container/debian-container.sh b/debian-container/debian-container.sh new file mode 100755 index 0000000..4a52da0 --- /dev/null +++ b/debian-container/debian-container.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (C) 2026 by Richard Qin + +# Debian 构建容器 +set -Eeuo pipefail + +DC_SCRIPT=$(readlink -f -- "${BASH_SOURCE[0]}") +DC_DIR=$(dirname -- "$DC_SCRIPT") + +source "$DC_DIR/lib/config.sh" +source "$DC_DIR/lib/common.sh" +source "$DC_DIR/lib/mount.sh" +source "$DC_DIR/lib/container.sh" + +DC_ACTION=${1:-} + +case "$DC_ACTION" in + help|-h|--help) + dc_usage + exit 0 + ;; +esac + +dc_require_root + +case "$DC_ACTION" in + init|enter|delete) + # 防止多个会话同时读写同一 ext4 镜像。 + dc_acquire_lock + ;; +esac + +case "$DC_ACTION" in + init) dc_init ;; + _init) dc_init_rootfs ;; + enter) dc_enter ;; + _enter) dc_enter_rootfs ;; + delete) dc_delete ;; + *) + dc_usage >&2 + exit 2 + ;; +esac |
