slyfox1186

fix-qnap-container-station-errors.sh

Apr 29th, 2022 (edited)
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.23 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # FIX QNAP QuTS HERO ACL PERMISSIONS FOR THE CONTAINER STATION APP.
  4. # WINDOWS CAUSES ACL PERMISSION ERRORS THAT YOU MUST FIX... THE CONTAINERS WONT RUN WITHOUT THIS UNTIL QNAP FIXES IT.
  5. # I AM NOT HOPEFUL BECAUSE I AM BEING ASKED FOR THE SECOND TIME BY QNAP WHAT MY ISSUES ARE AFTER I ALREADY EXPLAINED THEM.
  6.  
  7. ## YOU MUST PASS ARGUMENTS TO THE SCRIPT.
  8. # EXAMPLE: ./fix-qnap-container-station-errors.sh set 1000000
  9.  
  10. ## FOLDER 01
  11. # FIND THE FOLDER THAT CONTAINS THE 'Container' FOLDER
  12. # EXAMPLE: CONTAINER_VOLUME1="/share/ZFS22_DATA/Container"
  13. CONTAINER_VOLUME1="/share/<FOLDER HERE>/Container"
  14.  
  15. ## FOLDER 02
  16. # FIND THE FOLDER THAT CONTAINS THE '.qpkg' FOLDER
  17. # EXAMPLE: CONTAINER_VOLUME2="/share/ZFS530_DATA/.qpkg"
  18. CONTAINER_VOLUME2="/share/<FOLDER HERE>/.qpkg"
  19.  
  20. # VERIFY THAT ARGUMENTS WERE PASSED TO THE SCRIPT
  21. if [ -z "$1" ] || [ -z "$2" ]; then
  22.   echo "Use as $0 [set|unset] <UID>"
  23.   exit 1
  24. fi
  25.  
  26. # IF SET OR UNSET IS THE FIRST ARGUMENT RUN THE COMMANDS BELOW
  27. # OTHERWISE THROW AN ERROR
  28. if [ "$1" == "set" ]; then
  29.     setfacl -m user:$2:rx "$CONTAINER_VOLUME1"
  30.     setfacl -m user:$2:rx "$CONTAINER_VOLUME1"/container-station-data/lib
  31.     setfacl -m user:$2:rx "$CONTAINER_VOLUME1"/container-station-data/lib/lxd
  32.     setfacl -m user:$2:rx "$CONTAINER_VOLUME2"/container-station
  33.     setfacl -m user:$2:rx "$CONTAINER_VOLUME2"/container-station/lib
  34.     setfacl -m user:$2:rx "$CONTAINER_VOLUME2"/container-station/var
  35.    # setfacl -R -m user:$2:rx "$CONTAINER_VOLUME2"/container-station ## RECURSIVE
  36.     setfacl -R -m user:$2:rx "$CONTAINER_VOLUME2"/container-station/usr
  37.     setfacl -m user:$2:rx /var/lib/lxd
  38.     setfacl -m user:$2:rx /var/lib/lxd/containers
  39.     setfacl -m user:$2:rx /var/lib/lxd/devices
  40.     setfacl -m user:$2:rx /var/lib/lxd/shmounts
  41.     setfacl -m user:$2:rx /var/lib/lxd/snapshots
  42.     setfacl -m user:$2:rx /var/lib/lxd/storage-pools
  43.     setfacl -m user:$2:rx /var/lib/lxd/storage-pools/default/containers
  44.     sleep 2
  45.   elif [ "$1" == "unset" ]; then
  46.     setfacl -R -x user:$2 "$CONTAINER_VOLUME1"
  47.     setfacl -R -x user:$2 "$CONTAINER_VOLUME2"/container-station
  48.     setfacl -R -x user:$2 /var/lib/lxd/
  49.     setfacl -x user:$2 /var/lib/lxd
  50.     sleep 2
  51.   else
  52.     echo "Invalid operation"
  53.     exit 1
  54. fi
  55.  
Add Comment
Please, Sign In to add comment