mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-19 13:17:23 +00:00
group host changes by function with a truthful before/after
This commit is contained in:
@@ -158,7 +158,7 @@ _pmx_journal_common() {
|
||||
# EOF
|
||||
pmx_write_file() {
|
||||
local path="$1"
|
||||
local temp before after existed="false"
|
||||
local temp before="" after="" existed="false"
|
||||
temp="$(mktemp)" || { cat > "$path"; return $?; }
|
||||
cat > "$temp"
|
||||
|
||||
@@ -245,7 +245,7 @@ pmx_remove_file() {
|
||||
# printf 'ulimit -n 1048576\n' | pmx_append_file /root/.profile
|
||||
pmx_append_file() {
|
||||
local path="$1"
|
||||
local temp before after existed="false"
|
||||
local temp before="" after="" existed="false"
|
||||
temp="$(mktemp)" || { cat >> "$path"; return $?; }
|
||||
cat > "$temp"
|
||||
|
||||
@@ -342,8 +342,8 @@ pmx_install_pkg() {
|
||||
_pmx_service_state() {
|
||||
local unit="$1"
|
||||
printf '%s/%s' \
|
||||
"$(systemctl is-enabled "$unit" 2>/dev/null || echo unknown)" \
|
||||
"$(systemctl is-active "$unit" 2>/dev/null || echo unknown)"
|
||||
"$(systemctl is-enabled "$unit" 2>/dev/null | head -1 || echo unknown)" \
|
||||
"$(systemctl is-active "$unit" 2>/dev/null | head -1 || echo unknown)"
|
||||
}
|
||||
|
||||
pmx_enable_service() {
|
||||
|
||||
@@ -97,16 +97,6 @@ register_tool() {
|
||||
local state="$2"
|
||||
local version="${3:-1.0}"
|
||||
local source="${4:-${SCRIPT_SOURCE:-unknown}}"
|
||||
# Same as in the customizable script: the one call every function
|
||||
# already makes, so an applied tool reaches the journal even where
|
||||
# the function itself still writes directly.
|
||||
if declare -F pmx_record_applied >/dev/null 2>&1; then
|
||||
PMX_JOURNAL_FUNCTION="${FUNCNAME[1]:-$tool}" \
|
||||
PMX_JOURNAL_VERSION="$version" \
|
||||
PMX_JOURNAL_SOURCE="$source" \
|
||||
pmx_record_applied "$tool" "$version" \
|
||||
"$([[ "$state" == "true" ]] && echo applied || echo removed)"
|
||||
fi
|
||||
ensure_tools_json
|
||||
if [[ "$state" == "true" ]]; then
|
||||
jq --arg t "$tool" --arg ver "$version" --arg src "$source" \
|
||||
@@ -1293,8 +1283,13 @@ EOF
|
||||
[ "$KEEP_MB" -lt 8 ] && KEEP_MB=8
|
||||
|
||||
|
||||
pmx_edit_file /etc/systemd/journald.conf '/^\[Journal\]/,$d' 2>/dev/null || true
|
||||
pmx_append_file /etc/systemd/journald.conf <<EOF
|
||||
# Compose the final file and write it once: keep everything above the
|
||||
# existing [Journal] section, then our block. Editing then appending
|
||||
# produced two journal entries for one file, each with half the diff;
|
||||
# one write shows the whole before/after a sysadmin should read.
|
||||
{
|
||||
sed '/^\[Journal\]/,$d' /etc/systemd/journald.conf 2>/dev/null
|
||||
cat <<EOF
|
||||
[Journal]
|
||||
Storage=persistent
|
||||
SplitMode=none
|
||||
@@ -1315,6 +1310,7 @@ MaxLevelKMsg=warning
|
||||
MaxLevelConsole=notice
|
||||
MaxLevelWall=crit
|
||||
EOF
|
||||
} | pmx_write_file /etc/systemd/journald.conf
|
||||
|
||||
|
||||
mkdir -p /var/log/pveproxy
|
||||
|
||||
@@ -94,18 +94,6 @@ register_tool() {
|
||||
local state="$2"
|
||||
local version="${3:-1.0}"
|
||||
local source="${4:-${SCRIPT_SOURCE:-unknown}}"
|
||||
# Recorded here rather than in each function: this is the one call the
|
||||
# whole of post-install already makes, so every applied tool reaches
|
||||
# the journal even where the function itself still writes directly.
|
||||
# Such an entry says what was applied and admits it cannot say what
|
||||
# changed, which is the honest account for anything not yet migrated.
|
||||
if declare -F pmx_record_applied >/dev/null 2>&1; then
|
||||
PMX_JOURNAL_FUNCTION="${FUNCNAME[1]:-$tool}" \
|
||||
PMX_JOURNAL_VERSION="$version" \
|
||||
PMX_JOURNAL_SOURCE="$source" \
|
||||
pmx_record_applied "$tool" "$version" \
|
||||
"$([[ "$state" == "true" ]] && echo applied || echo removed)"
|
||||
fi
|
||||
ensure_tools_json
|
||||
if [[ "$state" == "true" ]]; then
|
||||
jq --arg t "$tool" --arg ver "$version" --arg src "$source" \
|
||||
|
||||
Reference in New Issue
Block a user