mirror of
https://github.com/mrvasil/ctf-ad-mirror-tool-rust.git
synced 2026-10-25 02:09:25 +00:00
35 lines
1.2 KiB
Bash
35 lines
1.2 KiB
Bash
#!/bin/sh
|
|
# Portable Linux launcher. Runtime data is never included in release archives.
|
|
set -eu
|
|
case "$(uname -s):$(uname -m)" in
|
|
Linux:x86_64|Linux:amd64) ;;
|
|
*) echo 'This package requires Linux x86-64.' >&2; exit 1 ;;
|
|
esac
|
|
cd -- "$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)"
|
|
umask 077
|
|
mkdir -p data
|
|
if [ ! -e mirror.toml ]; then
|
|
(set -C; cat > mirror.toml <<'CONFIG'
|
|
# Add teams/services in the panel or use mirror.example.toml as a reference.
|
|
# Existing data/state.json takes precedence over teams/services in this file.
|
|
[web]
|
|
listen = "127.0.0.1:6700"
|
|
state_file = "data/state.json"
|
|
CONFIG
|
|
)
|
|
fi
|
|
if [ -z "${MIRROR_PASSWORD:-}" ]; then
|
|
if [ ! -e data/panel-password ]; then
|
|
(set -C; od -An -N24 -tx1 /dev/urandom | tr -d ' \n' > data/panel-password)
|
|
fi
|
|
MIRROR_PASSWORD=$(cat data/panel-password)
|
|
if [ "${#MIRROR_PASSWORD}" -lt 12 ]; then
|
|
echo 'data/panel-password is invalid; restore it or supply MIRROR_PASSWORD.' >&2
|
|
exit 1
|
|
fi
|
|
export MIRROR_PASSWORD
|
|
echo 'Panel password: read data/panel-password (kept across restarts).'
|
|
fi
|
|
echo 'Config: mirror.toml. Default panel: http://127.0.0.1:6700 (see web.listen).'
|
|
exec ./mirror-tool --config mirror.toml "$@"
|