mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-10-02 08:06:17 +00:00
Update commands_share.sh
This commit is contained in:
@@ -73,129 +73,73 @@ show_how_to_enter_lxc() {
|
||||
show_host_mount_resources_help() {
|
||||
clear
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Mount Remote Resources on Proxmox Host Guide")"
|
||||
msg_title "$(translate "Mount Remote Resources on Proxmox Host")"
|
||||
|
||||
msg_info2 "$(translate "Manual commands to mount NFS, Samba, and local resources directly on the Proxmox host. Execute these commands on the Proxmox host.")"
|
||||
msg_info2 "$(translate "How to mount NFS and Samba shares directly on the Proxmox host. Proxmox already has the necessary tools installed.")"
|
||||
echo -e
|
||||
|
||||
echo -e "${BOLD}${BL}=== NFS MOUNT ON HOST ===${CL}"
|
||||
echo -e "${BOLD}${BL}=== MOUNT NFS SHARE ===${CL}"
|
||||
echo -e
|
||||
|
||||
|
||||
show_command "1" \
|
||||
"$(translate "Create host mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/host_nfs${CL}" \
|
||||
"$(translate "Replace /mnt/host_nfs with your preferred path.")" \
|
||||
"$(translate "Create mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/nfs_share${CL}" \
|
||||
"$(translate "Replace with your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "2" \
|
||||
"$(translate "Create universal shared group on host:")" \
|
||||
"groupadd -g 101000 sharedfiles" \
|
||||
"$(translate "GID 101000 works universally: privileged see 101000, unprivileged see 1000.")" \
|
||||
"$(translate "Mount NFS share:")" \
|
||||
"mount -t nfs ${CUS}192.168.1.100${CL}:${CUS}/path/to/share${CL} ${CUS}/mnt/nfs_share${CL}" \
|
||||
"$(translate "Replace IP and paths with your values.")" \
|
||||
""
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Mount NFS share on host:")" \
|
||||
"mount -t nfs ${CUS}192.168.1.100${CL}:${CUS}/mnt/nfs_export${CL} ${CUS}/mnt/host_nfs${CL}" \
|
||||
"$(translate "Replace server IP and remote path.")" \
|
||||
""
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Set universal host mount permissions:")" \
|
||||
"chgrp sharedfiles ${CUS}/mnt/host_nfs${CL}
|
||||
chmod 2775 ${CUS}/mnt/host_nfs${CL}" \
|
||||
"$(translate "Uses GID 101000 - works for both container types.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== SAMBA/CIFS MOUNT ON HOST ===${CL}"
|
||||
echo -e
|
||||
|
||||
|
||||
show_command "5" \
|
||||
"$(translate "Create Samba mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/host_samba${CL}" \
|
||||
"$(translate "Replace /mnt/host_samba with your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Create credentials file:")" \
|
||||
"cat > /etc/samba/host_credentials << EOF
|
||||
username=${CUS}sambauser${CL}
|
||||
password=${CUS}your_password${CL}
|
||||
domain=WORKGROUP
|
||||
EOF
|
||||
chmod 600 /etc/samba/host_credentials" \
|
||||
"$(translate "Secure storage for Samba credentials.")" \
|
||||
""
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Mount Samba share with universal permissions:")" \
|
||||
"mount -t cifs //${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/host_samba${CL} -o credentials=/etc/samba/host_credentials,uid=0,gid=101000,file_mode=0664,dir_mode=2775" \
|
||||
"$(translate "Uses GID 101000 for universal compatibility.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== LOCAL BIND MOUNT ON HOST ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Create source and target directories:")" \
|
||||
"mkdir -p ${CUS}/source/directory${CL}
|
||||
mkdir -p ${CUS}/mnt/host_bind${CL}" \
|
||||
"$(translate "Create both source and mount point directories.")" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Set up bind mount:")" \
|
||||
"mount --bind ${CUS}/source/directory${CL} ${CUS}/mnt/host_bind${CL}" \
|
||||
"$(translate "Creates a bind mount of local directory.")" \
|
||||
""
|
||||
|
||||
show_command "10" \
|
||||
"$(translate "Set universal permissions:")" \
|
||||
"chgrp sharedfiles ${CUS}/mnt/host_bind${CL}
|
||||
chmod 2775 ${CUS}/mnt/host_bind${CL}" \
|
||||
"$(translate "Uses GID 101000 for universal compatibility.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== MAKE MOUNTS PERMANENT ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "11" \
|
||||
"$(translate "Add NFS to fstab:")" \
|
||||
"echo '${CUS}192.168.1.100${CL}:${CUS}/mnt/nfs_export${CL} ${CUS}/mnt/host_nfs${CL} nfs defaults,_netdev 0 0' >> /etc/fstab" \
|
||||
"$(translate "Make permanent (optional):")" \
|
||||
"echo '${CUS}192.168.1.100${CL}:${CUS}/path/to/share${CL} ${CUS}/mnt/nfs_share${CL} nfs4 rw,hard,intr,_netdev,rsize=1048576,wsize=1048576,timeo=600,retrans=2 0 0' >> /etc/fstab" \
|
||||
"$(translate "_netdev waits for network before mounting.")" \
|
||||
""
|
||||
|
||||
show_command "12" \
|
||||
"$(translate "Add Samba to fstab:")" \
|
||||
"echo '//${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/host_samba${CL} cifs credentials=/etc/samba/host_credentials,uid=0,gid=101000,file_mode=0664,dir_mode=2775,_netdev 0 0' >> /etc/fstab" \
|
||||
"" \
|
||||
echo -e "${BOLD}${BL}=== MOUNT SAMBA SHARE ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Create mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/samba_share${CL}" \
|
||||
"$(translate "Replace with your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "13" \
|
||||
"$(translate "Add bind mount to fstab:")" \
|
||||
"echo '${CUS}/source/directory${CL} ${CUS}/mnt/host_bind${CL} none bind 0 0' >> /etc/fstab" \
|
||||
"" \
|
||||
show_command "5" \
|
||||
"$(translate "Mount Samba share:")" \
|
||||
"mount -t cifs //${CUS}192.168.1.100${CL}/${CUS}sharename${CL} ${CUS}/mnt/samba_share${CL} -o username=${CUS}user${CL}" \
|
||||
"$(translate "You will be prompted for password. Replace IP, share and user.")" \
|
||||
""
|
||||
|
||||
show_command "14" \
|
||||
"$(translate "Test fstab configuration:")" \
|
||||
"mount -a" \
|
||||
"$(translate "Mounts all entries in fstab to verify configuration.")" \
|
||||
show_command "6" \
|
||||
"$(translate "Make permanent (optional):")" \
|
||||
"echo '//${CUS}192.168.1.100${CL}/${CUS}sharename${CL} ${CUS}/mnt/samba_share${CL} cifs username=${CUS}user${CL},password=${CUS}pass${CL},_netdev 0 0' >> /etc/fstab" \
|
||||
"$(translate "Replace with your credentials.")" \
|
||||
""
|
||||
|
||||
show_command "15" \
|
||||
"$(translate "Verify all mounts:")" \
|
||||
"df -h | grep -E '(host_nfs|host_samba|host_bind)'" \
|
||||
"" \
|
||||
echo -e "${BOLD}${BL}=== CREATE LOCAL DIRECTORY ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Create directory:")" \
|
||||
"mkdir -p ${CUS}/mnt/local_share${CL}" \
|
||||
"$(translate "Creates a local directory on Proxmox host.")" \
|
||||
""
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Set permissions:")" \
|
||||
"chmod 755 ${CUS}/mnt/local_share${CL}" \
|
||||
"$(translate "Sets basic read/write permissions.")" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Verify mounts:")" \
|
||||
"df -h" \
|
||||
"$(translate "Shows all mounted filesystems.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOR}"
|
||||
echo -e "${BOLD}$(translate "Universal GID 101000 Explanation:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Host:")${CL} ${BL}All directories use GID 101000 (sharedfiles)${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Privileged containers:")${CL} ${BL}See GID 101000, create group with same GID${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Unprivileged containers:")${CL} ${BL}See GID 1000 (mapped from 101000), create group GID 1000${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Result:")${CL} ${BL}Same group name 'sharedfiles' in all containers${CL}"
|
||||
|
||||
echo -e ""
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
@@ -205,113 +149,41 @@ chmod 2775 ${CUS}/mnt/host_bind${CL}" \
|
||||
show_host_to_lxc_mount_help() {
|
||||
clear
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Mount Host Directory to LXC Container Guide")"
|
||||
msg_title "$(translate "Mount Host Directory to LXC Container")"
|
||||
|
||||
msg_info2 "$(translate "Manual commands to mount a host directory into an LXC container. Execute these commands on the Proxmox host.")"
|
||||
msg_info2 "$(translate "How to mount a Proxmox host directory into an LXC container. Execute these commands on the Proxmox host.")"
|
||||
echo -e
|
||||
|
||||
echo -e "${BOLD}${BL}=== UNIVERSAL APPROACH (WORKS FOR BOTH CONTAINER TYPES) ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "1" \
|
||||
"$(translate "Create universal shared group on the host:")" \
|
||||
"groupadd -g 101000 sharedfiles" \
|
||||
"$(translate "GID 101000 works universally for both privileged and unprivileged containers.")" \
|
||||
""
|
||||
"$(translate "Add mount point to container:")" \
|
||||
"pct set ${CUS}<container-id>${CL} -mp0 ${CUS}/host/directory${CL},mp=${CUS}/container/path${CL},backup=0,shared=1" \
|
||||
"$(translate "Replace container-id, host directory and container path.")" \
|
||||
"$(translate "Example: pct set 101 -mp0 /mnt/shared,mp=/mnt/shared,,backup=0,shared=1")"
|
||||
|
||||
show_command "2" \
|
||||
"$(translate "Create the host directory:")" \
|
||||
"mkdir -p ${CUS}/mnt/shared_data${CL}" \
|
||||
"$(translate "Replace /mnt/shared_data with your preferred path.")" \
|
||||
"$(translate "Restart container:")" \
|
||||
"pct reboot ${CUS}<container-id>${CL}" \
|
||||
"$(translate "Required to activate the mount point.")" \
|
||||
""
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Set universal ownership and permissions:")" \
|
||||
"chown root:sharedfiles ${CUS}/mnt/shared_data${CL}
|
||||
chmod 2775 ${CUS}/mnt/shared_data${CL}" \
|
||||
"$(translate "Uses GID 101000 - works for both container types.")" \
|
||||
"$(translate "Verify mount inside container:")" \
|
||||
"pct enter ${CUS}<container-id>${CL}
|
||||
df -h | grep ${CUS}/container/path${CL}" \
|
||||
"$(translate "Check if the directory is mounted.")" \
|
||||
""
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Add bind mount to ANY LXC container:")" \
|
||||
"pct set ${CUS}<container-id>${CL} -mp0 ${CUS}/mnt/shared_data${CL},mp=${CUS}/mnt/shared${CL},backup=0,acl=1" \
|
||||
"$(translate "Works for both privileged and unprivileged containers.")" \
|
||||
"$(translate "Example: pct set 101 -mp0 /mnt/shared_data,mp=/mnt/shared,backup=0,acl=1")"
|
||||
|
||||
echo -e "${BOLD}${BL}=== INSIDE PRIVILEGED CONTAINER CONFIGURATION ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "5" \
|
||||
"$(translate "Enter the privileged container:")" \
|
||||
"pct enter ${CUS}<privileged-container-id>${CL}" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Inside privileged container - create matching group:")" \
|
||||
"groupadd -g 101000 sharedfiles" \
|
||||
"$(translate "Creates GID 101000 group to match host group exactly.")" \
|
||||
""
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Add users to the shared group (privileged):")" \
|
||||
"usermod -aG sharedfiles www-data
|
||||
usermod -aG sharedfiles root" \
|
||||
"$(translate "Add any users that need access to the shared directory.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== INSIDE UNPRIVILEGED CONTAINER CONFIGURATION ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Enter the unprivileged container:")" \
|
||||
"pct enter ${CUS}<unprivileged-container-id>${CL}" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Inside unprivileged container - create mapped group:")" \
|
||||
"groupadd -g 1000 sharedfiles" \
|
||||
"$(translate "Creates GID 1000 group (maps to host GID 101000).")" \
|
||||
""
|
||||
|
||||
show_command "10" \
|
||||
"$(translate "Add users to the shared group (unprivileged):")" \
|
||||
"usermod -aG sharedfiles www-data
|
||||
usermod -aG sharedfiles root" \
|
||||
"$(translate "Add any users that need access to the shared directory.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== FINAL STEPS (BOTH CONTAINER TYPES) ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "11" \
|
||||
"$(translate "Set container directory permissions:")" \
|
||||
"chgrp sharedfiles ${CUS}/mnt/shared${CL}
|
||||
chmod 2775 ${CUS}/mnt/shared${CL}" \
|
||||
"$(translate "Run this inside each container after group creation.")" \
|
||||
""
|
||||
|
||||
show_command "12" \
|
||||
"$(translate "Test access (inside container):")" \
|
||||
"su - www-data -c 'touch ${CUS}/mnt/shared${CL}/test_file.txt'" \
|
||||
"$(translate "Verify that users can create files in the shared directory.")" \
|
||||
""
|
||||
|
||||
show_command "13" \
|
||||
"$(translate "Restart container to activate mount:")" \
|
||||
"exit
|
||||
pct reboot ${CUS}<container-id>${CL}" \
|
||||
"$(translate "Exit container first, then restart from host.")" \
|
||||
"$(translate "Remove mount point (if needed):")" \
|
||||
"pct set ${CUS}<container-id>${CL} --delete mp0" \
|
||||
"$(translate "Removes the mount point. Use mp1, mp2, etc. for other mounts.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOR}"
|
||||
echo -e "${BOLD}$(translate "Universal GID Mapping Explanation:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Host:")${CL} ${BL}Uses GID 101000 (sharedfiles)${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Privileged containers:")${CL} ${BL}Create GID 101000 (sharedfiles) - direct match${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Unprivileged containers:")${CL} ${BL}Create GID 1000 (sharedfiles) - maps to host 101000${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Result:")${CL} ${BL}Same directory, same group name, works for both${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Mount point index:")${CL} ${BL}Use mp0, mp1, mp2, etc. for multiple mounts${CL}"
|
||||
echo -e "${BOLD}$(translate "Notes:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Mount indices:")${CL} ${BL}Use mp0, mp1, mp2, etc. for multiple mounts${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Permissions:")${CL} ${BL}May need adjustment depending on directory type${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Container types:")${CL} ${BL}Works with both privileged and unprivileged containers${CL}"
|
||||
|
||||
echo -e ""
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
@@ -321,99 +193,59 @@ pct reboot ${CUS}<container-id>${CL}" \
|
||||
show_nfs_server_help() {
|
||||
clear
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "NFS Server Installation Guide")"
|
||||
msg_title "$(translate "NFS Server Installation")"
|
||||
|
||||
msg_info2 "$(translate "Manual commands to install NFS server in an LXC with universal compatibility. Remember to substitute the highlighted values.")"
|
||||
msg_info2 "$(translate "How to install and configure an NFS server in an LXC container.")"
|
||||
echo -e
|
||||
|
||||
show_command "1" \
|
||||
"$(translate "Update package list:")" \
|
||||
"apt-get update" \
|
||||
"$(translate "Update and install packages:")" \
|
||||
"apt-get update && apt-get install -y nfs-kernel-server" \
|
||||
"" \
|
||||
""
|
||||
|
||||
|
||||
show_command "2" \
|
||||
"$(translate "Install NFS server packages:")" \
|
||||
"apt-get install -y nfs-kernel-server nfs-common rpcbind" \
|
||||
"$(translate "Create export directory:")" \
|
||||
"mkdir -p ${CUS}/mnt/nfs_export${CL}" \
|
||||
"$(translate "Replace with your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Set directory permissions:")" \
|
||||
"chmod 755 ${CUS}/mnt/nfs_export${CL}" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Create universal shared group:")" \
|
||||
"groupadd -g 101000 sharedfiles" \
|
||||
"$(translate "Creates group with GID 101000 for universal compatibility.")" \
|
||||
""
|
||||
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Add existing users to shared group:")" \
|
||||
"usermod -aG sharedfiles root
|
||||
usermod -aG sharedfiles www-data" \
|
||||
"$(translate "Add all users that need NFS access.")" \
|
||||
"$(translate "Configure exports:")" \
|
||||
"echo '${CUS}/mnt/nfs_export${CL} ${CUS}192.168.1.0/24${CL}(rw,sync,no_subtree_check)' >> /etc/exports" \
|
||||
"$(translate "Replace directory path and network range.")" \
|
||||
""
|
||||
|
||||
|
||||
show_command "5" \
|
||||
"$(translate "Create remapped users for unprivileged containers:")" \
|
||||
"useradd -u 100000 -g sharedfiles -s /bin/false -M unpriv_root
|
||||
useradd -u 100033 -g sharedfiles -s /bin/false -M unpriv_www" \
|
||||
"$(translate "Creates mapped users (original UID + 100000).")" \
|
||||
""
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Create the export directory:")" \
|
||||
"mkdir -p ${CUS}/mnt/nfs_export${CL}" \
|
||||
"$(translate "You can change /mnt/nfs_export to your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Set universal permissions:")" \
|
||||
"chown root:sharedfiles ${CUS}/mnt/nfs_export${CL}
|
||||
chmod 2775 ${CUS}/mnt/nfs_export${CL}" \
|
||||
"$(translate "Sets group ownership and sticky bit for inheritance.")" \
|
||||
""
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Configure exports with universal compatibility:")" \
|
||||
"echo '${CUS}/mnt/nfs_export${CL} ${CUS}192.168.1.0/24${CL}(rw,sync,no_subtree_check,all_squash,anonuid=0,anongid=101000)' >> /etc/exports" \
|
||||
"$(translate "Replace directory path and network. Uses all_squash for universal access.")" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Apply export configuration:")" \
|
||||
"$(translate "Apply configuration:")" \
|
||||
"exportfs -ra" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "10" \
|
||||
"$(translate "Restart NFS service:")" \
|
||||
"systemctl restart nfs-kernel-server" \
|
||||
show_command "6" \
|
||||
"$(translate "Start and enable service:")" \
|
||||
"systemctl restart nfs-kernel-server
|
||||
systemctl enable nfs-kernel-server" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "11" \
|
||||
"$(translate "Enable and start services:")" \
|
||||
"systemctl enable rpcbind nfs-kernel-server" \
|
||||
"$(translate "Ensure services start on boot.")" \
|
||||
""
|
||||
|
||||
show_command "12" \
|
||||
"$(translate "Verify installation:")" \
|
||||
show_command "7" \
|
||||
"$(translate "Verify exports:")" \
|
||||
"showmount -e localhost" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "13" \
|
||||
"$(translate "Test file creation:")" \
|
||||
"su - www-data -c 'touch ${CUS}/mnt/nfs_export${CL}/test_nfs.txt'" \
|
||||
"$(translate "Verify that users can create files in the export.")" \
|
||||
"$(translate "Shows available NFS exports.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOR}"
|
||||
echo -e "${BOLD}$(translate "Universal Compatibility Options:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "all_squash:")${CL} ${BL}Maps all users to anonymous user${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "anonuid=0:")${CL} ${BL}Anonymous user = root (UID 0)${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "anongid=101000:")${CL} ${BL}Anonymous group = sharedfiles (GID 101000)${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Privileged clients:")${CL} ${BL}See files as root:sharedfiles (0:101000)${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Unprivileged clients:")${CL} ${BL}See files as root:sharedfiles (0:1000) - mapped${CL}"
|
||||
echo -e "${BOLD}$(translate "Export Options:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "rw:")${CL} ${BL}Read-write access${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "sync:")${CL} ${BL}Synchronous writes${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "no_subtree_check:")${CL} ${BL}Improves performance${CL}"
|
||||
|
||||
echo -e ""
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
@@ -423,102 +255,66 @@ chmod 2775 ${CUS}/mnt/nfs_export${CL}" \
|
||||
show_samba_server_help() {
|
||||
clear
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Samba Server Installation Guide")"
|
||||
msg_title "$(translate "Samba Server Installation")"
|
||||
|
||||
msg_info2 "$(translate "Manual commands to install Samba server in an LXC with shared group support. Remember to substitute the highlighted values.")"
|
||||
msg_info2 "$(translate "How to install and configure a Samba server in an LXC container.")"
|
||||
echo -e
|
||||
|
||||
show_command "1" \
|
||||
"$(translate "Update package list:")" \
|
||||
"apt-get update" \
|
||||
"$(translate "Update and install packages:")" \
|
||||
"apt-get update && apt-get install -y samba" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "2" \
|
||||
"$(translate "Install Samba packages:")" \
|
||||
"apt-get install -y samba samba-common-bin acl" \
|
||||
"" \
|
||||
"$(translate "Create share directory:")" \
|
||||
"mkdir -p ${CUS}/mnt/samba_share${CL}" \
|
||||
"$(translate "Replace with your preferred path.")" \
|
||||
""
|
||||
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Create shared group:")" \
|
||||
"groupadd -g 1000 sharedfiles" \
|
||||
"$(translate "Creates group with GID 1000 for shared access.")" \
|
||||
"$(translate "Set directory permissions:")" \
|
||||
"chmod 755 ${CUS}/mnt/samba_share${CL}" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Create the share directory:")" \
|
||||
"mkdir -p ${CUS}/mnt/samba_share${CL}" \
|
||||
"$(translate "You can change /mnt/samba_share to your preferred path.")" \
|
||||
"$(translate "Create Samba user:")" \
|
||||
"adduser ${CUS}sambauser${CL}
|
||||
smbpasswd -a ${CUS}sambauser${CL}" \
|
||||
"$(translate "Replace with your username. You'll be prompted for password.")" \
|
||||
""
|
||||
|
||||
show_command "5" \
|
||||
"$(translate "Set directory permissions:")" \
|
||||
"chown root:sharedfiles ${CUS}/mnt/samba_share${CL}
|
||||
chmod 2775 ${CUS}/mnt/samba_share${CL}" \
|
||||
"$(translate "Sets group ownership and sticky bit for inheritance.")" \
|
||||
""
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Create a Samba user:")" \
|
||||
"adduser --disabled-password --gecos '' ${CUS}sambauser${CL}
|
||||
usermod -aG sharedfiles ${CUS}sambauser${CL}" \
|
||||
"$(translate "Creates user and adds to shared group.")" \
|
||||
""
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Set the Samba password for the user:")" \
|
||||
"smbpasswd -a ${CUS}sambauser${CL}" \
|
||||
"$(translate "You will be prompted to enter and confirm a new password.")" \
|
||||
""
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Configure the Samba share:")" \
|
||||
"$(translate "Configure share:")" \
|
||||
"cat >> /etc/samba/smb.conf << EOF
|
||||
[shared]
|
||||
comment = Shared folder
|
||||
path = ${CUS}/mnt/samba_share${CL}
|
||||
read only = no
|
||||
browseable = yes
|
||||
valid users = @sharedfiles
|
||||
force group = sharedfiles
|
||||
create mask = 0664
|
||||
directory mask = 2775
|
||||
force create mode = 0664
|
||||
force directory mode = 2775
|
||||
valid users = ${CUS}sambauser${CL}
|
||||
EOF" \
|
||||
"$(translate "Uses @sharedfiles group for access control.")" \
|
||||
"$(translate "Replace path and username.")" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Restart the Samba service:")" \
|
||||
"systemctl restart smbd" \
|
||||
show_command "6" \
|
||||
"$(translate "Restart and enable service:")" \
|
||||
"systemctl restart smbd
|
||||
systemctl enable smbd" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "10" \
|
||||
"$(translate "Enable the Samba service:")" \
|
||||
"systemctl enable smbd" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "11" \
|
||||
"$(translate "Verify installation:")" \
|
||||
show_command "7" \
|
||||
"$(translate "Test configuration:")" \
|
||||
"smbclient -L localhost -U ${CUS}sambauser${CL}" \
|
||||
"$(translate "Test share listing. You will be prompted for password.")" \
|
||||
""
|
||||
|
||||
show_command "12" \
|
||||
"$(translate "Test file creation:")" \
|
||||
"su - ${CUS}sambauser${CL} -c 'touch ${CUS}/mnt/samba_share${CL}/test_samba.txt'" \
|
||||
"$(translate "Verify that the user can create files in the share.")" \
|
||||
"$(translate "Lists available shares. You'll be prompted for password.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOR}"
|
||||
echo -e "${BOLD}$(translate "Connection Examples:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Windows:")${CL} ${YW}\\\\<server-ip>\\shared${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Linux:")${CL} ${YW}smbclient //server-ip/shared -U sambauser${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Mount:")${CL} ${YW}mount -t cifs //server-ip/shared /mnt/point -o username=sambauser${CL}"
|
||||
|
||||
echo -e ""
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
@@ -528,101 +324,47 @@ EOF" \
|
||||
show_nfs_client_help() {
|
||||
clear
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "NFS Client Configuration Guide")"
|
||||
msg_title "$(translate "NFS Client Configuration")"
|
||||
|
||||
msg_info2 "$(translate "Manual commands to configure an NFS client in an LXC with proper group mapping. Remember to substitute the highlighted values.")"
|
||||
echo -e
|
||||
|
||||
echo -e "${BOLD}${BL}=== FOR PRIVILEGED LXC CONTAINERS ===${CL}"
|
||||
msg_info2 "$(translate "How to configure an NFS client in an LXC container.")"
|
||||
echo -e
|
||||
|
||||
show_command "1" \
|
||||
"$(translate "Update package list:")" \
|
||||
"apt-get update" \
|
||||
"$(translate "Update and install packages:")" \
|
||||
"apt-get update && apt-get install -y nfs-common" \
|
||||
"" \
|
||||
""
|
||||
|
||||
|
||||
show_command "2" \
|
||||
"$(translate "Install NFS client packages:")" \
|
||||
"apt-get install -y nfs-common" \
|
||||
"" \
|
||||
"$(translate "Create mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/nfsmount${CL}" \
|
||||
"$(translate "Replace with your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Create matching shared group (privileged):")" \
|
||||
"groupadd -g 101000 sharedfiles" \
|
||||
"$(translate "Creates group that matches the NFS server group exactly.")" \
|
||||
"$(translate "Mount NFS share:")" \
|
||||
"mount -t nfs ${CUS}192.168.1.100${CL}:${CUS}/mnt/nfs_export${CL} ${CUS}/mnt/nfsmount${CL}" \
|
||||
"$(translate "Replace server IP and paths.")" \
|
||||
""
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Add users to shared group:")" \
|
||||
"usermod -aG sharedfiles root
|
||||
usermod -aG sharedfiles www-data" \
|
||||
"$(translate "Add users that need access to NFS files.")" \
|
||||
"$(translate "Test access:")" \
|
||||
"ls -la ${CUS}/mnt/nfsmount${CL}" \
|
||||
"$(translate "Verify you can access the mounted share.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== FOR UNPRIVILEGED LXC CONTAINERS ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "5" \
|
||||
"$(translate "Create mapped shared group (unprivileged):")" \
|
||||
"groupadd -g 1000 sharedfiles" \
|
||||
"$(translate "Creates GID 1000 group that maps to server GID 101000.")" \
|
||||
""
|
||||
"$(translate "Make permanent (optional):")" \
|
||||
"echo '${CUS}192.168.1.100${CL}:${CUS}/path/to/share${CL} ${CUS}/mnt/nfs_share${CL} nfs4 rw,hard,intr,_netdev,rsize=1048576,wsize=1048576,timeo=600,retrans=2 0 0' >> /etc/fstab" \
|
||||
|
||||
"$(translate "Replace with your server IP and paths.")" \
|
||||
""
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Add users to shared group:")" \
|
||||
"usermod -aG sharedfiles root
|
||||
usermod -aG sharedfiles www-data" \
|
||||
"$(translate "Add users that need access to NFS files.")" \
|
||||
"$(translate "Verify mount:")" \
|
||||
"df -h | grep nfs" \
|
||||
"$(translate "Shows NFS mounts.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOLD}${BL}=== MOUNT CONFIGURATION (BOTH TYPES) ===${CL}"
|
||||
echo -e
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Create local mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/nfsmount${CL}" \
|
||||
"$(translate "Create the directory where the remote share will be mounted.")" \
|
||||
""
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Mount the NFS share manually:")" \
|
||||
"mount -t nfs ${CUS}192.168.1.100${CL}:${CUS}/mnt/nfs_export${CL} ${CUS}/mnt/nfsmount${CL}" \
|
||||
"$(translate "Replace the IP, remote share path, and local mount point.")" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Set local mount permissions:")" \
|
||||
"chgrp sharedfiles ${CUS}/mnt/nfsmount${CL}
|
||||
chmod 2775 ${CUS}/mnt/nfsmount${CL}" \
|
||||
"$(translate "Ensures proper group access to the mounted share.")" \
|
||||
""
|
||||
|
||||
show_command "10" \
|
||||
"$(translate "Test access:")" \
|
||||
"su - www-data -c 'touch ${CUS}/mnt/nfsmount${CL}/test_client.txt'" \
|
||||
"$(translate "Verify that users can create files on the NFS share.")" \
|
||||
""
|
||||
|
||||
show_command "11" \
|
||||
"$(translate "Verify the mount:")" \
|
||||
"df -h | grep ${CUS}/mnt/nfsmount${CL}" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "12" \
|
||||
"$(translate "Add to fstab for automatic mounting:")" \
|
||||
"echo '${CUS}192.168.1.100${CL}:${CUS}/mnt/nfs_export${CL} ${CUS}/mnt/nfsmount${CL} nfs defaults,_netdev 0 0' >> /etc/fstab" \
|
||||
"$(translate "_netdev ensures mount waits for network. Replace IPs and paths.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOR}"
|
||||
echo -e "${BOLD}$(translate "Universal Compatibility:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "NFS Server:")${CL} ${BL}Uses all_squash,anonuid=0,anongid=101000${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Privileged containers:")${CL} ${BL}Create GID 101000 (sharedfiles) - direct match${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Unprivileged containers:")${CL} ${BL}Create GID 1000 (sharedfiles) - maps to 101000${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "Result:")${CL} ${BL}Both container types access with same group name${CL}"
|
||||
|
||||
echo -e ""
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
@@ -632,96 +374,68 @@ chmod 2775 ${CUS}/mnt/nfsmount${CL}" \
|
||||
show_samba_client_help() {
|
||||
clear
|
||||
show_proxmenux_logo
|
||||
msg_title "$(translate "Samba Client Configuration Guide")"
|
||||
msg_title "$(translate "Samba Client Configuration")"
|
||||
|
||||
msg_info2 "$(translate "Manual commands to configure a Samba client in an LXC with proper group mapping. Remember to substitute the highlighted values.")"
|
||||
msg_info2 "$(translate "How to configure a Samba client in an LXC container.")"
|
||||
echo -e
|
||||
|
||||
show_command "1" \
|
||||
"$(translate "Update package list:")" \
|
||||
"apt-get update" \
|
||||
"$(translate "Update and install packages:")" \
|
||||
"apt-get update && apt-get install -y cifs-utils" \
|
||||
"" \
|
||||
""
|
||||
|
||||
|
||||
show_command "2" \
|
||||
"$(translate "Install Samba client packages:")" \
|
||||
"apt-get install -y cifs-utils" \
|
||||
"" \
|
||||
"$(translate "Create mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/sambamount${CL}" \
|
||||
"$(translate "Replace with your preferred path.")" \
|
||||
""
|
||||
|
||||
show_command "3" \
|
||||
"$(translate "Create matching shared group:")" \
|
||||
"groupadd -g 1000 sharedfiles" \
|
||||
"$(translate "Creates group that matches the Samba server group.")" \
|
||||
"$(translate "Mount Samba share:")" \
|
||||
"mount -t cifs //${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/sambamount${CL} -o username=${CUS}sambauser${CL}" \
|
||||
"$(translate "Replace server IP, share name and username. You'll be prompted for password.")" \
|
||||
""
|
||||
|
||||
show_command "4" \
|
||||
"$(translate "Add users to shared group:")" \
|
||||
"usermod -aG sharedfiles root
|
||||
usermod -aG sharedfiles www-data" \
|
||||
"$(translate "Add users that need access to Samba files.")" \
|
||||
""
|
||||
|
||||
show_command "5" \
|
||||
"$(translate "Create local mount point:")" \
|
||||
"mkdir -p ${CUS}/mnt/sambamount${CL}" \
|
||||
"$(translate "Create the directory where the remote share will be mounted.")" \
|
||||
"$(translate "Test access:")" \
|
||||
"ls -la ${CUS}/mnt/sambamount${CL}" \
|
||||
"$(translate "Verify you can access the mounted share.")" \
|
||||
""
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Create credentials file (optional but recommended):")" \
|
||||
show_command "5" \
|
||||
"$(translate "Create credentials file (optional):")" \
|
||||
"cat > /etc/samba/credentials << EOF
|
||||
username=${CUS}sambauser${CL}
|
||||
password=${CUS}your_password${CL}
|
||||
domain=WORKGROUP
|
||||
EOF
|
||||
chmod 600 /etc/samba/credentials" \
|
||||
"$(translate "Secure way to store Samba credentials.")" \
|
||||
"$(translate "Secure way to store credentials.")" \
|
||||
""
|
||||
|
||||
|
||||
show_command "6" \
|
||||
"$(translate "Mount with credentials file:")" \
|
||||
"mount -t cifs //${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/sambamount${CL} -o credentials=/etc/samba/credentials" \
|
||||
"$(translate "No password prompt needed.")" \
|
||||
""
|
||||
|
||||
show_command "7" \
|
||||
"$(translate "Mount the Samba share manually:")" \
|
||||
"mount -t cifs //${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/sambamount${CL} -o credentials=/etc/samba/credentials,uid=0,gid=1000,file_mode=0664,dir_mode=2775" \
|
||||
"$(translate "Uses credentials file and sets proper permissions.")" \
|
||||
""
|
||||
|
||||
show_command "8" \
|
||||
"$(translate "Alternative - mount with username prompt:")" \
|
||||
"mount -t cifs //${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/sambamount${CL} -o username=${CUS}sambauser${CL},uid=0,gid=1000,file_mode=0664,dir_mode=2775" \
|
||||
"$(translate "You will be prompted for password.")" \
|
||||
""
|
||||
|
||||
show_command "9" \
|
||||
"$(translate "Test access:")" \
|
||||
"su - www-data -c 'touch ${CUS}/mnt/sambamount${CL}/test_client.txt'" \
|
||||
"$(translate "Verify that users can create files on the Samba share.")" \
|
||||
""
|
||||
|
||||
show_command "10" \
|
||||
"$(translate "Verify the mount:")" \
|
||||
"df -h | grep ${CUS}/mnt/sambamount${CL}" \
|
||||
"" \
|
||||
""
|
||||
|
||||
show_command "11" \
|
||||
"$(translate "Add to fstab for automatic mounting:")" \
|
||||
"echo '//${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/sambamount${CL} cifs credentials=/etc/samba/credentials,uid=0,gid=1000,file_mode=0664,dir_mode=2775,_netdev 0 0' >> /etc/fstab" \
|
||||
"$(translate "_netdev ensures mount waits for network.")" \
|
||||
"$(translate "Make permanent (optional):")" \
|
||||
"echo '//${CUS}192.168.1.100${CL}/${CUS}shared${CL} ${CUS}/mnt/sambamount${CL} cifs credentials=/etc/samba/credentials,_netdev 0 0' >> /etc/fstab" \
|
||||
"$(translate "Replace with your values.")" \
|
||||
""
|
||||
|
||||
echo -e "${BOR}"
|
||||
echo -e "${BOLD}$(translate "Mount Options Explained:")${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "uid=0:")${CL} ${BL}Files owned by root${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "gid=1000:")${CL} ${BL}Files belong to sharedfiles group${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "file_mode=0664:")${CL} ${BL}Files: rw-rw-r--${CL}"
|
||||
echo -e "${TAB}${BGN}$(translate "dir_mode=2775:")${CL} ${BL}Directories: rwxrwsr-x (sticky bit)${CL}"
|
||||
show_command "8" \
|
||||
"$(translate "Verify mount:")" \
|
||||
"df -h | grep cifs" \
|
||||
"$(translate "Shows CIFS/Samba mounts.")" \
|
||||
""
|
||||
|
||||
echo -e ""
|
||||
msg_success "$(translate "Press Enter to return to menu...")"
|
||||
read -r
|
||||
}
|
||||
|
||||
|
||||
show_help_menu() {
|
||||
while true; do
|
||||
CHOICE=$(dialog --title "$(translate "Help & Information")" \
|
||||
@@ -729,10 +443,10 @@ show_help_menu() {
|
||||
"0" "$(translate "How to Access an LXC Terminal")" \
|
||||
"1" "$(translate "Mount Remote Resources on Proxmox Host")" \
|
||||
"2" "$(translate "Mount Host Directory to LXC Container")" \
|
||||
"3" "$(translate "NFS Server Installation (Universal)")" \
|
||||
"4" "$(translate "Samba Server Installation (with Groups)")" \
|
||||
"5" "$(translate "NFS Client Configuration (with Groups)")" \
|
||||
"6" "$(translate "Samba Client Configuration (with Groups)")" \
|
||||
"3" "$(translate "NFS Server Installation")" \
|
||||
"4" "$(translate "Samba Server Installation")" \
|
||||
"5" "$(translate "NFS Client Configuration")" \
|
||||
"6" "$(translate "Samba Client Configuration")" \
|
||||
"7" "$(translate "Return to Main Menu")" \
|
||||
3>&1 1>&2 2>&3)
|
||||
|
||||
|
Reference in New Issue
Block a user