goose-ws / bash-scripts

A collection of bash scripts I've hacked together over time
MIT License
10 stars 3 forks source link

[Bug] Script cannot find my root folder #17

Closed retardgerman closed 4 weeks ago

retardgerman commented 4 weeks ago

I am encountering an issue with the sonarr-update-tba.bash script where it is unable to locate the root folder of my sonarr instance.

I am using a Synology NAS, and Sonarr is running in a Docker container. My media files are stored in '/data/media/tv'.

This is my env:


# The Sonarr instances you want to interact with. 
# If you are running Sonarr via Docker, you can use 'docker:<container_name>' to let the script automatically figure out the IP address
#   e.g. if your container name is 'sonarr', then containerIp=("docker:sonarr")
#   For multiple Sonarr instances, just add additional array items, e.g. containerIp=("docker:sonarr" "docker:sonarr-4k")
# If your instance is hosted on your system, you could just provide a direct IPv4 address, assuming it is valid/static
#   e.g. if your instance is reachable via localhost, then containerIp=("127.0.0.1")
#   Currently multiple Sonarr instances outside of Docker are unsupported. If you have multiple instances running on your host, create
#   an issue and I'll try and motivate myself to add support for your situation.
## This is an array
containerIp=("172.21.0.4")

# If your Sonarr instance is not provided via Docker, you must uncomment the below variable and point to where your 'config.xml' for Sonarr is
## This is a string
sonarrConfig="/volume1/docker/appdata/sonarr/config.xml"

# Are we allowed to check for and notify of updates each time the script runs?
# Can be "Yes" "No" "True" "False"
## This is a string
updateCheck="Yes"

# How verbose should our output be?
# Possible values:
# 1 - Error only
# 2 - Informational
# 3 - Verbose
## This is a string
outputVerbosity="2"

# If you have entire libraries you want to ignore, you can run the script with verbose output, and watch for the
# line "Detected [int] libraries", then put the correspnding library ID into this array to have it ignored on future runs.
# If you have multiple Sonarr containers running in Docker, you should prefix the ID with the container
# you want it to correspond to, for example instead of:
#     ignoreLibraryArr=("123")
# you would do:
#     ignoreLibraryArr=("docker:sonarr:123")
## This is an array
ignoreLibrary=()

# If you have entire series you want to ignore, you can run the script with verbose output, and watch for the
# line "Found series ID:", then put the series ID into this array to have it ignored on future runs.
# If you have multiple Sonarr containers running in Docker, you should prefix the ID with the container
# you want it to correspond to, for example instead of:
#     ignoreSeries=("456")
# you would do:
#     ignoreSeries=("docker:sonarr:456")
## This is an array
ignoreSeries=()

# If you have files you want to ignore, you can run the script with verbose output, and watch for the
# line "Found episode ID:", then put the episode ID into this array to have it ignored on future runs.
# If you have multiple Sonarr containers running in Docker, you should prefix the ID with the container
# you want it to correspond to, for example instead of:
#     ignoreEpisodes=("789")
# you would do:
#     ignoreEpisodes=("docker:sonarr:789")
## This is an array
ignoreEpisodes=()

And these are my logs:

sonarr-update-tba.bash   ::   2024-08-15 13:44:07   ::   [info]  Processing instance: 172.21.0.4
sonarr-update-tba.bash   ::   2024-08-15 13:44:07   ::   [info]  Configuration file retrieved
sonarr-update-tba.bash   ::   2024-08-15 13:44:07   ::   [info]  Port retrieved from config file
sonarr-update-tba.bash   ::   2024-08-15 13:44:07   ::   [info]  API key retrieved from config file
sonarr-update-tba.bash   ::   2024-08-15 13:44:07   ::   [info]  No URL base detected
sonarr-update-tba.bash   ::   2024-08-15 13:44:07   ::   [info]  Checking API functionality
sonarr-update-tba.bash   ::   2024-08-15 13:44:08   ::   [info]  API authorization succeeded
sonarr-update-tba.bash   ::   2024-08-15 13:44:08   ::   [info]  Detected 1 libraries
sonarr-update-tba.bash   ::   2024-08-15 13:44:08   ::   [info]  Checking for TBA/TBD items in /data/media/tv
find: `/data/media/tv': No such file or directory
sonarr-update-tba.bash   ::   2024-08-15 13:44:08   ::   [info]  Located 0 files to process

What am I doing wrong!:D would appreciate some help!

goose-ws commented 4 weeks ago

The way you've denoted the container IP address and path to the config file in your .env file leads to script to believe that this is a host-based instance of Sonarr, not a docker-based instance. As a result, it's searching for the path /data/media/tv on your host, not in your docker container.

Solution is to denote your Sonarr instance as described in lines 2/3 of the .env file. You can also comment out the sonarrConfig variable on line 14, as your config will be automatically retrieved from inside the container, since it's not a host-based instance.

retardgerman commented 4 weeks ago

If I am doing that, I get this is error:

sonarr-update-tba.bash   ::   2024-08-15 14:23:24   ::   [info]  Processing instance: docker:sonarr
jq: error: guides_default/0 is not defined at <top-level>, line 1:
.[] | .NetworkSettings.Networks.trash-guides_default.IPAddress                                      
jq: 1 compile error
sonarr-update-tba.bash   ::   2024-08-15 14:23:25   ::   [error] Unable to determine IP address via networking mode: trash-guides_default

Since I have completely followed the documentation of the TraSH Guides, this probably leads to problems.

goose-ws commented 4 weeks ago

What's the output of:

docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{println $k}}{{end}}' sonarr
retardgerman commented 4 weeks ago

trash-guides_default

goose-ws commented 4 weeks ago

Thanks. What about docker inspect sonarr?

retardgerman commented 4 weeks ago
[
    {
        "Id": "6de34aa6a6ace0ef2270ef452b46eb116892537669c6c378efed561ca7a73a2a",
        "Created": "2024-07-25T15:29:29.739289871Z",
        "Path": "/init",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 18956,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2024-08-15T03:32:38.177351786Z",
            "FinishedAt": "2024-08-14T22:27:57.326545145Z",
            "StartedTs": 1723692758,
            "FinishedTs": 1723674477
        },
        "Image": "sha256:def528700c5a2452b1c3909cfc5d34ba825182d19882bda26b9724ec1745f018",
        "ResolvConfPath": "/volume1/@docker/containers/6de34aa6a6ace0ef2270ef452b46eb116892537669c6c378efed561ca7a73a2a/resolv.conf",
        "HostnamePath": "/volume1/@docker/containers/6de34aa6a6ace0ef2270ef452b46eb116892537669c6c378efed561ca7a73a2a/hostname",
        "HostsPath": "/volume1/@docker/containers/6de34aa6a6ace0ef2270ef452b46eb116892537669c6c378efed561ca7a73a2a/hosts",
        "LogPath": "/volume1/@docker/containers/6de34aa6a6ace0ef2270ef452b46eb116892537669c6c378efed561ca7a73a2a/6de34aa6a6ace0ef2270ef452b46eb116892537669c6c378efed561ca7a73a2a-json.log",
        "Name": "/sonarr",
        "RestartCount": 0,
        "Driver": "btrfs",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/volume1/docker/appdata/sonarr:/config:rw",
                "/etc/localtime:/etc/localtime:ro",
                "/volume1/data:/data:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {
                    "max-file": "10",
                    "max-size": "200k"
                }
            },
            "NetworkMode": "trash-guides_default",
            "PortBindings": {
                "8989/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "32782"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": [],
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "IMAGE_STATS=ewogICJhcHAiOiAic29uYXJyIiwKICAiaW1hZ2UiOiAiaG90aW8vc29uYXJyOnJlbGVhc2UiLAogICJyZXZpc2lvbiI6ICJmOTQ3MGQzIiwKICAidmVyc2lvbiI6ICI0LjAuOC4xODc0Igp9Cg==",
                "BUILD_ARCHITECTURE=linux-amd64",
                "APP_DIR=/app",
                "CONFIG_DIR=/config",
                "PUID=1029",
                "PGID=100",
                "UMASK=002",
                "TZ=Europe/Berlin",
                "XDG_CONFIG_HOME=/.config",
                "XDG_CACHE_HOME=/.cache",
                "XDG_DATA_HOME=/.local/share",
                "LANG=en_US.UTF-8",
                "LANGUAGE=en_US:en",
                "LC_ALL=en_US.UTF-8",
                "S6_BEHAVIOUR_IF_STAGE2_FAILS=2",
                "S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0",
                "S6_SERVICES_GRACETIME=180000",
                "S6_STAGE2_HOOK=/etc/s6-overlay/init-hook",
                "VPN_ENABLED=false",
                "VPN_CONF=wg0",
                "VPN_PROVIDER=generic",
                "VPN_LAN_NETWORK=",
                "VPN_LAN_LEAK_ENABLED=false",
                "VPN_EXPOSE_PORTS_ON_LAN=",
                "VPN_AUTO_PORT_FORWARD=true",
                "VPN_AUTO_PORT_FORWARD_TO_PORTS=",
                "VPN_KEEP_LOCAL_DNS=false",
                "VPN_FIREWALL_TYPE=auto",
                "VPN_HEALTHCHECK_ENABLED=false",
                "PRIVOXY_ENABLED=false",
                "UNBOUND_ENABLED=false",
                "VPN_PIA_USER=",
                "VPN_PIA_PASS=",
                "VPN_PIA_PREFERRED_REGION=",
                "VPN_PIA_DIP_TOKEN=no",
                "VPN_PIA_PORT_FORWARD_PERSIST=false",
                "WEBUI_PORTS=8989/tcp,8989/udp"
            ],
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": null,
            "Name": "btrfs"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/volume1/docker/appdata/sonarr",
                "Destination": "/config",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/volume1/data",
                "Destination": "/data",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/etc/localtime",
                "Destination": "/etc/localtime",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "6de34aa6a6ac",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "8989/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "IMAGE_STATS=ewogICJhcHAiOiAic29uYXJyIiwKICAiaW1hZ2UiOiAiaG90aW8vc29uYXJyOnJlbGVhc2UiLAogICJyZXZpc2lvbiI6ICJmOTQ3MGQzIiwKICAidmVyc2lvbiI6ICI0LjAuOC4xODc0Igp9Cg==",
                "BUILD_ARCHITECTURE=linux-amd64",
                "APP_DIR=/app",
                "CONFIG_DIR=/config",
                "PUID=1029",
                "PGID=100",
                "UMASK=002",
                "TZ=Europe/Berlin",
                "XDG_CONFIG_HOME=/.config",
                "XDG_CACHE_HOME=/.cache",
                "XDG_DATA_HOME=/.local/share",
                "LANG=en_US.UTF-8",
                "LANGUAGE=en_US:en",
                "LC_ALL=en_US.UTF-8",
                "S6_BEHAVIOUR_IF_STAGE2_FAILS=2",
                "S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0",
                "S6_SERVICES_GRACETIME=180000",
                "S6_STAGE2_HOOK=/etc/s6-overlay/init-hook",
                "VPN_ENABLED=false",
                "VPN_CONF=wg0",
                "VPN_PROVIDER=generic",
                "VPN_LAN_NETWORK=",
                "VPN_LAN_LEAK_ENABLED=false",
                "VPN_EXPOSE_PORTS_ON_LAN=",
                "VPN_AUTO_PORT_FORWARD=true",
                "VPN_AUTO_PORT_FORWARD_TO_PORTS=",
                "VPN_KEEP_LOCAL_DNS=false",
                "VPN_FIREWALL_TYPE=auto",
                "VPN_HEALTHCHECK_ENABLED=false",
                "PRIVOXY_ENABLED=false",
                "UNBOUND_ENABLED=false",
                "VPN_PIA_USER=",
                "VPN_PIA_PASS=",
                "VPN_PIA_PREFERRED_REGION=",
                "VPN_PIA_DIP_TOKEN=no",
                "VPN_PIA_PORT_FORWARD_PERSIST=false",
                "WEBUI_PORTS=8989/tcp,8989/udp"
            ],
            "Cmd": null,
            "Image": "ghcr.io/hotio/sonarr:release",
            "Volumes": {
                "/config": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/init"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "46430976436f6740713bd4f67120635f051e35470d459e45d2892fcebab7e3f7",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.depends_on": "",
                "com.docker.compose.image": "sha256:def528700c5a2452b1c3909cfc5d34ba825182d19882bda26b9724ec1745f018",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "trash-guides",
                "com.docker.compose.project.config_files": "/volume1/docker/appdata/docker-compose.yml",
                "com.docker.compose.project.working_dir": "/volume1/docker/appdata",
                "com.docker.compose.service": "sonarr",
                "com.docker.compose.version": "2.9.0",
                "org.hotio.pullio.discord.webhook": "https://discord.com/api/webhooks/1245684853177847808/xBqQsk7p6FozzTQoDqEc1TOV_5oCRHqo3a55ZGgcuj0K4QybNeVSUYYYIQW27dziiG7L",
                "org.hotio.pullio.notify": "true",
                "org.hotio.pullio.update": "true",
                "org.opencontainers.image.created": "2024-07-23T00:53:43.000Z",
                "org.opencontainers.image.revision": "f9470d317d3bdc6312faf00cebc75e6105757d70",
                "org.opencontainers.image.source": "https://github.com/hotio/sonarr/tree/release",
                "org.opencontainers.image.title": "hotio/sonarr:release",
                "org.opencontainers.image.url": "https://hotio.dev/containers/sonarr",
                "org.opencontainers.image.vendor": "hotio",
                "org.opencontainers.image.version": "4.0.8.1874"
            },
            "DDSM": false
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "20c28fa7aaad81b5a0ca5d9be194746fcd2cd4eb318d184961de058f0a4bd3ba",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8989/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32782"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "32782"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/20c28fa7aaad",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "trash-guides_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "sonarr",
                        "sonarr",
                        "6de34aa6a6ac"
                    ],
                    "NetworkID": "ae364126f850c2713b896ba21780690365c5e5716f870a0136f6d2c5302ea83f",
                    "EndpointID": "042b5fd756d9e80c530263e60ac279aee3600f6f292fb2fe2c11dbc01dc4d521",
                    "Gateway": "172.21.0.1",
                    "IPAddress": "172.21.0.4",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:15:00:04",
                    "DriverOpts": null
                }
            }
        }
    }
]
goose-ws commented 4 weeks ago

Update your copy of the script and give it another try

retardgerman commented 4 weeks ago

Now it’s working! Thanks for the help!