mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-23 15:16:44 +00:00
scope the change journal to host changes, in three sections
The change journal exists so a sysadmin sees what ProxMenux changed on the host — its own configuration, packages and services — not how it uses the host or configures a guest. Several scripts recorded operations that are neither: disk passthrough to a VM, container conversions, VM import/export, mounting a share into an LXC. Those are restored to their original, uninstrumented form. Scripts that operate on the host while also installing a package now record only the package: format-disk keeps its exFAT-tools install, the UUP ISO builder its build dependencies, and the share/host scripts their packages, services and /etc/fstab writes, while the mount and unmount operations they used to log are dropped. The page now reads in three sections: what ProxMenux optimized after install (each function under its menu name), what its other host scripts changed (by script), and what it installed (packages and utilities, each referencing the script that installed it). A file reads as created or modified with its diff, a service shows its state transition, and the undo line appears only when a revert is possible.
This commit is contained in:
@@ -23,10 +23,6 @@ if [[ -f "$UTILS_FILE" ]]; then
|
||||
source "$UTILS_FILE"
|
||||
fi
|
||||
|
||||
if [[ -f "$LOCAL_SCRIPTS/global/pmx_journal.sh" ]]; then
|
||||
source "$LOCAL_SCRIPTS/global/pmx_journal.sh"
|
||||
fi
|
||||
|
||||
load_language
|
||||
initialize_cache
|
||||
|
||||
@@ -57,9 +53,6 @@ select_privileged_container() {
|
||||
}
|
||||
|
||||
validate_container_id() {
|
||||
local FUNC_VERSION="1.1"
|
||||
pmx_journal_context "validate_container_id" "$FUNC_VERSION"
|
||||
|
||||
if [ -z "$CONTAINER_ID" ]; then
|
||||
msg_error "$(translate 'Container ID not defined. Make sure to select a container first.')"
|
||||
exit 1
|
||||
@@ -73,8 +66,6 @@ validate_container_id() {
|
||||
|
||||
if pct status "$CONTAINER_ID" | grep -q "running"; then
|
||||
msg_info "$(translate 'Stopping the container before conversion...')"
|
||||
pmx_record_execution "stop CT ${CONTAINER_ID} for privileged-to-unprivileged conversion" \
|
||||
"pct stop ${CONTAINER_ID}"
|
||||
pct stop "$CONTAINER_ID"
|
||||
msg_ok "$(translate 'Container stopped.')"
|
||||
fi
|
||||
@@ -98,12 +89,7 @@ show_backup_warning() {
|
||||
}
|
||||
|
||||
convert_direct_method() {
|
||||
local FUNC_VERSION="1.1"
|
||||
pmx_journal_context "convert_direct_method" "$FUNC_VERSION"
|
||||
|
||||
msg_info2 "$(translate 'Starting direct conversion of container') $CONTAINER_ID..."
|
||||
pmx_record_execution "convert CT ${CONTAINER_ID} filesystem ownership to unprivileged IDs" \
|
||||
"mount rootfs, remap ownership by 100000, and update CT configuration"
|
||||
|
||||
TEMP_DIR="/tmp/lxc_convert_$CONTAINER_ID"
|
||||
mkdir -p "$TEMP_DIR"
|
||||
@@ -239,9 +225,9 @@ convert_direct_method() {
|
||||
|
||||
CONFIG_FILE="/etc/pve/lxc/$CONTAINER_ID.conf"
|
||||
if ! grep -q "^unprivileged:" "$CONFIG_FILE"; then
|
||||
echo "unprivileged: 1" | pmx_append_file "$CONFIG_FILE"
|
||||
echo "unprivileged: 1" >> "$CONFIG_FILE"
|
||||
else
|
||||
pmx_edit_file "$CONFIG_FILE" 's/^unprivileged:.*/unprivileged: 1/'
|
||||
sed -i 's/^unprivileged:.*/unprivileged: 1/' "$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
msg_ok "$(translate 'Direct conversion completed for container') $CONTAINER_ID"
|
||||
@@ -252,12 +238,9 @@ convert_direct_method() {
|
||||
}
|
||||
|
||||
cleanup_and_finalize() {
|
||||
local FUNC_VERSION="1.1"
|
||||
pmx_journal_context "cleanup_and_finalize" "$FUNC_VERSION"
|
||||
|
||||
if whiptail --yesno "$(translate 'Do you want to start the converted unprivileged container') $CONTAINER_ID $(translate 'now?')" 10 60; then
|
||||
msg_info2 "$(translate 'Starting unprivileged container...')"
|
||||
pmx_record_execution "start converted unprivileged CT ${CONTAINER_ID}" "pct start ${CONTAINER_ID}"
|
||||
pct start "$CONTAINER_ID"
|
||||
msg_ok "$(translate 'Unprivileged container') $CONTAINER_ID $(translate 'started successfully.')"
|
||||
fi
|
||||
|
||||
@@ -25,10 +25,6 @@ if [[ -f "$UTILS_FILE" ]]; then
|
||||
source "$UTILS_FILE"
|
||||
fi
|
||||
|
||||
if [[ -f "$LOCAL_SCRIPTS/global/pmx_journal.sh" ]]; then
|
||||
source "$LOCAL_SCRIPTS/global/pmx_journal.sh"
|
||||
fi
|
||||
|
||||
load_language
|
||||
initialize_cache
|
||||
|
||||
@@ -73,19 +69,12 @@ show_backup_warning() {
|
||||
}
|
||||
|
||||
convert_to_privileged() {
|
||||
local FUNC_VERSION="2.0"
|
||||
pmx_journal_context "convert_to_privileged" "$FUNC_VERSION"
|
||||
|
||||
CONF_FILE="/etc/pve/lxc/$CONTAINER_ID.conf"
|
||||
pmx_record_execution "convert CT ${CONTAINER_ID} to privileged mode" \
|
||||
"stop CT if running and update ${CONF_FILE}"
|
||||
|
||||
CONTAINER_STATUS=$(pct status "$CONTAINER_ID" | awk '{print $2}')
|
||||
|
||||
if [ "$CONTAINER_STATUS" == "running" ]; then
|
||||
msg_info "$(translate 'Stopping container') $CONTAINER_ID..."
|
||||
pmx_record_execution "stop CT ${CONTAINER_ID} for unprivileged-to-privileged conversion" \
|
||||
"pct shutdown ${CONTAINER_ID}"
|
||||
pct shutdown "$CONTAINER_ID"
|
||||
|
||||
# Wait for container to stop
|
||||
@@ -112,8 +101,8 @@ convert_to_privileged() {
|
||||
msg_ok "$(translate 'Configuration backup created:') $CONF_FILE.bak"
|
||||
|
||||
msg_info "$(translate 'Converting container to privileged...')"
|
||||
pmx_edit_file "$CONF_FILE" '/^unprivileged: 1/d'
|
||||
echo "unprivileged: 0" | pmx_append_file "$CONF_FILE"
|
||||
sed -i '/^unprivileged: 1/d' "$CONF_FILE"
|
||||
echo "unprivileged: 0" >> "$CONF_FILE"
|
||||
|
||||
msg_ok "$(translate 'Container successfully converted to privileged.')"
|
||||
|
||||
@@ -123,12 +112,9 @@ convert_to_privileged() {
|
||||
}
|
||||
|
||||
finalize_conversion() {
|
||||
local FUNC_VERSION="2.0"
|
||||
pmx_journal_context "finalize_conversion" "$FUNC_VERSION"
|
||||
|
||||
if whiptail --yesno "$(translate 'Do you want to start the privileged container') $CONTAINER_ID $(translate 'now?')" 10 60; then
|
||||
msg_info "$(translate 'Starting privileged container...')"
|
||||
pmx_record_execution "start converted privileged CT ${CONTAINER_ID}" "pct start ${CONTAINER_ID}"
|
||||
pct start "$CONTAINER_ID"
|
||||
msg_ok "$(translate 'Privileged container') $CONTAINER_ID $(translate 'started successfully.')"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user