workspace и reboot-модуль: второй продакшн бинарь и упаковка
This commit is contained in:
+30
-9
@@ -2,8 +2,10 @@
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
WORKSPACE_MANIFEST="$ROOT_DIR/Cargo.toml"
|
||||
CRATE_MANIFEST="$ROOT_DIR/traffic_core/Cargo.toml"
|
||||
TARGET_BIN="$ROOT_DIR/traffic_core/target/release/awg2-harness"
|
||||
TARGET_BIN="$ROOT_DIR/target/release/awg2-harness"
|
||||
REBOOT_BIN="$ROOT_DIR/target/release/awg2-reboot-scheduler"
|
||||
RUST_TOOLCHAIN_FILE="$ROOT_DIR/rust-toolchain.toml"
|
||||
RUST_TOOLCHAIN_VERSION="1.95.0"
|
||||
|
||||
@@ -215,23 +217,33 @@ prepare_build_gate() {
|
||||
cargo fmt --manifest-path "$CRATE_MANIFEST" --all --check
|
||||
fi
|
||||
|
||||
cargo clippy --locked --manifest-path "$CRATE_MANIFEST" --all-targets -- -D warnings
|
||||
cargo test --locked --manifest-path "$CRATE_MANIFEST" --release
|
||||
cargo build --locked --manifest-path "$CRATE_MANIFEST" --release
|
||||
if [[ ! -f "$WORKSPACE_MANIFEST" ]]; then
|
||||
echo "Missing workspace manifest: $WORKSPACE_MANIFEST"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo clippy --locked --workspace --all-targets --manifest-path "$WORKSPACE_MANIFEST" -- -D warnings
|
||||
cargo test --locked --workspace --release --manifest-path "$WORKSPACE_MANIFEST"
|
||||
cargo build --locked --workspace --release --manifest-path "$WORKSPACE_MANIFEST"
|
||||
|
||||
file "$TARGET_BIN"
|
||||
file "$REBOOT_BIN"
|
||||
ldd "$TARGET_BIN" || true
|
||||
ldd "$REBOOT_BIN" || true
|
||||
"$TARGET_BIN" --help >/dev/null
|
||||
"$REBOOT_BIN" --help >/dev/null
|
||||
sha256sum "$TARGET_BIN"
|
||||
sha256sum "$REBOOT_BIN"
|
||||
ls -lh "$TARGET_BIN"
|
||||
ls -lh "$REBOOT_BIN"
|
||||
}
|
||||
|
||||
install_artifacts() {
|
||||
require_cmd install
|
||||
require_cmd systemctl
|
||||
|
||||
if [[ ! -f "$TARGET_BIN" ]]; then
|
||||
echo "Binary not found: $TARGET_BIN"
|
||||
if [[ ! -f "$TARGET_BIN" || ! -f "$REBOOT_BIN" ]]; then
|
||||
echo "Binary not found: $TARGET_BIN or $REBOOT_BIN"
|
||||
echo "Run build first: ./tools/build.sh"
|
||||
exit 1
|
||||
fi
|
||||
@@ -246,11 +258,14 @@ install_artifacts() {
|
||||
setup_root_runner
|
||||
"${RUN_AS_ROOT[@]}" install -d -m 0755 /usr/sbin
|
||||
"${RUN_AS_ROOT[@]}" install -m 0755 "$TARGET_BIN" /usr/sbin/awg2-harness
|
||||
"${RUN_AS_ROOT[@]}" install -m 0755 "$REBOOT_BIN" /usr/sbin/awg2-reboot-scheduler
|
||||
"${RUN_AS_ROOT[@]}" install -d -m 0755 /lib/systemd/system
|
||||
"${RUN_AS_ROOT[@]}" install -m 0644 "$ROOT_DIR/awg2-harness.service" /lib/systemd/system/awg2-harness.service
|
||||
"${RUN_AS_ROOT[@]}" install -m 0644 "$ROOT_DIR/awg2-reboot-scheduler.service" /lib/systemd/system/awg2-reboot-scheduler.service
|
||||
|
||||
if command -v systemd-analyze >/dev/null 2>&1; then
|
||||
"${RUN_AS_ROOT[@]}" systemd-analyze verify /lib/systemd/system/awg2-harness.service
|
||||
"${RUN_AS_ROOT[@]}" systemd-analyze verify /lib/systemd/system/awg2-reboot-scheduler.service
|
||||
fi
|
||||
"${RUN_AS_ROOT[@]}" systemctl daemon-reload
|
||||
}
|
||||
@@ -271,8 +286,8 @@ package_deb() {
|
||||
prepare_build_gate
|
||||
fi
|
||||
|
||||
if [[ ! -f "$TARGET_BIN" ]]; then
|
||||
echo "Binary not found after build: $TARGET_BIN"
|
||||
if [[ ! -f "$TARGET_BIN" || ! -f "$REBOOT_BIN" ]]; then
|
||||
echo "Binary not found after build: $TARGET_BIN or $REBOOT_BIN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -295,15 +310,20 @@ package_deb() {
|
||||
install -d -m 0755 "$staging/DEBIAN"
|
||||
install -d -m 0755 "$staging/usr/sbin"
|
||||
install -d -m 0755 "$staging/lib/systemd/system"
|
||||
install -d -m 0755 "$staging/etc/awg2-harness"
|
||||
install -d -m 0755 "$staging/usr/share/doc/awg2-harness/repo"
|
||||
install -d -m 0755 "$staging/usr/share/doc/awg2-harness/repo/docs"
|
||||
install -d -m 0755 "$staging/usr/share/doc/awg2-harness/repo/tools"
|
||||
|
||||
install -m 0755 "$TARGET_BIN" "$staging/usr/sbin/awg2-harness"
|
||||
install -m 0755 "$REBOOT_BIN" "$staging/usr/sbin/awg2-reboot-scheduler"
|
||||
install -m 0644 "$ROOT_DIR/awg2-harness.service" "$staging/lib/systemd/system/awg2-harness.service"
|
||||
install -m 0644 "$ROOT_DIR/awg2-reboot-scheduler.service" "$staging/lib/systemd/system/awg2-reboot-scheduler.service"
|
||||
install -m 0644 "$ROOT_DIR/config.example.toml" "$staging/usr/share/doc/awg2-harness/repo/config.example.toml"
|
||||
install -m 0644 "$ROOT_DIR/README.md" "$staging/usr/share/doc/awg2-harness/repo/README.md"
|
||||
install -m 0644 "$ROOT_DIR/docs/INSTALLATION.md" "$staging/usr/share/doc/awg2-harness/repo/docs/INSTALLATION.md"
|
||||
install -m 0644 "$ROOT_DIR/docs/CONFIGURATION.md" "$staging/usr/share/doc/awg2-harness/repo/docs/CONFIGURATION.md"
|
||||
install -m 0644 "$ROOT_DIR/docs/ACCEPTANCE_CHECKLIST.md" "$staging/usr/share/doc/awg2-harness/repo/docs/ACCEPTANCE_CHECKLIST.md"
|
||||
install -m 0644 "$ROOT_DIR/tools/README.md" "$staging/usr/share/doc/awg2-harness/repo/tools/README.md"
|
||||
|
||||
cat >"$staging/DEBIAN/control" <<EOF
|
||||
@@ -317,7 +337,7 @@ Depends: libc6, iproute2, wireguard-tools, nftables, kmod, util-linux, procps, s
|
||||
Description: Host-side orchestrator for AmneziaWG traffic shaping and lifecycle recovery
|
||||
AWG2 Harness manages AmneziaWG traffic shaping, IFB ingress shaping,
|
||||
nftables anti-torrent guard, reboot scheduling, swap setup and daemonized
|
||||
drift recovery on dedicated Debian hosts.
|
||||
drift recovery on dedicated Debian hosts. Includes external reboot scheduler.
|
||||
EOF
|
||||
|
||||
cat >"$staging/DEBIAN/postinst" <<'EOF'
|
||||
@@ -365,6 +385,7 @@ enable_service() {
|
||||
require_cmd systemctl
|
||||
setup_root_runner
|
||||
"${RUN_AS_ROOT[@]}" systemctl enable --now awg2-harness.service
|
||||
"${RUN_AS_ROOT[@]}" systemctl enable --now awg2-reboot-scheduler.service
|
||||
}
|
||||
|
||||
ensure_supported_host
|
||||
|
||||
Reference in New Issue
Block a user