alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.55k stars 219 forks source link

🐛 [unpackerr] Unable to change default Folder path #502

Closed nathang21 closed 2 years ago

nathang21 commented 2 years ago

Which addon?

Describe the bug

I am unable to change the default watch folders according to the official unpackerr instructions. My config file is in /config/unpackerr.conf and I took the example file from the parent repo, and only changed the folder.path and folder.extract_path options, which are both set to /media.

My theory is that the addon environmental variables of UN_FOLDER_0_PATH and UN_FOLDER_0_EXTRACT_PATH are overriding the config file, since the log shows the config file is read. The way the addon is currently setup, there is no way to change the default values without a fork.

To Reproduce

  1. Save config file
  2. Start addon
  3. View log

Expected: Logs to show config file read, and folder /media to be scanned. Actual: Logs show config file read, but folder still remains set to default Env values of /share/...

Full addon log

022/10/04 09:56:36.872149 start.go:128: Unpackerr v0.10.0 Starting! (PID: 7) 2022-10-04 09:56:36.869420559 -0400 EDT m=+0.002993323
2022/10/04 09:56:36.872312 logs.go:210: ==> GoLift Discord: https://golift.io/discord <==
2022/10/04 09:56:36.872333 logs.go:211: ==> Startup Settings <==
2022/10/04 09:56:36.872365 sonarr.go:87:  => Sonarr Config: 0 servers
2022/10/04 09:56:36.872382 radarr.go:88:  => Radarr Config: 0 servers
2022/10/04 09:56:36.872397 lidarr.go:87:  => Lidarr Config: 0 servers
2022/10/04 09:56:36.872412 readarr.go:87:  => Readarr Config: 0 servers
2022/10/04 09:56:36.872485 folder.go:69:  => Folder Config: 1 path: /share/downloads_packed, extract to: /share/downloads_unpacked (delete after:0s, delete orig:false, log file: true, move back:false, event buffer:20000)
2022/10/04 09:56:36.872511 logs.go:217:  => Using Config File: /config/unpackerr.conf
2022/10/04 09:56:36.872527 logs.go:218:  => Parallel: 1
2022/10/04 09:56:36.872541 logs.go:219:  => RAR Passwords: 0
2022/10/04 09:56:36.872558 logs.go:220:  => Interval: 2m
2022/10/04 09:56:36.872591 logs.go:221:  => Start Delay: 1m
2022/10/04 09:56:36.872616 logs.go:222:  => Retry Delay: 5m, max: 3
2022/10/04 09:56:36.872630 logs.go:223:  => Debug / Quiet: true / false
2022/10/04 09:56:36.872689 logs.go:226:  => Directory & File Modes: 0755 & 0644
2022/10/04 09:56:36.872708 webhook.go:229:  => Webhook Configs: 0 URLs
2022/10/04 09:56:36.872724 cmdhook.go:124:  => Command Hook Configs: 0 cmds
2022/10/04 09:56:36.873120 folder.go:199: [ERROR] Folder (cannot watch): stat /share/downloads_packed: no such file or directory
2022/10/04 09:57:36.875959 logs.go:143: [Unpackerr] Queue: [0 waiting] [0 queued] [0 extracting] [0 extracted] [0 imported] [0 failed] [0 deleted]

Full addon config

N/A this addon has no HA config, but here is my /config/unpackerr.conf file.

##      Unpackerr Example Configuration File      ##
## The following values are application defaults. ##
## Environment Variables may override all values. ##
####################################################

# [true/false] Turn on debug messages in the output. Do not wrap this in quotes.
# Recommend trying this so you know what it looks like. I personally leave it on.
debug = true

# Disable writing messages to stdout. This silences the app. You should set a log
# file below if you set this to true. Recommended when starting with systemctl.
quiet = false

# Setting activity to true will silence all app queue log lines with only zeros.
# Set this to true when you want less log spam.
activity = false

# The application queue data is logged on an interval. Adjust that interval with this setting.
# Default is a minute. 2m, 5m, 10m, 30m, 1h are also perfectly acceptable.
log_queues = "1m"

# Write messages to a log file. This is the same data that is normally output to stdout.
# This setting is great for Docker users that want to export their logs to a file.
# The alternative is to use syslog to log the output of the application to a file.
# Default is no log file; this is unset. log_files=0 turns off auto-rotation.
# Default files is 10 and size(mb) is 10 Megabytes; both doubled if debug is true.
# Windows paths must use two backslashes: "C:\\Some\\Path\\Unpacker.log" (true everywhere).
#log_file = "/downloads/unpackerr.log"
log_files = 10
log_file_mb = 10

# How often to poll sonarr and radarr.
# Recommend 1m-5m. Uses Go Duration.
interval = "2m"

# How long an item must be queued (download complete) before extraction will start.
# One minute is the historic default and works well. Set higher if your downloads
# take longer to finalize (or transfer locally). Uses Go Duration.
start_delay = "1m"

# How long to wait before removing the history for a failed extraction.
# Once the history is deleted the item will be recognized as new and
# extraction will start again. Uses Go Duration.
retry_delay = "5m"

# How many files may be extracted in parallel. 1 works fine.
# Do not wrap the number in quotes. Raise this only if you have fast disks and CPU.
parallel = 1

# Use these configurations to control the file modes used for newly extracted
# files and folders. Recommend 0644/0755 or 0666/0777.
file_mode = "0644"
dir_mode = "0755"

##-Notes-#######-READ THIS!!!-##################################################
## The following sections can be repeated if you have more than one Sonarr,   ##
## Radarr or Lidarr, Readarr, Folder, Webhook, or Command Hook.               ##
## You MUST uncomment the [[header]] and api_key at a minimum for Starr apps. ##
################################################################################

#[[sonarr]]
#  url = "http://127.0.0.1:8989"
#  api_key = "0123456789abcdef0123456789abcdef"
## File system path where downloaded Sonarr items are located.
#  paths = ["/downloads"]
## Default protocols is torrent. Alternative: "torrent,usenet"
#  protocols = "torrent"
## How long to wait for a reply from the backend.
#  timeout = "10s"
## If you use this app with NZB you may wish to delete archives after extraction.
## General recommendation is: do not enable this for torrent use.
## Setting this to true deletes the entire original download folder after import.
#  delete_orig = false

#[[radarr]]
#  url = "http://127.0.0.1:7878"
#  api_key = "0123456789abcdef0123456789abcdef"
## File system path where downloaded Radarr items are located.
#  paths = ["/downloads"]
## Default protocols is torrents. Alternative: "torrent,usenet"
#  protocols = "torrent"
## How long to wait for a reply from the backend.
#  timeout = "10s"
## If you use this app with NZB you may wish to delete archives after extraction.
## General recommendation is: do not enable this for torrent use.
## Setting this to true deletes the entire original download folder after import.
#  delete_orig = false

#[[lidarr]]
#  url = "http://127.0.0.1:8686"
#  api_key = "0123456789abcdef0123456789abcdef"
## File system path where downloaded Lidarr items are located.
#  paths = ["/downloads"]
## Default protocols is torrent. Alternative: "torrent,usenet"
#  protocols = "torrent"
## How long to wait for a reply from the backend.
#  timeout = "10s"
## If you use this app with NZB you may wish to delete archives after extraction.
## General recommendation is: do not enable this for torrent use.
## Setting this to true deletes the entire original download folder after import.
#  delete_orig = false

#[[readarr]]
#  url = "http://127.0.0.1:8787"
#  api_key = "0123456789abcdef0123456789abc"
## File system path where downloaded Readarr items are located.
#  paths = ["/downloads"]
## Default protocols is torrent. Alternative: "torrent,usenet"
#  protocols = "torrent"
## How long to wait for a reply from the backend.
#  timeout = "10s"
## If you use this app with NZB you may wish to delete archives after extraction.
## General recommendation is: do not enable this for torrent use.
## Setting this to true deletes the entire original download folder after import.
#  delete_orig = false

##################################################################################
### ###  STOP HERE ### STOP HERE ### STOP HERE ### STOP HERE #### STOP HERE  ### #
### Only using Starr apps? The things above. The below configs are OPTIONAL. ### #
##################################################################################

##-Folders-#######################################################################
## This application can also watch folders for things to extract. If you copy a ##
## subfolder into a watched folder (defined below) any extractable items in the ##
## folder will be decompressed. This has nothing to do with Starr applications. ##
##################################################################################
[[folder]]
## Windows paths must use two backslashes: "C:\\Some\\Folder\\To\\Watch"
path = "/media"
## Path to extract files to. The default (leaving this blank) is the same as `path` (above).
extract_path = "/media"
## Delete extracted or original files this long after extraction. Set to 0 to disable all deletes. Uses Go Duration.
#  delete_after = "10m"
## Delete extracted files after successful extraction? true/false, no quotes. Honors delete_after.
#  delete_files = false
## Delete original items after successful extraction? true/false, no quotes. Honors delete_after.
#  delete_original = false
## Disable extraction log (unpackerred.txt) file creation? true/false, no quotes.
#  disable_log = false
## Move extracted files into original folder? If false, files go into an _unpackerred folder.
#  move_back = false

################
### Webhooks ###
################
# Sends a webhook when an extraction queues, starts, finishes, and/or is deleted.
# Created to integrate with notifiarr.com.
# Also works natively with Discord.com, Telegram.org, and Slack.com webhooks.
# Can possibly be used with other services by providing a custom template_path.
###### Don't forget to uncomment [[webhook]] and url at a minimum !!!!
#[[webhook]]
#  url    = "https://notifiarr.com/api/v1/notification/unpackerr/api_key_from_notifiarr_com"
#  name   = ""    # Set this to hide the URL in logs.
#  silent = false # do not log success (less log spam)
#  events = [0]   # list of event ids to include, 0 == all.
## Advanced Optional Webhook Configuration
#  nickname      = ""    # Used in Discord and Slack templates as bot name, in Telegram as chat_id.
#  channel       = ""    # Also passed into templates. Used in Slack templates for destination channel.
#  exclude       = []    # list of apps to exclude, ie. ["radarr", "lidarr"]
#  template_path = ""    # Override internal webhook template for discord.com or other hooks.
#  template      = ""    # Override automatic template detection. Values: notifiarr, discord, telegram, gotify, pushover, slack
#  ignore_ssl    = false # Set this to true to ignore the SSL certificate on the server.
#  timeout       = "10s" # You can adjust how long to wait for a server response.
#  content_type  = "application/json" # If your custom template uses another MIME type, set this.

#####################
### Command Hooks ###
#####################
# Executes a script or command when an extraction queues, starts, finishes, and/or is deleted.
# All data is passed in as environment variables. Try /usr/bin/env to see what variables are available.
###### Don't forget to uncomment [[cmdhook]] and url at a minimum !!!!
#[[cmdhook]]
#  command = "/my/cool/app" # Path to command or script.
#  shell   = false # Runs the command inside /bin/sh ('nix) or cmd.exe (Windows).
#  name    = ""    # Provide an optional name for logging.
#  silent  = false # Hides command output from logs.
#  events  = [0]   # list of event ids to include, 0 == all.
## Optional Command Hook Configuration
#  exclude       = []    # list of apps to exclude, ie. ["radarr", "lidarr"]
#  timeout       = "10s" # You can adjust how long to wait for a server response.

System

Home Assistant 2022.9.7 Supervisor 2022.09.1 Operating System 9.0 Frontend 20220907.2 - latest

alexbelgium commented 2 years ago

Hi, thanks for the detailed info. Indeed the current setup doesn't allow to change the folders from /share/downloads_packed. Alas it uses golift and does not include bash so I'm not sure how to implement modifications. Only solution I see is that I completely remove the env variable and everyone just uses the config file. Seems the only solution to me unless you know golift

nathang21 commented 2 years ago

Thanks for the quick reply!

That makes sense to me, however I just tried again after this change 5e75a4f, but now it can't seem to find the folder.

Is what what you meant by bash not being included, it's not possible to change folders within the config, only the other general options?

2022/10/04 15:05:36.651160 start.go:128: Unpackerr v0.10.0 Starting! (PID: 7) 2022-10-04 15:05:36.648845218 -0400 EDT m=+0.033085554
2022/10/04 15:05:36.653315 logs.go:210: ==> GoLift Discord: https://golift.io/discord <==
2022/10/04 15:05:36.653330 logs.go:211: ==> Startup Settings <==
2022/10/04 15:05:36.653355 sonarr.go:87:  => Sonarr Config: 0 servers
2022/10/04 15:05:36.653363 radarr.go:88:  => Radarr Config: 0 servers
2022/10/04 15:05:36.653370 lidarr.go:87:  => Lidarr Config: 0 servers
2022/10/04 15:05:36.653376 readarr.go:87:  => Readarr Config: 0 servers
2022/10/04 15:05:36.653396 folder.go:69:  => Folder Config: 1 path:  (delete after:0s, delete orig:false, log file: true, move back:false, event buffer:20000)
2022/10/04 15:05:36.653410 logs.go:217:  => Using Config File: /config/unpackerr.conf
2022/10/04 15:05:36.653417 logs.go:218:  => Parallel: 1
2022/10/04 15:05:36.653423 logs.go:219:  => RAR Passwords: 0
2022/10/04 15:05:36.653430 logs.go:220:  => Interval: 2m
2022/10/04 15:05:36.653436 logs.go:221:  => Start Delay: 1m
2022/10/04 15:05:36.653442 logs.go:222:  => Retry Delay: 5m, max: 3
2022/10/04 15:05:36.653447 logs.go:223:  => Debug / Quiet: true / false
2022/10/04 15:05:36.653453 logs.go:226:  => Directory & File Modes: 0755 & 0644
2022/10/04 15:05:36.653460 webhook.go:229:  => Webhook Configs: 0 URLs
2022/10/04 15:05:36.653468 cmdhook.go:124:  => Command Hook Configs: 0 cmds
2022/10/04 15:05:36.653761 folder.go:199: [ERROR] Folder (cannot watch): stat : no such file or directory

Only solution I see is that I completely remove the env variable and everyone just uses the config file.

This makes sense to me, perhaps even including the example or a default config file in the repo would be helpful, but the instructions were clear to make a copy from the source so that is minor.

nathang21 commented 2 years ago

Update: I just saw version 0.10.1-3 and gave it another try, it's now detecting the folder for me with the following config.

Config:

[[folder]]
## Windows paths must use two backslashes: "C:\\Some\\Folder\\To\\Watch"
path = "/media"

Logs:

...
2022/10/04 15:50:15.394343 folder.go:112: [Folder] Watching (fsnotify): /media/
2022/10/04 15:50:15.395043 folder.go:123: [Folder] Polling @ 1s: /media/
2022/10/04 15:51:15.392176 logs.go:143: [Unpackerr] Queue: [0 waiting] [0 queued] [0 extracting] [0 extracted] [0 imported] [0 failed] [0 deleted]
2022/10/04 15:51:15.392263 logs.go:145: [Unpackerr] Totals: [0 retries] [0 finished] [0|0 webhooks] [0|0 cmdhooks] [stacks; event:0, hook:0, del:0]

Will follow up later to confirm extractions are working as expected, I may need to see if subfolders can be included or re-arrange my structure.

alexbelgium commented 2 years ago

I, thanks indeed you were right the # had to be removed before the "folder"! Looks it working too on my system. Thanks

nathang21 commented 2 years ago

Glad to hear! Progress, however still not getting it to actually detect or extract anything despite having multiple rar files in the watched folders.

It seems like I could be running into this docker issue https://github.com/davidnewhall/unpackerr/issues/85 but that was already fixed upstream so i'm at a loss, may need to open a bug upstream, but i'm really curious how your's is working.

2022/10/04 16:59:06.243740 folder.go:112: [Folder] Watching (fsnotify): /media/Movies, /media/TV Shows
2022/10/04 16:59:06.243827 folder.go:123: [Folder] Polling @ 1s: /media/Movies, /media/TV Shows
2022/10/04 17:00:06.242975 logs.go:143: [Unpackerr] Queue: [0 waiting] [0 queued] [0 extracting] [0 extracted] [0 imported] [0 failed] [0 deleted]
2022/10/04 17:00:06.243031 logs.go:145: [Unpackerr] Totals: [0 retries] [0 finished] [0|0 webhooks] [0|0 cmdhooks] [stacks; event:0, hook:0, del:0]
alexbelgium commented 2 years ago

Hi, I've never used this addon, so I'm not sure... I've just tested it starts without error. Have you tried broadening permissions for the folder or checking the upstream container documentation (like putting temporarily 777 recursively to check)?

alexbelgium commented 2 years ago

@hacshacdgacs hi, are you still using unpackerr? Is it working as expected? Thanks!

hacshacdgacs commented 2 years ago

Hi, no sorry, I've moved on from using unpackerr as I couldn't find a way of working it into my system properly

On Wed, 5 Oct 2022, 16:45 Alexandre, @.***> wrote:

@hacshacdgacs https://github.com/hacshacdgacs hi, are you still using unpackerr? Is it working as expected? Thanks!

— Reply to this email directly, view it on GitHub https://github.com/alexbelgium/hassio-addons/issues/502#issuecomment-1267895758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUMWJOD35AMDQLS5KH4EM73WBT2UHANCNFSM6AAAAAAQ4TP4HE . You are receiving this because you were mentioned.Message ID: @.***>

alexbelgium commented 2 years ago

Thanks!

Perhaps I'll switch the upstream image to https://hub.docker.com/layers/hotio/unpackerr to allow it to use bash and change user...

nathang21 commented 2 years ago

Have you tried broadening permissions for the folder or checking the upstream container documentation (like putting temporarily 777 recursively to check)?

Just gave that a try, no change. Image starts, config file read, folder watching starts, but no rar files are detected.

Perhaps I'll switch the upstream image to hub.docker.com/layers/hotio/unpackerr to allow it to use bash and change user...

I just took a look at that upstream image, seems worth a shot but otherwise looks almost the same so i'm not sure if that with help.

alexbelgium commented 2 years ago

I've changed the upstream image. Key thing I think is that the zip files must have the correct ownership per puid/pgid described in the log

nathang21 commented 2 years ago

Progress again, I was able to change some permissions which seemed to do the trick. Although, in some cases the permissions didn't ACTUALLY change, I just re-applied them, which I suspect caused fsnotify to pick it up and Unpacker then begin processing the files.

chmod 755 ./* # for all folders
chmod 644 ./* # for all files

Previously I didn't even see any logs of detected files, no permission denied or anything, just empty logs. Which makes me still suspicious about https://github.com/davidnewhall/unpackerr/issues/85.


I'm also using your qBitorrent and Plex NAS addons, and I am hoping to get a fully automated pipeline from qBitorrent download to media folder --> Unpacker extract any archived files, which are then scanned by Plex.

I'll keep testing, but i'm not sure how to make qBittorrent set the proper file permissions / cause Unpacker to detect the files. Perhaps I could use the Autorun program feature of qBittorrent once a download finishes, but I can't find any documentation on this.

I am trying it with the following, will see if this works when I download something again. Auto Run Enabled --> Autorun Program

chmod 644 %F/*

In this case %F = "Content path (same as root path for torrents with multiple files)"

Assuming the file permissions are correct to begin with, I wonder if a simple touch would cause fsnotify + Unpacker to detect them.

alexbelgium commented 2 years ago

Hi, in theory I've enabled automatic ownership and definition of the downloads and extraction folders through the addon options. Hope it will smoothen the installation. Regarding your issue... Not sure how to help. Cron job with periodic touch ?

nathang21 commented 2 years ago

Hi Alex, thank you so much that did the trick. I think even though the permissions were correct, the group was set to root instead of hassio. Your new startup script auto-fixed all of the owners and it's now working end-to-end more or less.

As for the fsnotify issue, i'll play around with solutions via an autorun or cron and update here if/when a get that working. Feel free to close this issue in the meantime if you prefer.

alexbelgium commented 2 years ago

Thanks for the feedback. Given the title of the issue is with folders definition, let's close it and we could re-open a new one if indeed there is a new function to solve the fsnotify issue. Have a nice day!