Pre-requisites
- Mounting and User mapping
- Data folder for Sonarr downloads ready
Install
CT Creation
{
read -rs -p "Root password for the new CT: " PW; echo
pct create \
112 \
/mnt/pve/evo/template/cache/alpine-3.24-default_20260714_amd64.tar.xz \
--hostname sonarr \
--memory 512 \
--net0 name=eth0,bridge=vmbr0,firewall=1,gw=192.168.0.1,ip=192.168.0.112/24,hwaddr=DE:AD:DE:AD:01:12,type=veth \
--rootfs local-lvm:1 \
--unprivileged 1 \
--ignore-unpack-errors \
--ostype alpine \
--password="$PW" \
--ssh-public-keys /root/.ssh/authorized_keys \
--start 0
unset PW
}Storage Mapping
echo "mp0: /mnt/pve/evo/data,mp=/data" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: u 0 100000 1000" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: g 0 100000 1000" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: u 1000 1000 1" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: g 1000 1000 1" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: u 1001 101001 64535" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: g 1001 101001 64535" >> /etc/pve/lxc/112.confEnter the CT
pct start 112 && pct enter 112Enable DHCP Leasing - Alpine
# Alpine
touch /hdd_request_ip.sh
echo "udhcpc -i eth0 -F $(hostname) -x hostname:$(hostname) -r $(hostname -i)" >> /hdd_request_ip.sh
echo -e "#!/sbin/openrc-run\n\
name=hdd_request_ip\n\
description=\"Request IP Address From Router\"\n\
command=\"sh ./hdd_request_ip.sh\"\n\
command_background=true\n\
pidfile=\"/run/\$name.pid\"\n\
# output_log=\"/var/log/homepage/output.log\"\n\
# error_log=\"/var/log/homepage/error.log\"\n\
\ndepend() {\n\
\tneed net\n\
\tuse dns logger netmount\n\
}" >> /etc/init.d/hdd_request_ip
chmod +x /etc/init.d/hdd_request_ip
rc-update add hdd_request_ip
service hdd_request_ip startUser at uid 1000
addgroup -g 1000 sonarr
adduser -D -h /var/lib/sonarr -s /sbin/nologin -G sonarr -u 1000 sonarrDependencies
apk add libstdc++ icu-libs sqlite-libs tzdataInstall Sonarr
VERSION=$(wget -qO- https://api.github.com/repos/Sonarr/Sonarr/releases/latest | tr ',' '\n' | grep '"tag_name"' | cut -d'"' -f4 | sed 's/^v//')
wget -O /tmp/sonarr.tar.gz "https://github.com/Sonarr/Sonarr/releases/download/v$VERSION/Sonarr.main.$VERSION.linux-musl-x64.tar.gz"
mkdir -p /opt/sonarr
tar xzf /tmp/sonarr.tar.gz -C /opt/sonarr --strip-components=1
rm -rf /opt/sonarr/Sonarr.Update /tmp/sonarr.tar.gzService
cat > /etc/init.d/sonarr <<'EOF'
#!/sbin/openrc-run
name=sonarr
description="Sonarr"
command=/opt/sonarr/Sonarr
command_args="-nobrowser -data=/var/lib/sonarr"
command_user=sonarr:sonarr
supervisor=supervise-daemon
output_log=/var/log/sonarr/output.log
error_log=/var/log/sonarr/output.log
depend() {
need net
after firewall
}
start_pre() {
checkpath -d -o $command_user /var/lib/sonarr /var/log/sonarr
}
EOF
chmod +x /etc/init.d/sonarr
rc-update add sonarrData folder
chmod 770 /data -R
chown 1000:1000 -R /dataStart
rc-service sonarr startYou’re done
http://192.168.0.112:8989Heart Beat
http://192.168.0.112:8989/pingOptional: reach it at sonarr.lan
Needs the Nginx LAN proxy. Run this on the node that hosts the proxy.
pct exec 101 -- add-lan-app sonarr.lan 192.168.0.112 8989/ip dns static add name=sonarr.lan address=192.168.0.101Optional: reach it through the Cloudflare tunnel
Needs the Cloudflared tunnel. On the node that hosts it:
pct exec 102 -- add-cf-app sonarr.hadidi.art 192.168.0.112 8989
pct exec 102 -- protect-cf-app sonarr.hadidi.art "HDD"
# Share with a friend
pct exec 102 -- add-cf-policy "Friend" [email protected]
pct exec 102 -- protect-cf-app --add sonarr.hadidi.art "Friend"Update
Update Sonarr
VERSION=$(wget -qO- https://api.github.com/repos/Sonarr/Sonarr/releases/latest | tr ',' '\n' | grep '"tag_name"' | cut -d'"' -f4 | sed 's/^v//')
wget -O /tmp/sonarr.tar.gz "https://github.com/Sonarr/Sonarr/releases/download/v$VERSION/Sonarr.main.$VERSION.linux-musl-x64.tar.gz"
rc-service sonarr stop
rm -rf /opt/sonarr
mkdir -p /opt/sonarr
tar xzf /tmp/sonarr.tar.gz -C /opt/sonarr --strip-components=1
rm -rf /opt/sonarr/Sonarr.Update /tmp/sonarr.tar.gz
rc-service sonarr startRemove
Remove from the LAN proxy
Only if you added it to the Nginx LAN proxy. Run this on the node that hosts the proxy.
pct exec 101 -- sed -i '/^ *sonarr\.lan /d' /etc/nginx/http.d/map-backends.conf
pct exec 101 -- nginx -s reload/ip dns static remove [find name=sonarr.lan]Remove from the Cloudflare tunnel
Only if you added it to the Cloudflared tunnel. Run this on the node that hosts the tunnel.
pct exec 102 -- del-cf-app sonarr.hadidi.artDelete the CT
pct stop 112
pct destroy 112