Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
# -----------------------------------------------------------------------------
|
||||
# Installs the ADPanel privileged runner + job scripts.
|
||||
#
|
||||
# Deploys privileged/adpanel-priv to /usr/local/lib/adpanel/adpanel-priv and
|
||||
# privileged/jobs/*.sh to /usr/local/lib/adpanel/jobs/, all owned root:root
|
||||
# with no group/world write bits, so the sudoers policy can safely allow
|
||||
# 'adpanel' to run exactly one command as root (see adpanel-sudoers).
|
||||
#
|
||||
# Must be run as root. Idempotent. Uses the panel dir as $1 or the directory
|
||||
# containing this script when omitted.
|
||||
# -----------------------------------------------------------------------------
|
||||
set -euo pipefail
|
||||
|
||||
PANEL_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd)}"
|
||||
PRIV_SRC="${PANEL_DIR}/privileged"
|
||||
DEST="/usr/local/lib/adpanel"
|
||||
JOBS_SRC="${PRIV_SRC}/jobs"
|
||||
JOBS_DEST="${DEST}/jobs"
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "install-privileged.sh: must be run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${PRIV_SRC}/adpanel-priv" ] || [ ! -d "$JOBS_SRC" ]; then
|
||||
echo "install-privileged.sh: privileged sources missing under ${PRIV_SRC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install -d -o root -g root -m 0755 "$DEST"
|
||||
install -d -o root -g root -m 0755 "$JOBS_DEST"
|
||||
|
||||
# Remove any job no longer shipped in the source tree (stale root-owned
|
||||
# leftovers must not survive a panel update).
|
||||
for f in "${JOBS_DEST}"/*.sh; do
|
||||
[ -e "$f" ] || continue
|
||||
base="$(basename "$f")"
|
||||
[ -f "${JOBS_SRC}/${base}" ] || rm -f "$f"
|
||||
done
|
||||
|
||||
install -o root -g root -m 0755 "${PRIV_SRC}/adpanel-priv" "${DEST}/adpanel-priv"
|
||||
for f in "${JOBS_SRC}"/*.sh; do
|
||||
[ -e "$f" ] || continue
|
||||
install -o root -g root -m 0755 "$f" "${JOBS_DEST}/$(basename "$f")"
|
||||
done
|
||||
|
||||
# Keep an installed copy of the (restricted) sudoers snippet in sync so
|
||||
# start.sh's visudo-validated sync cannot regress to a wider policy.
|
||||
if [ -f "${PANEL_DIR}/adpanel-sudoers" ]; then
|
||||
tmp="$(mktemp)"
|
||||
cp "${PANEL_DIR}/adpanel-sudoers" "$tmp"
|
||||
chmod 0440 "$tmp"
|
||||
if command -v visudo >/dev/null 2>&1 && ! visudo -cf "$tmp" >/dev/null 2>&1; then
|
||||
rm -f "$tmp"
|
||||
echo "install-privileged.sh: WARNING sudoers snippet failed validation; leaving existing policy" >&2
|
||||
else
|
||||
mkdir -p /etc/sudoers.d
|
||||
mv "$tmp" /etc/sudoers.d/adpanel-panel
|
||||
chmod 0440 /etc/sudoers.d/adpanel-panel
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "install-privileged.sh: privileged runner installed at ${DEST}/adpanel-priv"
|
||||
Reference in new issue
Block a user