Unraid Community App Store

If they didn't mention it, then it's going to be fine, for now.

1 Like

The Unraid version is the official docker container, which is sticking around as a supported platform :slightly_smiling_face:

2 Likes

I'm experiencing the same problem with file permissions in the fancybits/channels-dvr:tve docker (channelsdvr_intel from the Unraid App store) - files are created are owned by root with rw-r-r permissions and the container seems to ignore a UMASK variable set to 0 as, umask is 022 in the terminal - also "id nobody" indicates the uid/gid are 65534/65534 vs 99/100 so I am not sure what to do here...

That's something that's an issue with the official Channels container, and would need an update by a Channels dev to support.

I got help from ChatGPT to write a script to fix permissions periodically within the DVR folder. Will update this post when I can.

Thanks - Unraid has a tool called "Docker Safe New Perms" that does this.

Yes, that will do it. Once the show folders have correct permissions, I think any new recordings with that folder will be fine. However, newly created show folders won’t.

Here's the script. You'll need to change the Recordings directory. It runs in the User Scripts plugin and runs every 5 minutes.

#!/bin/bash
# Script to monitor and fix permissions for Channels DVR recordings

# Path to your recordings directory (with proper escaping for spaces)
RECORDINGS_DIR="/mnt/user/media/Channels DVR/TV"

# Log file location
LOG_FILE="/tmp/channels_permissions.log"

# Maximum log size in bytes (1MB = 1048576)
MAX_LOG_SIZE=1048576

# Timestamp function
timestamp() {
  date "+%Y-%m-%d %H:%M:%S"
}

# Check if log file exists and is too large
if [ -f "$LOG_FILE" ] && [ $(stat -c%s "$LOG_FILE") -gt $MAX_LOG_SIZE ]; then
  # Keep only the last 100 lines
  tail -n 100 "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
  echo "$(timestamp) - Log file rotated due to size" >> "$LOG_FILE"
fi

echo "$(timestamp) - Starting permission fix check" >> "$LOG_FILE"

# Find directories created/modified in the last 10 minutes
find "$RECORDINGS_DIR" -type d -mmin -10 | while read dir; do
  # Check if the directory needs permission fixing (if owned by root)
  if [ "$(stat -c '%U' "$dir")" == "root" ]; then
    echo "$(timestamp) - Fixing permissions for: $dir" >> "$LOG_FILE"
    
    # Fix permissions with chmod -R 0777
    chmod -R 0777 "$dir"
    
    # Also try to fix ownership
    chown -R nobody:users "$dir"
    
    echo "$(timestamp) - Applied permissions to: $dir" >> "$LOG_FILE"
  fi
done

echo "$(timestamp) - Completed permission fix check" >> "$LOG_FILE"

Thanks - really nice script - I've added it to my user scripts

EDIT: I'll have to modify it to find files, not folders, owned by root and change permissions - I have a lot of folders for programs that get recorded daily (news) and I had already changed the ownership to nobody

This does the job but doesn't log any results and doesn't limit checking to newly created folders or files - will have to keep working on this...

# change ownership of all folders to nobody and permissions to 777
find /mnt/user/dvr/TV -type d -user root -exec chown nobody: {} \; -exec chmod 777 {} \;

# change ownership of files to nobody and permissions to 666
find /mnt/user/dvr/TV -type f -user root -exec chown nobody: {} \; -exec chmod 666 {} \;

Does anyone know how to change owner, group and permissions in Linux (Unraid) without changing the file date?

The time that gets changed is the ‘change time’, and the ‘access time’ and ‘modified time’ isn’t updated. There’s not a good way to change the ctime, and I wouldn’t recommend doing it.

Generally the timestamp that most applications use is the mtime, and updating that is easiest done with the touch command.

My bad - chmod and chown don't actually change the timestamp, my setup script to test my Channels DVR nightly maintenance script needed to do a cp -p to copy the test file and preserve it's date.

Anyways, below is a script FWIW for purposes of: (1) moving older recordings to secondary storage (in my case off the NVMe cache and to the HDD array) and (2) fixing folder and file permissions and ownership because the Unraid Docker creates new files as root:root 644 or 755 for folders. This is a work in progress but appears to perform the task.

#!/bin/bash

# Log file location
LOG_FILE="/tmp/channels_permissions.log"

# Maximum log size in bytes (1MB = 1048576)
MAX_LOG_SIZE=1048576

# Timestamp function
timestamp() {
  date "+%Y-%m-%d %H:%M:%S"
}

function do_it() {
  src=$1
  dst=$2
  age=$3

  # change ownership of all folders to nobody and permissions to 777
  echo "changing folder permissions" >> "$LOG_FILE"
  find "$src/" -type d -user root -exec echo {} >> "$LOG_FILE" \; -exec chown nobody: {} \; -exec chmod 777 {} \;

  # change ownership of files to nobody and permissions to 666
  echo "changing file permissions" >> "$LOG_FILE"
  find "$src/" -type f -user root -exec echo {} >> "$LOG_FILE" \; -exec chown nobody:users {} \; -exec chmod 666 {} \;

  # rsync files
  echo "moving to archive" >> "$LOG_FILE"
  find "$src/" -type f -mtime +"$age" -exec echo {} >> "$LOG_FILE" \;
  find "$src/" -type f -mtime +"$age" -printf %P\\0 | rsync --remove-source-files -avPR -X --files-from=- --from0 "$src/" "$dst/"

  #Clean up orphaned empty dirs
  echo "deleting empty folders" >> "$LOG_FILE"
  find "$src/" -empty -type d -mindepth 1 -exec echo {} >> "$LOG_FILE" \;
  find "$src/" -empty -type d -mindepth 1 -delete
}

# Check if log file exists and is too large
if [ -f "$LOG_FILE" ] && [ $(stat -c%s "$LOG_FILE") -gt $MAX_LOG_SIZE ]; then
  # Keep only the last 100 lines
  tail -n 100 "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
  echo "$(timestamp) - Log file rotated due to size" >> "$LOG_FILE"
fi

echo "$(timestamp) - Starting Channels DVR Maintenance" >> "$LOG_FILE"

# fix permissions and move old files (30 days+) to archive - TV
do_it "/mnt/user/dvr/TV" "/mnt/user/dvr-archive/TV" 30

# fix permissions and move old files (7 days+) to archive - Movies
do it "/mnt/user/dvr/Movies" "/mnt/user/dvr-archive/Movies" 7

# fix permissions and move old files (7 days+) to archive - PlayOn
do_it "/mnt/user/dvr/PlayOn" "/mnt/user/dvr-archive/PlayOn" 7

echo "$(timestamp) - Completed Channels DVR Maintenance" >> "$LOG_FILE"

Does anyone know how to implement VPN in Unraid to the Channels docker? I'd like to restrict the Channels docker to use my VPN, but when I configure the docker to use it Channels becomes inaccessible. The options are:

VPN tunneled access for docker
Remote access to LAN
Server to server access
LAN to LAN access
Server hub & spoke access
LAN hub & spoke access
Remote tunneled access
VPN tunneled access for system
VPN tunneled access for docker

Is there a specific one I should choose? Thanks.

I haven’t done this, but you’ll need to open the 8089 port on the VPN container and not on the Channels container. And the configuration for access would be through the VPN container.

1 Like