This commit is contained in:
Alex Janka 2024-05-18 12:09:06 +10:00
parent 5d777708aa
commit 1982050d1a
2 changed files with 94 additions and 1 deletions

93
radarr.sh Normal file
View file

@ -0,0 +1,93 @@
#!/usr/bin/env zsh
json=$(curl -Ls https://api.github.com/repos/Radarr/Radarr/releases/latest --header "Authorization: Bearer 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" --header "X-GitHub-Api-Version: 2022-11-28")
name=$(jq '.name' <<<$json | tr -d '"')
echo $name
control_file="Section: video
Priority: optional
Standards-Version: 3.9.2
Maintainer: alex
Package: radarr
Version: $name
Architecture: REPLACE_ARCHITECTURE
Description: radarr"
package_info="PackageAuthor=alex
UpdateMethod=External
UpdateMethodMessage=rebuild apt packages
Branch=master"
service_file="# Be sure to use \$(systemctl edit radarr) to modify this service with an override.conf because
# direct changes will be overwritten by package updates.
#
# A user per service w/ shared group setup would have an override like:
# [Service]
# Group=sharedgroupname
# UMask=002
[Unit]
Description=Radarr Service
Wants=network-online.target
After=network-online.target
[Service]
User=radarr
Group=radarr
SyslogIdentifier=radarr
ExecStart=/usr/lib/radarr/bin/Radarr -nobrowser -data=/var/lib/radarr
Type=simple
[Install]
WantedBy=multi-user.target"
sysusers_file="u radarr - \"Radarr daemon\" /var/lib/radarr"
tmpfiles_file="# Override this file with a modified version in /etc/tmpfiles.d/
d /var/lib/radarr 0755 radarr radarr
Z /var/lib/radarr - radarr radarr
L /var/log/radarr - - - - /var/lib/radarr/logs/"
rel_info=$(jq '.assets[] | select(.name | contains("linux")) | select(.name | contains("musl") | not)' <<<$json)
declare -a tarballs=($(jq '"\(.browser_download_url) /\(.name)"' <<<$rel_info | tr -d '"' | tr "\n" " "))
for ((i = 1; i < ${#tarballs[@]}; i += 2)); do
url="${tarballs[i]}"
filename="${tarballs[i + 1]#/}"
echo $filename
arch=$(sed -E "s/^.+?linux-(.+?).tar.gz$/\1/g" <<<"${tarballs[i + 1]}")
if [[ "$arch" == "x64" ]]; then
arch="amd64"
fi
if [[ "$arch" == "arm" ]]; then
arch="armhf"
fi
echo "url: $url, arch: $arch"
if [ -z "$1" ] || [[ "$arch" == "$1" ]]; then
dir=$(mktemp -d)
current_dir=$PWD
mkdir -p $dir/radarr
cd $dir/radarr
mkdir -p usr/lib/sysusers.d
echo $sysusers_file >usr/lib/sysusers.d/radarr.conf
mkdir -p usr/lib/systemd/system
echo $service_file >usr/lib/systemd/system/radarr.service
mkdir -p usr/lib/tmpfiles.d
echo $tmpfiles_file >usr/lib/tmpfiles.d/radarr.conf
mkdir -p usr/lib/radarr
echo "$package_info\nPackageVersion=$name" >usr/lib/radarr/package_info
curl -Ls $url | tar xz
rm -rf Radarr/Radarr.Update
mv Radarr usr/lib/radarr/bin
chmod +x usr/lib/radarr/bin/Radarr usr/lib/radarr/bin/ffprobe
mkdir -p DEBIAN
echo $control_file | sed -E "s/REPLACE_ARCHITECTURE/$arch/g" >DEBIAN/control
cd $dir
dpkg-deb --build radarr
cp radarr.deb $current_dir/radarr-$name-$arch.deb
cd $current_dir
else
echo "skipping arch $arch"
fi
done

View file

@ -19,7 +19,7 @@ UpdateMethod=External
UpdateMethodMessage=rebuild apt packages
Branch=main"
service_file="# Be sure to use $(systemctl edit sonarr) to modify this service with an override.conf because
service_file="# Be sure to use \$(systemctl edit sonarr) to modify this service with an override.conf because
# direct changes will be overwritten by package updates.
#
# A user per service w/ shared group setup would have an override like: