mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-05-14 21:15:01 +00:00
update beta ProxMenux 1.2.1.1-beta
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ==========================================================
|
||||
# ProxMenux - A menu-driven script for Proxmox VE management
|
||||
# ProxMenux - Storage & Share CLI Reference
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : (GPL-3.0) (https://github.com/MacRimi/ProxMenux/blob/main/LICENSE)
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.6
|
||||
# Last Updated: 07/04/2026
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Reference of the manual CLI commands behind the Storage &
|
||||
# Share Manager flows (NFS / Samba / iSCSI client and server,
|
||||
# bind mounts, Proxmox storage registration). Used as the
|
||||
# Help & Info entry of the Storage & Share menu.
|
||||
# ==========================================================
|
||||
|
||||
# Configuration ============================================
|
||||
|
||||
@@ -4,12 +4,24 @@
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Adds local SCSI/SATA/NVMe disks as Proxmox directory storage
|
||||
# (pvesm add dir) or ZFS pool storage (pvesm add zfspool).
|
||||
# The disk can be formatted (ext4/xfs/zfs) and registered in Proxmox.
|
||||
# Prepares a local SCSI / SATA / NVMe disk on the Proxmox host
|
||||
# and registers it as Proxmox storage — either as a directory
|
||||
# (pvesm add dir) or as a ZFS pool (pvesm add zfspool).
|
||||
#
|
||||
# Features:
|
||||
# - Safety filter hides root / swap / mounted / in-use disks
|
||||
# and disks already referenced by any VM/CT config.
|
||||
# - Format path: wipe + GPT + mkfs (ext4 / xfs / btrfs / zfs).
|
||||
# - Reuse path: mount an existing filesystem without touching
|
||||
# the data.
|
||||
# - UUID-based /etc/fstab entries with defaults,nofail.
|
||||
# - Content-type presets (VM Storage / Standard NAS / All / Custom).
|
||||
# - View, remove (with fstab cleanup) and list-disks helpers.
|
||||
# ==========================================================
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ==========================================================
|
||||
# ProxMenux - Shared Groups Manager
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Description : Manage host groups for shared directories
|
||||
# ==========================================================
|
||||
|
||||
# Configuration
|
||||
BASE_DIR="/usr/local/share/proxmenux"
|
||||
UTILS_FILE="$BASE_DIR/utils.sh"
|
||||
|
||||
if [[ -f "$UTILS_FILE" ]]; then
|
||||
source "$UTILS_FILE"
|
||||
fi
|
||||
|
||||
load_language
|
||||
initialize_cache
|
||||
|
||||
|
||||
pmx_list_groups() {
|
||||
local groups
|
||||
groups=$(getent group | awk -F: '$3 >= 1000 && $1 != "nogroup" && $1 !~ /^pve/ {print $1 ":" $3}')
|
||||
if [[ -z "$groups" ]]; then
|
||||
whiptail --title "$(translate "Groups")" --msgbox "$(translate "No user groups found.")" 8 60
|
||||
return
|
||||
fi
|
||||
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Existing Groups")"
|
||||
echo "$groups" | column -t -s: | while read -r name gid; do
|
||||
members=$(getent group "$name" | awk -F: '{print $4}')
|
||||
echo -e " • ${BL}$name${CL} (GID: $gid) -> ${YW}${members:-no members}${CL}"
|
||||
done
|
||||
echo ""
|
||||
msg_success "$(translate "Press Enter to continue...")"
|
||||
read -r
|
||||
}
|
||||
|
||||
|
||||
|
||||
pmx_create_group() {
|
||||
group_name=$(dialog --inputbox "$(translate "Enter new group name:")" 10 60 "sharedfiles-new" \
|
||||
--title "$(translate "New Group")" 3>&1 1>&2 2>&3) || return
|
||||
[[ -z "$group_name" ]] && return
|
||||
|
||||
if getent group "$group_name" >/dev/null; then
|
||||
dialog --title "$(translate "Error")" --msgbox "$(translate "Group already exists.")" 8 50
|
||||
return
|
||||
fi
|
||||
|
||||
if groupadd "$group_name"; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Create Group")"
|
||||
msg_ok "$(translate "Group created successfully:") $group_name"
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Create Group")"
|
||||
msg_error "$(translate "Failed to create group.")"
|
||||
fi
|
||||
|
||||
echo -e
|
||||
msg_success "$(translate "Press Enter to continue...")"
|
||||
read -r
|
||||
}
|
||||
|
||||
|
||||
|
||||
pmx_edit_group() {
|
||||
local groups group_name action
|
||||
|
||||
|
||||
groups=$(getent group | awk -F: '$3 >= 1000 && $1 != "nogroup" && $1 !~ /^pve/ {print $1}')
|
||||
|
||||
if [[ -z "$groups" ]]; then
|
||||
dialog --title "$(translate "Error")" --msgbox "$(translate "No groups available to edit.")" 8 50
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
local menu_options=""
|
||||
while read -r group; do
|
||||
if [[ -n "$group" ]]; then
|
||||
local gid=$(getent group "$group" | cut -d: -f3)
|
||||
menu_options="$menu_options $group \"GID:$gid\""
|
||||
fi
|
||||
done <<< "$groups"
|
||||
|
||||
|
||||
group_name=$(eval "dialog --title \"$(translate "Edit Group")\" --menu \
|
||||
\"$(translate "Select a group:")\" 20 60 10 \
|
||||
$menu_options 3>&1 1>&2 2>&3")
|
||||
|
||||
if [[ -z "$group_name" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
action=$(dialog --title "$(translate "Edit Group")" --menu \
|
||||
"$(translate "What do you want to edit in group:") $group_name" 15 60 3 \
|
||||
"rename" "$(translate "Rename group")" \
|
||||
"gid" "$(translate "Change GID")" \
|
||||
"users" "$(translate "Add/Remove users")" 3>&1 1>&2 2>&3)
|
||||
|
||||
if [[ -z "$action" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
rename)
|
||||
new_name=$(dialog --inputbox "$(translate "Enter new group name:")" 10 60 \
|
||||
"$group_name" --title "$(translate "Rename Group")" 3>&1 1>&2 2>&3)
|
||||
if [[ -n "$new_name" && "$new_name" != "$group_name" ]]; then
|
||||
if groupmod -n "$new_name" "$group_name" 2>/dev/null; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Rename Group")"
|
||||
msg_ok "$(translate "Group renamed to:") $new_name"
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Rename Group")"
|
||||
msg_error "$(translate "Failed to rename group")"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
gid)
|
||||
current_gid=$(getent group "$group_name" | cut -d: -f3)
|
||||
new_gid=$(dialog --inputbox "$(translate "Enter new GID:")" 10 60 \
|
||||
"$current_gid" --title "$(translate "Change GID")" 3>&1 1>&2 2>&3)
|
||||
if [[ -n "$new_gid" && "$new_gid" != "$current_gid" ]]; then
|
||||
if groupmod -g "$new_gid" "$group_name" 2>/dev/null; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Change GID")"
|
||||
msg_ok "$(translate "GID changed to:") $new_gid"
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Change GID")"
|
||||
msg_error "$(translate "Failed to change GID")"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
users)
|
||||
user_action=$(dialog --title "$(translate "User Management")" --menu \
|
||||
"$(translate "Choose an action for group:") $group_name" 15 60 2 \
|
||||
"add" "$(translate "Add user to group")" \
|
||||
"remove" "$(translate "Remove user from group")" 3>&1 1>&2 2>&3)
|
||||
|
||||
case "$user_action" in
|
||||
add)
|
||||
username=$(dialog --inputbox "$(translate "Enter username to add:")" 10 60 \
|
||||
--title "$(translate "Add User")" 3>&1 1>&2 2>&3)
|
||||
if [[ -n "$username" ]]; then
|
||||
if id "$username" >/dev/null 2>&1; then
|
||||
if usermod -aG "$group_name" "$username" 2>/dev/null; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Add User")"
|
||||
msg_ok "$(translate "User added:") $username"
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Add User")"
|
||||
msg_error "$(translate "Failed to add user")"
|
||||
fi
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Add User")"
|
||||
msg_error "$(translate "User does not exist:") $username"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
remove)
|
||||
members=$(getent group "$group_name" | awk -F: '{print $4}' | tr ',' ' ')
|
||||
if [[ -z "$members" ]]; then
|
||||
dialog --title "$(translate "Info")" --msgbox "$(translate "No users in this group.")" 8 50
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
local user_options=""
|
||||
for user in $members; do
|
||||
user_options="$user_options $user \"\""
|
||||
done
|
||||
|
||||
username=$(eval "dialog --title \"$(translate "Remove User")\" --menu \
|
||||
\"$(translate "Select user to remove:")\" 15 60 5 \
|
||||
$user_options 3>&1 1>&2 2>&3")
|
||||
|
||||
if [[ -n "$username" ]]; then
|
||||
if gpasswd -d "$username" "$group_name" 2>/dev/null; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Remove User")"
|
||||
msg_ok "$(translate "User removed:") $username"
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Remove User")"
|
||||
msg_error "$(translate "Failed to remove user")"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
echo -e
|
||||
msg_success "$(translate "Press Enter to continue...")"
|
||||
read -r
|
||||
}
|
||||
|
||||
|
||||
|
||||
pmx_delete_group() {
|
||||
local groups group_name menu_options
|
||||
groups=$(getent group | awk -F: '$3 >= 1000 && $1 != "nogroup" && $1 !~ /^pve/ {print $1}')
|
||||
|
||||
if [[ -z "$groups" ]]; then
|
||||
dialog --title "$(translate "Error")" --msgbox "$(translate "No groups available to delete.")" 8 50
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
menu_options=""
|
||||
while read -r group; do
|
||||
if [[ -n "$group" ]]; then
|
||||
menu_options="$menu_options $group \"\""
|
||||
fi
|
||||
done <<< "$groups"
|
||||
|
||||
group_name=$(eval "dialog --title \"$(translate "Delete Group")\" --menu \
|
||||
\"$(translate "Select a group to delete:")\" 20 60 10 \
|
||||
$menu_options 3>&1 1>&2 2>&3") || return
|
||||
|
||||
if dialog --yesno "$(translate "Are you sure you want to delete group:") $group_name ?" 10 60; then
|
||||
if groupdel "$group_name" 2>/dev/null; then
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Deleting Groups")"
|
||||
msg_ok "$(translate "Group deleted:") $group_name"
|
||||
else
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Deleting Groups")"
|
||||
msg_ok "$(translate "Group deleted:") $group_name"
|
||||
msg_error "$(translate "Failed to delete group")"
|
||||
fi
|
||||
fi
|
||||
echo -e
|
||||
msg_success "$(translate "Press Enter to continue...")"
|
||||
read -r
|
||||
}
|
||||
|
||||
|
||||
pmx_manage_groups() {
|
||||
while true; do
|
||||
CHOICE=$(dialog --title "$(translate "Shared Groups Manager")" \
|
||||
--menu "$(translate "Select an option:")" 20 70 10 \
|
||||
"list" "$(translate "View existing groups")" \
|
||||
"create" "$(translate "Create new group")" \
|
||||
"edit" "$(translate "Edit existing group")" \
|
||||
"delete" "$(translate "Delete a group")" \
|
||||
"exit" "$(translate "Exit")" \
|
||||
3>&1 1>&2 2>&3) || return 0
|
||||
|
||||
case "$CHOICE" in
|
||||
list) pmx_list_groups ;;
|
||||
create) pmx_create_group ;;
|
||||
edit) pmx_edit_group ;;
|
||||
delete) pmx_delete_group ;;
|
||||
exit) return 0 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
pmx_manage_groups
|
||||
@@ -4,12 +4,22 @@
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Adds iSCSI targets as Proxmox storage (pvesm add iscsi).
|
||||
# Proxmox manages the connection natively via open-iscsi.
|
||||
# iSCSI storage provides block devices for VM disk images.
|
||||
# Registers iSCSI targets as Proxmox storage via
|
||||
# pvesm add iscsi. Proxmox manages the session natively via
|
||||
# open-iscsi; LUNs appear as raw block devices for VM disks.
|
||||
#
|
||||
# Features:
|
||||
# - Auto-installs open-iscsi + enables iscsid service.
|
||||
# - sendtargets discovery against a portal (IP:port).
|
||||
# - Auto-selects a single target; menu when several.
|
||||
# - Storage ID derived from the IQN suffix.
|
||||
# - Content type fixed to 'images' (block storage only).
|
||||
# - View, remove and connectivity-test for existing storages.
|
||||
# ==========================================================
|
||||
|
||||
LOCAL_SCRIPTS="/usr/local/share/proxmenux/scripts"
|
||||
|
||||
@@ -4,9 +4,24 @@
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# Last Updated: 08/04/2026
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Creates a host directory pre-configured for LXC bind mounts.
|
||||
# Applies a permission profile (1777 + ACLs) that works for
|
||||
# both privileged and unprivileged containers without UID/GID
|
||||
# alignment.
|
||||
#
|
||||
# Features:
|
||||
# - Auto-suggests a free name in /mnt (shared, shared2, …).
|
||||
# - Accepts custom absolute paths outside /mnt.
|
||||
# - chown root:root + chmod 1777 (sticky + world-rwx).
|
||||
# - setfacl with default-inheritance ACLs so new files keep
|
||||
# the permissive profile.
|
||||
# - Registers the directory in the ProxMenux share map for
|
||||
# later use by the LXC Mount Manager.
|
||||
# ==========================================================
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
@@ -4,15 +4,27 @@
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Adds bind mounts from Proxmox host directories into LXC
|
||||
# containers using pct set -mpX (Proxmox native).
|
||||
# Bind-mounts a host directory into an LXC container using
|
||||
# Proxmox's native pct set -mpN syntax. Handles the permission
|
||||
# quirks of unprivileged containers on the host side — never
|
||||
# modifies anything inside the container.
|
||||
#
|
||||
# SAFE DESIGN: This script NEVER modifies permissions, ownership,
|
||||
# or ACLs on the host or inside the container. All existing
|
||||
# configurations are preserved as-is.
|
||||
# Features:
|
||||
# - Unified host-directory picker (mounted CIFS/NFS shares,
|
||||
# fstab-inactive entries, /mnt/* local dirs, /mnt/pve/*
|
||||
# Proxmox storages, manual entry).
|
||||
# - Active fix per source type:
|
||||
# - CIFS → offer remount with uid=0,gid=0,file_mode=0777
|
||||
# - NFS → offer chmod 1777 + setfacl on the share
|
||||
# - Local → offer chmod o+rwx + ACL (unprivileged only)
|
||||
# - Auto-detects privileged vs unprivileged containers.
|
||||
# - View / remove existing mp* entries.
|
||||
# - Optional CT restart at end with mount-point smoke test.
|
||||
# ==========================================================
|
||||
|
||||
BASE_DIR="/usr/local/share/proxmenux"
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
#!/bin/bash
|
||||
# ==========================================================
|
||||
# ProxMenux CT - NFS Client Manager for Proxmox LXC
|
||||
# ProxMenux - NFS Client Manager for LXC
|
||||
# ==========================================================
|
||||
# Based on ProxMenux by MacRimi
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# This script allows you to manage NFS client mounts inside Proxmox CTs:
|
||||
# - Mount NFS shares (temporary and permanent)
|
||||
# - View current mounts
|
||||
# - Unmount and remove NFS shares
|
||||
# - Auto-discover NFS servers
|
||||
# Manages NFS client mounts from inside a Proxmox LXC container.
|
||||
# Requires a privileged container (kernel NFS client needs
|
||||
# capabilities that unprivileged CTs do not expose).
|
||||
#
|
||||
# Features:
|
||||
# - Mount NFS shares (temporary and permanent via /etc/fstab).
|
||||
# - List current NFS mounts inside the CT.
|
||||
# - Unmount and remove NFS shares cleanly.
|
||||
# - Auto-discover NFS servers on the local network.
|
||||
# ==========================================================
|
||||
|
||||
# Configuration
|
||||
@@ -45,6 +53,17 @@ install_nfs_client() {
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Installing NFS Client in LXC")"
|
||||
|
||||
# Pre-flight: refuse non-Debian-family CTs. The script targets
|
||||
# `apt-get` only — Alpine / Rocky / AlmaLinux fail with cryptic
|
||||
# errors mid-flow. Audit Tier 6 — `nfs_client.sh`/`samba_client.sh`
|
||||
# asume distro Debian-family sin detección.
|
||||
if ! pct exec "$CTID" -- bash -c 'command -v apt-get' &>/dev/null; then
|
||||
msg_error "$(translate "This container does not have apt-get. NFS client installation only supports Debian/Ubuntu containers.")"
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
read -r
|
||||
return 1
|
||||
fi
|
||||
|
||||
msg_info "$(translate "Installing NFS client packages...")"
|
||||
if ! pct exec "$CTID" -- apt-get update >/dev/null 2>&1; then
|
||||
msg_error "$(translate "Failed to update package list.")"
|
||||
@@ -551,9 +570,23 @@ unmount_nfs_share() {
|
||||
# Remove from fstab
|
||||
pct exec "$CTID" -- sed -i "\|[[:space:]]$SELECTED_MOUNT[[:space:]]|d" /etc/fstab
|
||||
msg_ok "$(translate "Removed from /etc/fstab.")"
|
||||
|
||||
|
||||
# Actually unmount it now (the previous version only edited fstab,
|
||||
# so the share remained mounted until the CT rebooted). Try a
|
||||
# graceful umount first, fall back to lazy umount if busy. Audit
|
||||
# Tier 7 — `unmount_nfs_share` only borra fstab.
|
||||
if pct exec "$CTID" -- mountpoint -q "$SELECTED_MOUNT" 2>/dev/null; then
|
||||
if pct exec "$CTID" -- umount "$SELECTED_MOUNT" 2>/dev/null; then
|
||||
msg_ok "$(translate "Unmounted") $SELECTED_MOUNT"
|
||||
elif pct exec "$CTID" -- umount -l "$SELECTED_MOUNT" 2>/dev/null; then
|
||||
msg_warn "$(translate "Mount was busy — performed lazy unmount") $SELECTED_MOUNT"
|
||||
else
|
||||
msg_warn "$(translate "Could not unmount") $SELECTED_MOUNT $(translate "automatically. Reboot LXC to fully release.")"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e ""
|
||||
msg_ok "$(translate "NFS share unmount successfully. Reboot LXC required to take effect.")"
|
||||
msg_ok "$(translate "NFS share unmount completed.")"
|
||||
fi
|
||||
|
||||
echo -e ""
|
||||
|
||||
@@ -4,11 +4,21 @@
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Adds external NFS shares as Proxmox storage (pvesm).
|
||||
# Proxmox manages the mount natively — no fstab entries needed.
|
||||
# Registers external NFS exports as Proxmox storage via
|
||||
# pvesm add nfs. Proxmox manages the mount natively — no
|
||||
# fstab entries needed on the host.
|
||||
#
|
||||
# Features:
|
||||
# - Auto-discover NFS servers on the local subnet (nmap).
|
||||
# - Reachability validation chain (ping + nc + showmount).
|
||||
# - Content-type checklist (import/backup/iso/vztmpl/images/
|
||||
# rootdir/snippets).
|
||||
# - View, remove and connectivity-test for existing storages.
|
||||
# ==========================================================
|
||||
|
||||
LOCAL_SCRIPTS="/usr/local/share/proxmenux/scripts"
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
#!/bin/bash
|
||||
# ==========================================================
|
||||
# ProxMenux CT - NFS Manager for Proxmox LXC (Simple + Universal)
|
||||
# ProxMenux - NFS Server Manager for LXC
|
||||
# ==========================================================
|
||||
# Based on ProxMenux by MacRimi
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# This script allows you to manage NFS shares inside Proxmox CTs:
|
||||
# - Create NFS exports with universal sharedfiles group
|
||||
# - View configured exports
|
||||
# - Delete existing exports
|
||||
# - Check NFS service status
|
||||
# Manages NFS exports from inside a Proxmox LXC container.
|
||||
# Requires a privileged container (the kernel NFS server module
|
||||
# needs capabilities that unprivileged CTs do not expose).
|
||||
#
|
||||
# Features:
|
||||
# - Install and configure nfs-kernel-server inside the CT.
|
||||
# - Create NFS exports for folders under /mnt.
|
||||
# - Set up a universal "sharedfiles" group (GID 101000) on the
|
||||
# CT as a convention for cross-CT file sharing.
|
||||
# - List configured exports and check service status.
|
||||
# - Remove exports cleanly.
|
||||
# ==========================================================
|
||||
|
||||
# Configuration
|
||||
@@ -70,42 +80,55 @@ setup_universal_sharedfiles_group() {
|
||||
fi
|
||||
|
||||
|
||||
msg_info "$(translate "Creating UID remapping for unprivileged container compatibility...")"
|
||||
local remapped_count=0
|
||||
|
||||
if [[ -n "$lxc_users" ]]; then
|
||||
while IFS=: read -r username uid; do
|
||||
if [[ -n "$uid" ]]; then
|
||||
local remapped_uid=$((uid + 100000))
|
||||
local remapped_username="remap_${uid}"
|
||||
|
||||
|
||||
if ! pct exec "$ctid" -- id "$remapped_username" >/dev/null 2>&1; then
|
||||
pct exec "$ctid" -- useradd -u "$remapped_uid" -g sharedfiles -s /bin/false -M "$remapped_username" 2>/dev/null || true
|
||||
msg_ok "$(translate "Created remapped user") $remapped_username (UID: $remapped_uid)"
|
||||
((remapped_count++))
|
||||
else
|
||||
|
||||
pct exec "$ctid" -- usermod -g sharedfiles "$remapped_username" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
done <<< "$lxc_users"
|
||||
# `+ 100000` UID-shift only makes sense in unprivileged containers
|
||||
# (UID 0 in CT == UID 100000 on host). `select_privileged_lxc` already
|
||||
# gated the flow to privileged CTs above, so the shift is meaningless
|
||||
# here and creates phantom `remap_NNNN` accounts that don't map to
|
||||
# any real UID. Skip the loop in privileged context. Audit Tier 6 —
|
||||
# UID-shift remapping en CTs privilegiados donde no aplica.
|
||||
local _is_unpriv=0
|
||||
if pct config "$ctid" 2>/dev/null | grep -qE '^unprivileged:\s*1'; then
|
||||
_is_unpriv=1
|
||||
fi
|
||||
|
||||
local remapped_count=0
|
||||
|
||||
local common_uids=(33 1000 1001 1002)
|
||||
for base_uid in "${common_uids[@]}"; do
|
||||
local remapped_uid=$((base_uid + 100000))
|
||||
local remapped_username="remap_${base_uid}"
|
||||
|
||||
if ! pct exec "$ctid" -- id "$remapped_username" >/dev/null 2>&1; then
|
||||
pct exec "$ctid" -- useradd -u "$remapped_uid" -g sharedfiles -s /bin/false -M "$remapped_username" 2>/dev/null || true
|
||||
msg_ok "$(translate "Created common remapped user") $remapped_username (UID: $remapped_uid)"
|
||||
((remapped_count++))
|
||||
if (( _is_unpriv == 1 )); then
|
||||
msg_info "$(translate "Creating UID remapping for unprivileged container compatibility...")"
|
||||
|
||||
if [[ -n "$lxc_users" ]]; then
|
||||
while IFS=: read -r username uid; do
|
||||
if [[ -n "$uid" ]]; then
|
||||
local remapped_uid=$((uid + 100000))
|
||||
local remapped_username="remap_${uid}"
|
||||
|
||||
if ! pct exec "$ctid" -- id "$remapped_username" >/dev/null 2>&1; then
|
||||
pct exec "$ctid" -- useradd -u "$remapped_uid" -g sharedfiles -s /bin/false -M "$remapped_username" 2>/dev/null || true
|
||||
msg_ok "$(translate "Created remapped user") $remapped_username (UID: $remapped_uid)"
|
||||
((remapped_count++))
|
||||
else
|
||||
pct exec "$ctid" -- usermod -g sharedfiles "$remapped_username" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
done <<< "$lxc_users"
|
||||
fi
|
||||
done
|
||||
|
||||
msg_ok "$(translate "Universal sharedfiles group configured with") $remapped_count $(translate "remapped users")"
|
||||
|
||||
|
||||
local common_uids=(33 1000 1001 1002)
|
||||
for base_uid in "${common_uids[@]}"; do
|
||||
local remapped_uid=$((base_uid + 100000))
|
||||
local remapped_username="remap_${base_uid}"
|
||||
|
||||
if ! pct exec "$ctid" -- id "$remapped_username" >/dev/null 2>&1; then
|
||||
pct exec "$ctid" -- useradd -u "$remapped_uid" -g sharedfiles -s /bin/false -M "$remapped_username" 2>/dev/null || true
|
||||
msg_ok "$(translate "Created common remapped user") $remapped_username (UID: $remapped_uid)"
|
||||
((remapped_count++))
|
||||
fi
|
||||
done
|
||||
|
||||
msg_ok "$(translate "Universal sharedfiles group configured with") $remapped_count $(translate "remapped users")"
|
||||
else
|
||||
msg_ok "$(translate "Privileged container — UID-shift remapping skipped (not applicable)")"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
#!/bin/bash
|
||||
# ==========================================================
|
||||
# ProxMenux CT - Samba Client Manager for Proxmox LXC
|
||||
# ProxMenux - Samba / CIFS Client Manager for LXC
|
||||
# ==========================================================
|
||||
# Based on ProxMenux by MacRimi
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# This script allows you to manage Samba/CIFS client mounts inside Proxmox CTs:
|
||||
# - Mount Samba/CIFS shares (temporary and permanent)
|
||||
# - View current mounts
|
||||
# - Unmount and remove Samba shares
|
||||
# - Auto-discover Samba servers
|
||||
# - Manage credentials securely
|
||||
# Manages Samba / CIFS client mounts from inside a Proxmox LXC
|
||||
# container. Requires a privileged container (mount.cifs needs
|
||||
# capabilities that unprivileged CTs do not expose).
|
||||
#
|
||||
# Features:
|
||||
# - Mount CIFS shares (temporary and permanent via /etc/fstab).
|
||||
# - List current CIFS mounts inside the CT.
|
||||
# - Unmount and remove shares cleanly.
|
||||
# - Auto-discover Samba servers on the local network.
|
||||
# - Credentials stored in /etc/samba/credentials (root:0600).
|
||||
# ==========================================================
|
||||
|
||||
|
||||
@@ -52,6 +60,12 @@ install_samba_client() {
|
||||
msg_title "$(translate "Installing Samba Client")"
|
||||
msg_info "$(translate "Installing Samba/CIFS client packages...")"
|
||||
|
||||
# Mirror of nfs_client.sh: refuse non-Debian-family CTs early.
|
||||
if ! pct exec "$CTID" -- bash -c 'command -v apt-get' &>/dev/null; then
|
||||
msg_error "$(translate "This container does not have apt-get. Samba client installation only supports Debian/Ubuntu containers.")"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! pct exec "$CTID" -- apt-get update &>/dev/null; then
|
||||
msg_error "$(translate "Failed to update package list.")"
|
||||
return 1
|
||||
|
||||
@@ -4,11 +4,23 @@
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# Adds external Samba/CIFS shares as Proxmox storage (pvesm).
|
||||
# Proxmox manages the mount natively — no fstab entries needed.
|
||||
# Registers external Samba (SMB / CIFS) shares as Proxmox
|
||||
# storage via pvesm add cifs. Credentials are stored encrypted
|
||||
# in /etc/pve/priv/storage/<id>.pw — no fstab entries needed.
|
||||
#
|
||||
# Features:
|
||||
# - Auto-discover Samba servers on the local subnet
|
||||
# (nmap on ports 139/445 + nmblookup for NetBIOS names).
|
||||
# - Guest or username/password authentication.
|
||||
# - Share listing via smbclient -L (filtered to Disk shares).
|
||||
# - Content-type checklist (no rootdir — Proxmox does not
|
||||
# support LXC rootfs on CIFS).
|
||||
# - View, remove and connectivity-test for existing storages.
|
||||
# ==========================================================
|
||||
|
||||
LOCAL_SCRIPTS="/usr/local/share/proxmenux/scripts"
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
#!/bin/bash
|
||||
# ==========================================================
|
||||
# ProxMenux CT - Samba Manager for Proxmox LXC
|
||||
# ProxMenux - Samba Server Manager for LXC
|
||||
# ==========================================================
|
||||
# Based on ProxMenux by MacRimi
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : GPL-3.0
|
||||
# https://github.com/MacRimi/ProxMenux/blob/main/LICENSE
|
||||
# Version : 1.0
|
||||
# ==========================================================
|
||||
# Description:
|
||||
# This script allows you to manage Samba shares inside Proxmox CTs:
|
||||
# - Create shared folders
|
||||
# - View configured shares
|
||||
# - Delete existing shares
|
||||
# - Check Samba service status
|
||||
# Manages Samba (SMB / CIFS) shares from inside a Proxmox LXC
|
||||
# container. Requires a privileged container.
|
||||
#
|
||||
# Features:
|
||||
# - Install and configure samba inside the CT.
|
||||
# - Expose folders under /mnt as Samba shares.
|
||||
# - Set up a universal "sharedfiles" group (GID 101000) on the
|
||||
# CT as a convention for cross-CT file sharing.
|
||||
# - List configured shares and check service status.
|
||||
# - Remove shares cleanly.
|
||||
# ==========================================================
|
||||
|
||||
# Configuration
|
||||
@@ -146,7 +155,11 @@ create_share() {
|
||||
if ! pct exec "$CTID" -- id "$USERNAME" &>/dev/null; then
|
||||
pct exec "$CTID" -- adduser --disabled-password --gecos "" "$USERNAME"
|
||||
fi
|
||||
pct exec "$CTID" -- bash -c "echo -e '$PASSWORD\n$PASSWORD' | smbpasswd -a '$USERNAME'"
|
||||
# Pipe the password via stdin instead of interpolating into a `bash -c`
|
||||
# shell string. The previous form broke (and was injectable) when the
|
||||
# password contained a single quote. `-s` makes smbpasswd read silently
|
||||
# from stdin and `printf` keeps the bytes literal — no shell expansion.
|
||||
printf '%s\n%s\n' "$PASSWORD" "$PASSWORD" | pct exec "$CTID" -- smbpasswd -s -a "$USERNAME"
|
||||
|
||||
msg_ok "$(translate "Samba server installed successfully.")"
|
||||
else
|
||||
@@ -160,7 +173,12 @@ create_share() {
|
||||
if [[ -n "$IS_MOUNTED" ]]; then
|
||||
msg_info "$(translate "Detected a mounted directory from host. Setting up shared group...")"
|
||||
|
||||
SHARE_GID=999
|
||||
# Match the GID `nfs_lxc_server.sh` uses (101000) so the same
|
||||
# `sharedfiles` group bridges Samba- and NFS-served paths. The
|
||||
# previous `999` was inconsistent — files written via Samba were
|
||||
# owned by GID 999 and not visible to NFS clients accessing the
|
||||
# same dataset. Audit Tier 6 — GID inconsistente.
|
||||
SHARE_GID=101000
|
||||
GROUP_EXISTS=$(pct exec "$CTID" -- getent group sharedfiles || true)
|
||||
GID_IN_USE=$(pct exec "$CTID" -- getent group "$SHARE_GID" | cut -d: -f1 || true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user