mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-21 06:06:46 +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:
@@ -486,8 +486,6 @@ format_and_mount_disk() {
|
||||
14 80; then
|
||||
return 1
|
||||
fi
|
||||
pmx_record_execution "format disk ${disk} as ${filesystem} for ${mount_path}" \
|
||||
"wipe disk, create partition and format as ${filesystem}"
|
||||
show_proxmenux_logo
|
||||
if [[ "$MODE_PVESM" -eq 1 && "$MODE_FSTAB" -eq 1 ]]; then
|
||||
msg_title "$(translate "Add Local Disk (Proxmox storage + host mount)")"
|
||||
@@ -572,8 +570,6 @@ mount_disk_permanently() {
|
||||
msg_ok "$(translate "Mount point created")"
|
||||
|
||||
msg_info "$(translate "Mounting disk...")"
|
||||
pmx_record_execution "mount ${partition} at ${mount_path}" \
|
||||
"mount -t ${filesystem} ${partition} ${mount_path}"
|
||||
if ! mount -t "$filesystem" "$partition" "$mount_path" 2>/dev/null; then
|
||||
msg_error "$(translate "Failed to mount disk")"
|
||||
return 1
|
||||
@@ -622,8 +618,6 @@ _apply_lxc_bind_mount_perms() {
|
||||
[[ -d "$mount_path" ]] || return 0
|
||||
|
||||
msg_info "$(translate "Applying host permissions for unprivileged LXC bind-mounts...")"
|
||||
pmx_record_execution "apply LXC bind-mount permissions to ${mount_path}" \
|
||||
"chmod o+rwx and setfacl on ${mount_path}"
|
||||
chmod o+rwx "$mount_path" 2>/dev/null || true
|
||||
if command -v setfacl >/dev/null 2>&1; then
|
||||
setfacl -m o::rwx "$mount_path" 2>/dev/null || true
|
||||
@@ -653,7 +647,6 @@ mount_existing_disk() {
|
||||
msg_ok "$(translate "Mount point created")"
|
||||
|
||||
msg_info "$(translate "Mounting existing") $existing_fs $(translate "filesystem...")"
|
||||
pmx_record_execution "mount existing disk ${disk} at ${mount_path}" "mount ${disk} ${mount_path}"
|
||||
if ! mount "$disk" "$mount_path" 2>/dev/null; then
|
||||
msg_error "$(translate "Failed to mount disk")"
|
||||
return 1
|
||||
@@ -702,7 +695,6 @@ add_proxmox_dir_storage() {
|
||||
8 60; then
|
||||
return 0
|
||||
fi
|
||||
pmx_record_execution "remove existing Proxmox storage ${storage_id}" "pvesm remove ${storage_id}"
|
||||
pvesm remove "$storage_id" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
@@ -710,16 +702,12 @@ add_proxmox_dir_storage() {
|
||||
local pvesm_output
|
||||
local add_ok=false
|
||||
if [[ "$storage_kind" == "zfspool" ]]; then
|
||||
pmx_record_execution "add ZFS pool ${pool_name} as Proxmox storage ${storage_id}" \
|
||||
"pvesm add zfspool ${storage_id} --pool ${pool_name} --content ${content}"
|
||||
if pvesm_output=$(pvesm add zfspool "$storage_id" \
|
||||
--pool "$pool_name" \
|
||||
--content "$content" 2>&1); then
|
||||
add_ok=true
|
||||
fi
|
||||
else
|
||||
pmx_record_execution "add directory ${path} as Proxmox storage ${storage_id}" \
|
||||
"pvesm add dir ${storage_id} --path ${path} --content ${content}"
|
||||
if pvesm_output=$(pvesm add dir "$storage_id" \
|
||||
--path "$path" \
|
||||
--content "$content" 2>&1); then
|
||||
@@ -1048,7 +1036,6 @@ _remove_pvesm_storage() {
|
||||
|
||||
# Step 1: Remove from Proxmox
|
||||
msg_info "$(translate "Removing storage from Proxmox...")"
|
||||
pmx_record_execution "remove Proxmox storage ${storage_id}" "pvesm remove ${storage_id}"
|
||||
if ! pvesm remove "$storage_id" 2>/dev/null; then
|
||||
msg_error "$(translate "Failed to remove storage from Proxmox.")"
|
||||
echo ""
|
||||
@@ -1061,7 +1048,6 @@ _remove_pvesm_storage() {
|
||||
# Step 2: Unmount if mounted (dir-backed storages only)
|
||||
if [[ -n "$path" ]] && mountpoint -q "$path" 2>/dev/null; then
|
||||
msg_info "$(translate "Unmounting disk...")"
|
||||
pmx_record_execution "unmount disk from ${path}" "umount ${path}"
|
||||
if umount "$path" 2>/dev/null; then
|
||||
msg_ok "$(translate "Disk unmounted from") $path"
|
||||
else
|
||||
@@ -1088,7 +1074,6 @@ _remove_pvesm_storage() {
|
||||
# Step 3b: Export ZFS pool if applicable
|
||||
if [[ -n "$pool" ]] && zpool list "$pool" >/dev/null 2>&1; then
|
||||
msg_info "$(translate "Exporting ZFS pool...") $pool"
|
||||
pmx_record_execution "export ZFS pool ${pool}" "zpool export ${pool}"
|
||||
if zpool export "$pool" 2>/dev/null; then
|
||||
msg_ok "$(translate "ZFS pool exported:") $pool"
|
||||
else
|
||||
@@ -1105,7 +1090,6 @@ _remove_pvesm_storage() {
|
||||
read -r
|
||||
echo ""
|
||||
msg_warn "$(translate "Rebooting the system...")"
|
||||
pmx_record_execution "reboot host after removing storage ${storage_id}" "reboot"
|
||||
reboot
|
||||
else
|
||||
echo ""
|
||||
@@ -1161,7 +1145,6 @@ _remove_fstab_entry() {
|
||||
|
||||
if $mounted; then
|
||||
msg_info "$(translate "Unmounting") $mount_point..."
|
||||
pmx_record_execution "unmount disk from ${mount_point}" "umount ${mount_point}"
|
||||
if umount "$mount_point" 2>/dev/null; then
|
||||
msg_ok "$(translate "Unmounted successfully")"
|
||||
else
|
||||
|
||||
@@ -244,8 +244,6 @@ add_proxmox_iscsi_storage() {
|
||||
8 60 --title "$(translate "Storage Exists")"; then
|
||||
return 0
|
||||
fi
|
||||
pmx_record_execution "remove existing Proxmox iSCSI storage ${storage_id}" \
|
||||
"pvesm remove ${storage_id}"
|
||||
pvesm remove "$storage_id" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
@@ -253,8 +251,6 @@ add_proxmox_iscsi_storage() {
|
||||
msg_info "$(translate "Adding iSCSI storage to Proxmox...")"
|
||||
|
||||
local pvesm_output pvesm_result
|
||||
pmx_record_execution "add iSCSI target ${target} as Proxmox storage ${storage_id}" \
|
||||
"pvesm add iscsi ${storage_id} --portal ${portal} --target ${target} --content ${content}"
|
||||
pvesm_output=$(pvesm add iscsi "$storage_id" \
|
||||
--portal "$portal" \
|
||||
--target "$target" \
|
||||
@@ -418,7 +414,6 @@ remove_iscsi_storage() {
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Remove iSCSI Storage")"
|
||||
|
||||
pmx_record_execution "remove Proxmox iSCSI storage ${SELECTED}" "pvesm remove ${SELECTED}"
|
||||
if pvesm remove "$SELECTED" 2>/dev/null; then
|
||||
msg_ok "$(translate "Storage") $SELECTED $(translate "removed successfully from Proxmox.")"
|
||||
else
|
||||
|
||||
@@ -42,10 +42,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
|
||||
|
||||
SHARE_COMMON_FILE="$LOCAL_SCRIPTS/global/share-common.func"
|
||||
if ! source "$SHARE_COMMON_FILE" 2>/dev/null; then
|
||||
msg_error "$(translate "Could not load shared functions. Script cannot continue.")"
|
||||
@@ -68,14 +64,9 @@ fi
|
||||
|
||||
lsm_apply_multi_unpriv_permissions() {
|
||||
local dir="$1"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "lsm_apply_multi_unpriv_permissions" "$FUNC_VERSION"
|
||||
|
||||
[[ -z "$dir" || ! -d "$dir" ]] && return 1
|
||||
|
||||
pmx_record_execution "apply shared LXC permission profile to ${dir}" \
|
||||
"chown root:root; chmod 1777; chmod -R a+rwX; apply default ACLs when available"
|
||||
|
||||
# root:root ownership — no new group needed.
|
||||
chown root:root "$dir" 2>/dev/null || true
|
||||
|
||||
@@ -233,9 +224,6 @@ lsm_select_host_mount_point_dialog() {
|
||||
}
|
||||
|
||||
create_shared_directory() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "create_shared_directory" "$FUNC_VERSION"
|
||||
|
||||
lsm_select_host_mount_point_dialog "$(translate "Select Shared Directory Location")" "shared"
|
||||
[[ -z "$LSM_SELECTED_MOUNT_POINT" ]] && return
|
||||
SHARED_DIR="$LSM_SELECTED_MOUNT_POINT"
|
||||
@@ -243,7 +231,6 @@ create_shared_directory() {
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Create Shared Directory")"
|
||||
|
||||
pmx_record_execution "create shared directory ${SHARED_DIR}" "mkdir -p ${SHARED_DIR}"
|
||||
if ! mkdir -p "$SHARED_DIR" 2>/dev/null; then
|
||||
msg_error "$(translate "Failed to create directory:") $SHARED_DIR"
|
||||
echo ""
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
BASE_DIR="/usr/local/share/proxmenux"
|
||||
source "$BASE_DIR/utils.sh"
|
||||
|
||||
if [[ -f "/usr/local/share/proxmenux/scripts/global/pmx_journal.sh" ]]; then
|
||||
source "/usr/local/share/proxmenux/scripts/global/pmx_journal.sh"
|
||||
fi
|
||||
|
||||
load_language
|
||||
initialize_cache
|
||||
|
||||
@@ -293,8 +289,6 @@ select_lxc_container() {
|
||||
select_container_mount_point() {
|
||||
local ctid="$1"
|
||||
local host_dir="$2"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "select_container_mount_point" "$FUNC_VERSION"
|
||||
local base_name
|
||||
base_name=$(basename "$host_dir")
|
||||
|
||||
@@ -339,8 +333,6 @@ select_container_mount_point() {
|
||||
local ct_status
|
||||
ct_status=$(pct status "$ctid" 2>/dev/null | awk '{print $2}')
|
||||
if [[ "$ct_status" == "running" ]]; then
|
||||
pmx_record_execution "create mount directory ${mount_point} in CT ${ctid}" \
|
||||
"pct exec ${ctid} -- mkdir -p ${mount_point}"
|
||||
pct exec "$ctid" -- mkdir -p "$mount_point" 2>/dev/null
|
||||
fi
|
||||
|
||||
@@ -375,8 +367,6 @@ add_bind_mount() {
|
||||
local ctid="$1"
|
||||
local host_path="$2"
|
||||
local ct_path="$3"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "add_bind_mount" "$FUNC_VERSION"
|
||||
|
||||
if [[ ! "$ctid" =~ ^[0-9]+$ || -z "$host_path" || -z "$ct_path" ]]; then
|
||||
msg_error "$(translate "Invalid parameters for bind mount")"
|
||||
@@ -393,8 +383,6 @@ add_bind_mount() {
|
||||
mpidx=$(get_next_mp_index "$ctid")
|
||||
|
||||
local result
|
||||
pmx_record_execution "add bind mount ${host_path} to CT ${ctid} at ${ct_path}" \
|
||||
"pct set ${ctid} -mp${mpidx} ${host_path},mp=${ct_path},shared=1,backup=0"
|
||||
result=$(pct set "$ctid" -mp${mpidx} "$host_path,mp=$ct_path,shared=1,backup=0" 2>&1)
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
@@ -463,9 +451,6 @@ view_mount_points() {
|
||||
}
|
||||
|
||||
remove_mount_point() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "remove_mount_point" "$FUNC_VERSION"
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Remove LXC Mount Point")"
|
||||
|
||||
@@ -547,8 +532,6 @@ $(translate "Proceed with removal")?"
|
||||
msg_title "$(translate "Remove LXC Mount Point")"
|
||||
msg_info "$(translate "Removing mount point") $selected_mp $(translate "from container") $container_id..."
|
||||
|
||||
pmx_record_execution "remove mount point ${selected_mp} from CT ${container_id}" \
|
||||
"pct set ${container_id} --delete ${selected_mp}"
|
||||
if pct set "$container_id" --delete "$selected_mp" 2>/dev/null; then
|
||||
msg_ok "$(translate "Mount point removed successfully")"
|
||||
|
||||
@@ -558,8 +541,6 @@ $(translate "Proceed with removal")?"
|
||||
echo ""
|
||||
if whiptail --yesno "$(translate "Container is running. Restart to apply changes?")" 8 60; then
|
||||
msg_info "$(translate "Restarting container...")"
|
||||
pmx_record_execution "restart CT ${container_id} after removing ${selected_mp}" \
|
||||
"pct reboot ${container_id}"
|
||||
if pct reboot "$container_id"; then
|
||||
sleep 3
|
||||
msg_ok "$(translate "Container restarted successfully")"
|
||||
@@ -592,8 +573,6 @@ $(translate "Proceed with removal")?"
|
||||
lmm_fix_cifs_access() {
|
||||
local host_dir="$1"
|
||||
local is_unprivileged="$2"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "lmm_fix_cifs_access" "$FUNC_VERSION"
|
||||
|
||||
# CIFS mounted by Proxmox GUI uses uid=0/gid=0 by default (root only).
|
||||
# The fix: remount with uid/gid that the LXC can access.
|
||||
@@ -641,16 +620,13 @@ $(translate "Apply fix now? (The share will be briefly remounted)")" \
|
||||
18 84 3>&1 1>&2 2>&3; then
|
||||
|
||||
msg_info "$(translate "Remounting CIFS share with open permissions...")"
|
||||
pmx_record_execution "remount CIFS share ${mount_src} at ${host_dir}" \
|
||||
"umount ${host_dir}; mount -t cifs ${mount_src} ${host_dir} -o ${new_opts}"
|
||||
if umount "$host_dir" 2>/dev/null && \
|
||||
mount -t cifs "$mount_src" "$host_dir" -o "$new_opts" 2>/dev/null; then
|
||||
msg_ok "$(translate "CIFS share remounted — LXC containers can now read and write")"
|
||||
|
||||
# Update fstab if the mount is there
|
||||
if grep -qF "$host_dir" /etc/fstab 2>/dev/null; then
|
||||
pmx_edit_file /etc/fstab \
|
||||
"s|^\(${mount_src}[[:space:]].*${host_dir}.*cifs[[:space:]]\).*|\1${new_opts} 0 0|" 2>/dev/null || true
|
||||
sed -i "s|^\(${mount_src}[[:space:]].*${host_dir}.*cifs[[:space:]]\).*|\1${new_opts} 0 0|" /etc/fstab 2>/dev/null || true
|
||||
msg_ok "$(translate "/etc/fstab updated — permissions will persist after reboot")"
|
||||
fi
|
||||
else
|
||||
@@ -663,8 +639,6 @@ lmm_fix_nfs_access() {
|
||||
local host_dir="$1"
|
||||
local is_unprivileged="$2"
|
||||
local uid_shift="${3:-100000}"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "lmm_fix_nfs_access" "$FUNC_VERSION"
|
||||
|
||||
# NFS: the host cannot override server-side permissions.
|
||||
# BUT: if the server exports with root_squash (default), we can check
|
||||
@@ -704,8 +678,6 @@ $(translate "If it still fails, the NFS server export options must be changed on
|
||||
$(translate "Apply fix now?")" \
|
||||
18 84 3>&1 1>&2 2>&3; then
|
||||
|
||||
pmx_record_execution "apply LXC access permissions to NFS directory ${host_dir}" \
|
||||
"chmod 1777 and setfacl on ${host_dir}"
|
||||
if chmod 1777 "$host_dir" 2>/dev/null; then
|
||||
msg_ok "$(translate "NFS directory permissions set — containers should now be able to write")"
|
||||
else
|
||||
@@ -744,8 +716,6 @@ $(translate "You can still mount this share for READ-ONLY access.")" \
|
||||
lmm_offer_host_permissions() {
|
||||
local host_dir="$1"
|
||||
local is_unprivileged="$2"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "lmm_offer_host_permissions" "$FUNC_VERSION"
|
||||
|
||||
# Privileged containers: UID 0 inside = UID 0 on host — always accessible
|
||||
[[ "$is_unprivileged" != "1" ]] && return 0
|
||||
@@ -779,8 +749,6 @@ $(translate "Apply read+write access for 'others' on the host directory?")\n\n\
|
||||
$(translate "(Only the host directory is modified. Nothing inside the container is changed.")" \
|
||||
16 80 3>&1 1>&2 2>&3; then
|
||||
|
||||
pmx_record_execution "grant mapped LXC users access to host directory ${host_dir}" \
|
||||
"chmod o+rwx and setfacl on ${host_dir}"
|
||||
chmod o+rwx "$host_dir" 2>/dev/null || true
|
||||
if command -v setfacl >/dev/null 2>&1; then
|
||||
setfacl -m o::rwx "$host_dir" 2>/dev/null || true
|
||||
@@ -830,8 +798,6 @@ _lmm_verify_writable() {
|
||||
# ==========================================================
|
||||
|
||||
mount_host_directory_minimal() {
|
||||
local FUNC_VERSION="1.0"
|
||||
|
||||
# Step 1: Select container
|
||||
local container_id
|
||||
container_id=$(select_lxc_container)
|
||||
@@ -934,13 +900,10 @@ $(translate "Proceed")?"
|
||||
# bind-mount is supposed to spare them.
|
||||
local ct_status
|
||||
ct_status=$(pct status "$container_id" 2>/dev/null | awk '{print $2}')
|
||||
pmx_journal_context "mount_host_directory_minimal" "$FUNC_VERSION"
|
||||
echo ""
|
||||
if [[ "$ct_status" == "running" ]]; then
|
||||
if whiptail --yesno "$(translate "Restart container to activate mount?")" 8 60; then
|
||||
msg_info "$(translate "Restarting container...")"
|
||||
pmx_record_execution "restart CT ${container_id} to activate bind mount" \
|
||||
"pct reboot ${container_id}"
|
||||
if pct reboot "$container_id"; then
|
||||
sleep 5
|
||||
msg_ok "$(translate "Container restarted successfully")"
|
||||
@@ -955,8 +918,6 @@ $(translate "Proceed")?"
|
||||
# declines, fall back to the informational line.
|
||||
if whiptail --yesno "$(translate "Container is stopped. Start it now to verify the mount works?")" 8 70; then
|
||||
msg_info "$(translate "Starting container...")"
|
||||
pmx_record_execution "start CT ${container_id} to activate and verify bind mount" \
|
||||
"pct start ${container_id}"
|
||||
if pct start "$container_id"; then
|
||||
sleep 5
|
||||
msg_ok "$(translate "Container started successfully")"
|
||||
|
||||
@@ -71,8 +71,6 @@ install_nfs_client() {
|
||||
fi
|
||||
|
||||
msg_info "$(translate "Installing NFS client packages...")"
|
||||
pmx_record_execution "install NFS client packages in CT ${CTID}" \
|
||||
"pct exec ${CTID} -- apt-get update and apt-get install -y nfs-common"
|
||||
if ! pct exec "$CTID" -- apt-get update >/dev/null 2>&1; then
|
||||
msg_error "$(translate "Failed to update package list.")"
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
@@ -408,8 +406,6 @@ mount_nfs_share() {
|
||||
configure_mount_options || return
|
||||
|
||||
pmx_journal_context "mount_nfs_share" "$FUNC_VERSION"
|
||||
pmx_record_execution "mount NFS export ${NFS_SERVER}:${NFS_EXPORT} in CT ${CTID} at ${MOUNT_POINT}" \
|
||||
"pct exec ${CTID} -- mount NFS; persistent=${PERMANENT_MOUNT}"
|
||||
|
||||
|
||||
if ! pct exec "$CTID" -- test -d "$MOUNT_POINT"; then
|
||||
@@ -585,8 +581,6 @@ unmount_nfs_share() {
|
||||
msg_title "$(translate "Unmount NFS Share")"
|
||||
|
||||
# Remove from fstab
|
||||
pmx_record_execution "remove NFS mount ${SELECTED_MOUNT} from CT ${CTID}" \
|
||||
"remove CT fstab entry and unmount ${SELECTED_MOUNT}"
|
||||
pct exec "$CTID" -- sed --in-place "\|[[:space:]]$SELECTED_MOUNT[[:space:]]|d" /etc/fstab
|
||||
msg_ok "$(translate "Removed from /etc/fstab.")"
|
||||
|
||||
@@ -643,8 +637,6 @@ test_nfs_connectivity() {
|
||||
else
|
||||
echo "$(translate "RPC Bind Service: STOPPED")"
|
||||
msg_warn "$(translate "Starting rpcbind service...")"
|
||||
pmx_record_execution "start rpcbind in CT ${CTID}" \
|
||||
"pct exec ${CTID} -- systemctl start rpcbind"
|
||||
pct exec "$CTID" -- systemctl start rpcbind 2>/dev/null || true
|
||||
fi
|
||||
|
||||
|
||||
@@ -276,15 +276,11 @@ add_proxmox_nfs_storage() {
|
||||
8 60 --title "$(translate "Storage Exists")"; then
|
||||
return 0
|
||||
fi
|
||||
pmx_record_execution "remove existing Proxmox NFS storage ${storage_id}" \
|
||||
"pvesm remove ${storage_id}"
|
||||
pvesm remove "$storage_id" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
msg_ok "$(translate "Storage ID is available")"
|
||||
msg_info "$(translate "NFS storage adding in progress...")"
|
||||
pmx_record_execution "add NFS export ${server}:${export} as Proxmox storage ${storage_id}" \
|
||||
"pvesm add nfs ${storage_id} --server ${server} --export ${export} --content ${content}"
|
||||
if pvesm_output=$(pvesm add nfs "$storage_id" \
|
||||
--server "$server" \
|
||||
--export "$export" \
|
||||
@@ -411,8 +407,6 @@ mount_nfs_via_fstab() {
|
||||
msg_ok "$(translate "Mount point ready:") $mount_path"
|
||||
|
||||
msg_info "$(translate "Mounting NFS share...")"
|
||||
pmx_record_execution "mount NFS export ${server}:${export_path} at ${mount_path}" \
|
||||
"mount -t nfs -o ${mount_opts} ${server}:${export_path} ${mount_path}"
|
||||
if ! mount -t nfs -o "$mount_opts" "${server}:${export_path}" "$mount_path" >/dev/null 2>&1; then
|
||||
msg_error "$(translate "Failed to mount NFS share on host.")"
|
||||
return 1
|
||||
@@ -440,7 +434,6 @@ mount_nfs_via_fstab() {
|
||||
echo "${server}:${export_path} $mount_path nfs $mount_opts 0 0" | pmx_append_file /etc/fstab
|
||||
msg_ok "$(translate "Added to /etc/fstab.")"
|
||||
|
||||
pmx_record_execution "reload systemd units after NFS fstab update" "systemctl daemon-reload"
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
echo -e ""
|
||||
@@ -742,7 +735,6 @@ remove_nfs_storage() {
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Remove NFS Storage")"
|
||||
|
||||
pmx_record_execution "remove Proxmox NFS storage ${target}" "pvesm remove ${target}"
|
||||
if pvesm remove "$target" 2>/dev/null; then
|
||||
msg_ok "$(translate "Storage") $target $(translate "removed successfully from Proxmox.")"
|
||||
else
|
||||
@@ -767,7 +759,6 @@ remove_nfs_storage() {
|
||||
|
||||
# Try umount only if currently mounted; never force.
|
||||
if mount | grep -q " on ${mount_path} type "; then
|
||||
pmx_record_execution "unmount NFS path ${mount_path}" "umount ${mount_path}"
|
||||
if umount "$mount_path" 2>/dev/null; then
|
||||
msg_ok "$(translate "Unmounted:") $mount_path"
|
||||
else
|
||||
@@ -789,7 +780,6 @@ remove_nfs_storage() {
|
||||
msg_error "$(translate "Failed to edit /etc/fstab — remove the line manually.")"
|
||||
fi
|
||||
|
||||
pmx_record_execution "reload systemd units after NFS fstab removal" "systemctl daemon-reload"
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
# Try to remove the directory if empty; keep it otherwise.
|
||||
|
||||
@@ -31,10 +31,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 shared functions
|
||||
SHARE_COMMON_FILE="$LOCAL_SCRIPTS/global/share-common.func"
|
||||
if ! source "$SHARE_COMMON_FILE" 2>/dev/null; then
|
||||
@@ -53,10 +49,6 @@ select_privileged_lxc
|
||||
|
||||
setup_universal_sharedfiles_group() {
|
||||
local ctid="$1"
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "setup_universal_sharedfiles_group" "$FUNC_VERSION"
|
||||
pmx_record_execution "configure sharedfiles group and UID mappings in CT ${ctid}" \
|
||||
"pct exec ${ctid} -- manage sharedfiles group, memberships and remapped users"
|
||||
|
||||
msg_info "$(translate "Setting sharedfiles group with UID remapping...")"
|
||||
|
||||
@@ -143,9 +135,6 @@ setup_universal_sharedfiles_group() {
|
||||
|
||||
|
||||
select_mount_point() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "select_mount_point" "$FUNC_VERSION"
|
||||
|
||||
while true; do
|
||||
METHOD=$(whiptail --backtitle "ProxMenux" --title "$(translate "Select Folder")" \
|
||||
--menu "$(translate "How do you want to select the folder to export?")" 15 60 5 \
|
||||
@@ -192,8 +181,6 @@ select_mount_point() {
|
||||
--msgbox "$(translate "No mount point was specified.")" 8 50
|
||||
continue
|
||||
fi
|
||||
pmx_record_execution "create NFS export directory ${MOUNT_POINT} in CT ${CTID}" \
|
||||
"pct exec ${CTID} -- mkdir -p ${MOUNT_POINT}"
|
||||
pct exec "$CTID" -- mkdir -p "$MOUNT_POINT" 2>/dev/null
|
||||
return 0
|
||||
;;
|
||||
@@ -265,7 +252,6 @@ select_export_options() {
|
||||
|
||||
|
||||
create_nfs_export() {
|
||||
local FUNC_VERSION="1.0"
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Create LXC server NFS")"
|
||||
@@ -276,10 +262,6 @@ create_nfs_export() {
|
||||
get_network_config || return
|
||||
select_export_options || return
|
||||
|
||||
pmx_journal_context "create_nfs_export" "$FUNC_VERSION"
|
||||
pmx_record_execution "configure NFS export ${MOUNT_POINT} in CT ${CTID}" \
|
||||
"install and enable NFS services, update /etc/exports and reload exports"
|
||||
|
||||
|
||||
msg_ok "$(translate "Directory successfully.")"
|
||||
|
||||
@@ -287,7 +269,7 @@ create_nfs_export() {
|
||||
if ! pct exec "$CTID" -- dpkg -s nfs-kernel-server &>/dev/null; then
|
||||
msg_info "$(translate "Installing NFS server packages inside the CT...")"
|
||||
pct exec "$CTID" -- bash -c "apt-get update && apt-get install -y nfs-kernel-server nfs-common rpcbind"
|
||||
pct exec "$CTID" -- systemctl --now enable rpcbind nfs-kernel-server
|
||||
pct exec "$CTID" -- systemctl enable --now rpcbind nfs-kernel-server
|
||||
msg_ok "$(translate "NFS server installed successfully.")"
|
||||
else
|
||||
msg_ok "$(translate "NFS server is already installed.")"
|
||||
@@ -314,8 +296,8 @@ create_nfs_export() {
|
||||
if pct exec "$CTID" -- grep -q "^$MOUNT_POINT " /etc/exports; then
|
||||
if dialog --yesno "$(translate "Do you want to update the existing export?")" \
|
||||
10 60 --title "$(translate "Update Export")"; then
|
||||
pct exec "$CTID" -- sed --in-place "\|^$MOUNT_POINT |d" /etc/exports
|
||||
pct exec "$CTID" -- bash -c "printf '%s\\n' '$EXPORT_LINE' | tee -a /etc/exports >/dev/null"
|
||||
pct exec "$CTID" -- sed -i "\|^$MOUNT_POINT |d" /etc/exports
|
||||
pct exec "$CTID" -- bash -c "echo '$EXPORT_LINE' >> /etc/exports"
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Create LXC server NFS")"
|
||||
msg_ok "$(translate "Directory successfully.")"
|
||||
@@ -325,7 +307,7 @@ create_nfs_export() {
|
||||
|
||||
fi
|
||||
else
|
||||
pct exec "$CTID" -- bash -c "printf '%s\\n' '$EXPORT_LINE' | tee -a /etc/exports >/dev/null"
|
||||
pct exec "$CTID" -- bash -c "echo '$EXPORT_LINE' >> /etc/exports"
|
||||
msg_ok "$(translate "Export added successfully.")"
|
||||
fi
|
||||
|
||||
@@ -423,9 +405,6 @@ view_exports() {
|
||||
}
|
||||
|
||||
delete_export() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "delete_export" "$FUNC_VERSION"
|
||||
|
||||
if ! pct exec "$CTID" -- test -f /etc/exports; then
|
||||
dialog --title "$(translate "Error")" --msgbox "\n$(translate "No exports file found.")" 8 50
|
||||
return
|
||||
@@ -456,9 +435,7 @@ delete_export() {
|
||||
if whiptail --yesno "$(translate "Are you sure you want to delete this export?")\n\n$EXPORT_LINE" 10 70 --title "$(translate "Confirm Deletion")"; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Delete Export")"
|
||||
pmx_record_execution "remove NFS export line ${SELECTED_NUM} from CT ${CTID}" \
|
||||
"edit /etc/exports and restart nfs-kernel-server"
|
||||
pct exec "$CTID" -- sed --in-place "${SELECTED_NUM}d" /etc/exports
|
||||
pct exec "$CTID" -- sed -i "${SELECTED_NUM}d" /etc/exports
|
||||
pct exec "$CTID" -- exportfs -ra
|
||||
pct exec "$CTID" -- systemctl restart nfs-kernel-server
|
||||
msg_ok "$(translate "Export deleted and NFS service restarted.")"
|
||||
@@ -529,9 +506,6 @@ check_nfs_status() {
|
||||
}
|
||||
|
||||
uninstall_nfs() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "uninstall_nfs" "$FUNC_VERSION"
|
||||
|
||||
if ! pct exec "$CTID" -- dpkg -s nfs-kernel-server &>/dev/null; then
|
||||
dialog --title "$(translate "NFS Not Installed")" --msgbox "\n$(translate "NFS server is not installed in this CT.")" 8 60
|
||||
return
|
||||
@@ -545,8 +519,6 @@ uninstall_nfs() {
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Uninstall NFS Server")"
|
||||
pmx_record_execution "uninstall NFS server from CT ${CTID}" \
|
||||
"stop and disable NFS services, clear exports, remove users, groups and packages"
|
||||
|
||||
msg_info "$(translate "Stopping NFS services...")"
|
||||
pct exec "$CTID" -- systemctl stop nfs-kernel-server 2>/dev/null || true
|
||||
|
||||
@@ -55,8 +55,6 @@ select_privileged_lxc
|
||||
install_samba_client() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "install_samba_client" "$FUNC_VERSION"
|
||||
pmx_record_execution "install and prepare Samba client in CT ${CTID}" \
|
||||
"pct exec ${CTID} -- install cifs-utils and smbclient; create ${CREDENTIALS_DIR}"
|
||||
|
||||
if pct exec "$CTID" -- dpkg -s cifs-utils &>/dev/null && pct exec "$CTID" -- dpkg -s smbclient &>/dev/null; then
|
||||
pct exec "$CTID" -- mkdir -p "$CREDENTIALS_DIR"
|
||||
@@ -699,8 +697,6 @@ create_credentials_file() {
|
||||
|
||||
CRED_FILE="$CREDENTIALS_DIR/${SAMBA_SERVER}_${SAMBA_SHARE}.cred"
|
||||
|
||||
pmx_record_execution "create Samba credentials file ${CRED_FILE} in CT ${CTID}" \
|
||||
"pct exec ${CTID} -- write credentials file and chmod 600"
|
||||
|
||||
pct exec "$CTID" -- bash -c "cat > '$CRED_FILE' << EOF
|
||||
username=$USERNAME
|
||||
@@ -773,8 +769,6 @@ mount_samba_share() {
|
||||
configure_mount_options || return
|
||||
|
||||
pmx_journal_context "mount_samba_share" "$FUNC_VERSION"
|
||||
pmx_record_execution "mount Samba share //${SAMBA_SERVER}/${SAMBA_SHARE} in CT ${CTID} at ${MOUNT_POINT}" \
|
||||
"pct exec ${CTID} -- mount CIFS share; persistent=${PERMANENT_MOUNT}"
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Installing Samba Client in LXC")"
|
||||
@@ -978,8 +972,6 @@ unmount_samba_share() {
|
||||
msg_title "$(translate "Unmount Samba Share")"
|
||||
|
||||
CRED_FILE=$(pct exec "$CTID" -- grep -E "\s+$SELECTED_MOUNT\s+" /etc/fstab 2>/dev/null | grep -o "credentials=[^, ]*" | cut -d= -f2 || true)
|
||||
pmx_record_execution "remove Samba mount ${SELECTED_MOUNT} from CT ${CTID}" \
|
||||
"remove CT fstab entry and credentials file when present"
|
||||
pct exec "$CTID" -- sed --in-place "\|[[:space:]]$SELECTED_MOUNT[[:space:]]|d" /etc/fstab
|
||||
msg_ok "$(translate "Removed from /etc/fstab.")"
|
||||
|
||||
|
||||
@@ -297,8 +297,6 @@ add_proxmox_cifs_storage() {
|
||||
8 60 --title "$(translate "Storage Exists")"; then
|
||||
return 0
|
||||
fi
|
||||
pmx_record_execution "remove Proxmox CIFS storage ${storage_id}" \
|
||||
"pvesm remove ${storage_id}"
|
||||
pvesm remove "$storage_id" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
@@ -306,8 +304,6 @@ add_proxmox_cifs_storage() {
|
||||
msg_info "$(translate "Adding CIFS storage to Proxmox...")"
|
||||
|
||||
local pvesm_result pvesm_output
|
||||
pmx_record_execution "add Proxmox CIFS storage ${storage_id}" \
|
||||
"pvesm add cifs ${storage_id} --server ${server} --share ${share} --content ${content}"
|
||||
if [[ "$USE_GUEST" == "true" ]]; then
|
||||
pvesm_output=$(pvesm add cifs "$storage_id" \
|
||||
--server "$server" \
|
||||
@@ -435,8 +431,6 @@ write_host_credentials_file() {
|
||||
return 0
|
||||
fi
|
||||
local creds_dir="/etc/samba/credentials"
|
||||
pmx_record_execution "create Samba credentials directory ${creds_dir}" \
|
||||
"mkdir -p ${creds_dir}; chmod 0700 ${creds_dir}"
|
||||
mkdir -p "$creds_dir"
|
||||
chmod 0700 "$creds_dir"
|
||||
HOST_CRED_FILE="${creds_dir}/$(echo "${SAMBA_SERVER}_${SAMBA_SHARE}" | tr -c 'A-Za-z0-9._-' '_').cred"
|
||||
@@ -464,8 +458,6 @@ mount_cifs_via_fstab() {
|
||||
msg_info "$(translate "Preparing host mount...")"
|
||||
|
||||
if [[ ! -d "$mount_path" ]]; then
|
||||
pmx_record_execution "create CIFS mount point ${mount_path}" \
|
||||
"mkdir -p ${mount_path}"
|
||||
if ! mkdir -p "$mount_path" 2>/dev/null; then
|
||||
msg_error "$(translate "Failed to create mount point:") $mount_path"
|
||||
return 1
|
||||
@@ -481,8 +473,6 @@ mount_cifs_via_fstab() {
|
||||
fi
|
||||
|
||||
msg_info "$(translate "Mounting CIFS share...")"
|
||||
pmx_record_execution "mount CIFS share //${server}/${share} at ${mount_path}" \
|
||||
"mount -t cifs //${server}/${share} ${mount_path}"
|
||||
if ! mount -t cifs -o "$mount_opts" "//${server}/${share}" "$mount_path" >/dev/null 2>&1; then
|
||||
msg_error "$(translate "Failed to mount CIFS share on host.")"
|
||||
return 1
|
||||
@@ -503,7 +493,6 @@ mount_cifs_via_fstab() {
|
||||
echo "//${server}/${share} $mount_path cifs $mount_opts 0 0" | pmx_append_file /etc/fstab
|
||||
msg_ok "$(translate "Added to /etc/fstab.")"
|
||||
|
||||
pmx_record_execution "reload systemd after CIFS fstab update" "systemctl daemon-reload"
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
echo -e ""
|
||||
@@ -815,8 +804,6 @@ remove_cifs_storage() {
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Remove CIFS Storage")"
|
||||
|
||||
pmx_record_execution "remove Proxmox CIFS storage ${target}" \
|
||||
"pvesm remove ${target}"
|
||||
if pvesm remove "$target" 2>/dev/null; then
|
||||
msg_ok "$(translate "Storage") $target $(translate "removed successfully from Proxmox.")"
|
||||
else
|
||||
@@ -850,8 +837,6 @@ remove_cifs_storage() {
|
||||
msg_title "$(translate "Remove CIFS fstab Mount")"
|
||||
|
||||
if mount | grep -q " on ${mount_path} type "; then
|
||||
pmx_record_execution "unmount CIFS path ${mount_path}" \
|
||||
"umount ${mount_path}"
|
||||
if umount "$mount_path" 2>/dev/null; then
|
||||
msg_ok "$(translate "Unmounted:") $mount_path"
|
||||
else
|
||||
@@ -872,7 +857,6 @@ remove_cifs_storage() {
|
||||
msg_error "$(translate "Failed to edit /etc/fstab — remove the line manually.")"
|
||||
fi
|
||||
|
||||
pmx_record_execution "reload systemd after CIFS fstab removal" "systemctl daemon-reload"
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
# Remove credentials file if it's under the standard ProxMenux dir
|
||||
|
||||
@@ -32,10 +32,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
|
||||
|
||||
|
||||
SHARE_COMMON_FILE="$LOCAL_SCRIPTS/global/share-common.func"
|
||||
if ! source "$SHARE_COMMON_FILE" 2>/dev/null; then
|
||||
@@ -52,9 +48,6 @@ select_privileged_lxc
|
||||
|
||||
|
||||
select_mount_point() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "select_mount_point" "$FUNC_VERSION"
|
||||
|
||||
while true; do
|
||||
METHOD=$(whiptail --backtitle "ProxMenux" --title "$(translate "Select Folder")" \
|
||||
--menu "$(translate "How do you want to select the folder to share?")" 15 60 5 \
|
||||
@@ -111,16 +104,12 @@ select_mount_point() {
|
||||
|
||||
|
||||
create_share() {
|
||||
local FUNC_VERSION="1.0"
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Create Samba server service")"
|
||||
sleep 2
|
||||
|
||||
select_mount_point || return
|
||||
pmx_journal_context "create_share" "$FUNC_VERSION"
|
||||
pmx_record_execution "configure Samba share ${MOUNT_POINT} in CT ${CTID}" \
|
||||
"pct exec ${CTID} -- install and configure Samba share ${MOUNT_POINT}"
|
||||
|
||||
|
||||
if ! pct exec "$CTID" -- test -d "$MOUNT_POINT"; then
|
||||
@@ -322,7 +311,7 @@ EOF
|
||||
msg_warn "$(translate "The share already exists in smb.conf:") [$SHARE_NAME]"
|
||||
if whiptail --yesno "$(translate "Do you want to update the existing share?")" 10 60 --title "$(translate "Update Share")"; then
|
||||
|
||||
pct exec "$CTID" -- sed --in-place "/^\[$SHARE_NAME\]/,/^$/d" /etc/samba/smb.conf
|
||||
pct exec "$CTID" -- sed -i "/^\[$SHARE_NAME\]/,/^$/d" /etc/samba/smb.conf
|
||||
pct exec "$CTID" -- bash -c "echo '$CONFIG' >> /etc/samba/smb.conf"
|
||||
msg_ok "$(translate "Share updated successfully.")"
|
||||
else
|
||||
@@ -417,9 +406,6 @@ view_shares() {
|
||||
|
||||
|
||||
delete_share() {
|
||||
local FUNC_VERSION="1.0"
|
||||
pmx_journal_context "delete_share" "$FUNC_VERSION"
|
||||
|
||||
if ! pct exec "$CTID" -- test -f /etc/samba/smb.conf; then
|
||||
dialog --backtitle "ProxMenux" --title "$(translate "Error")" --msgbox "\n$(translate "No smb.conf file found.")" 8 50
|
||||
return
|
||||
@@ -452,9 +438,7 @@ delete_share() {
|
||||
msg_title "$(translate "Delete Share")"
|
||||
|
||||
|
||||
pmx_record_execution "remove Samba share ${SELECTED_SHARE} from CT ${CTID}" \
|
||||
"pct exec ${CTID} -- remove share ${SELECTED_SHARE} from /etc/samba/smb.conf and restart smbd"
|
||||
pct exec "$CTID" -- sed --in-place "/^\[$SELECTED_SHARE\]/,/^$/d" /etc/samba/smb.conf
|
||||
pct exec "$CTID" -- sed -i "/^\[$SELECTED_SHARE\]/,/^$/d" /etc/samba/smb.conf
|
||||
pct exec "$CTID" -- systemctl restart smbd.service
|
||||
msg_ok "$(translate "Share deleted and Samba service restarted.")"
|
||||
fi
|
||||
@@ -511,7 +495,6 @@ check_samba_status() {
|
||||
|
||||
|
||||
uninstall_samba() {
|
||||
local FUNC_VERSION="1.0"
|
||||
|
||||
if ! pct exec "$CTID" -- dpkg -s samba &>/dev/null; then
|
||||
dialog --backtitle "ProxMenux" --title "$(translate "Samba Not Installed")" --msgbox "\n$(translate "Samba server is not installed in this CT.")" 8 60
|
||||
@@ -527,9 +510,6 @@ uninstall_samba() {
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Uninstall Samba Server")"
|
||||
pmx_journal_context "uninstall_samba" "$FUNC_VERSION"
|
||||
pmx_record_execution "uninstall Samba server from CT ${CTID}" \
|
||||
"pct exec ${CTID} -- stop services, preserve smb.conf backup, remove Samba users and packages"
|
||||
|
||||
|
||||
msg_info "$(translate "Stopping Samba services...")"
|
||||
|
||||
Reference in New Issue
Block a user