sonarr
This commit is contained in:
commit
5d777708aa
94
sonarr.sh
Normal file
94
sonarr.sh
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
json=$(curl -Ls https://api.github.com/repos/Sonarr/Sonarr/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: sonarr
|
||||||
|
Version: $name
|
||||||
|
Architecture: REPLACE_ARCHITECTURE
|
||||||
|
Description: sonarr"
|
||||||
|
|
||||||
|
package_info="PackageAuthor=alex
|
||||||
|
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
|
||||||
|
# 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=Sonarr Service
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=sonarr
|
||||||
|
Group=sonarr
|
||||||
|
SyslogIdentifier=sonarr
|
||||||
|
ExecStart=/usr/lib/sonarr/bin/Sonarr -nobrowser -data=/var/lib/sonarr
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target"
|
||||||
|
|
||||||
|
sysusers_file="u sonarr - - /var/lib/sonarr
|
||||||
|
g sonarr -"
|
||||||
|
|
||||||
|
tmpfiles_file="# Override this file with a modified version in /etc/tmpfiles.d/
|
||||||
|
d /var/lib/sonarr 0755 sonarr sonarr
|
||||||
|
Z /var/lib/sonarr - sonarr sonarr
|
||||||
|
L /var/log/sonarr - - - - /var/lib/sonarr/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/sonarr
|
||||||
|
cd $dir/sonarr
|
||||||
|
mkdir -p usr/lib/sysusers.d
|
||||||
|
echo $sysusers_file >usr/lib/sysusers.d/sonarr.conf
|
||||||
|
mkdir -p usr/lib/systemd/system
|
||||||
|
echo $service_file >usr/lib/systemd/system/sonarr.service
|
||||||
|
mkdir -p usr/lib/tmpfiles.d
|
||||||
|
echo $tmpfiles_file >usr/lib/tmpfiles.d/sonarr.conf
|
||||||
|
mkdir -p usr/lib/sonarr
|
||||||
|
echo "$package_info\nPackageVersion=$name" >usr/lib/sonarr/package_info
|
||||||
|
curl -Ls $url | tar xz
|
||||||
|
rm -rf Sonarr/Sonarr.Update
|
||||||
|
mv Sonarr usr/lib/sonarr/bin
|
||||||
|
mkdir -p DEBIAN
|
||||||
|
echo $control_file | sed -E "s/REPLACE_ARCHITECTURE/$arch/g" >DEBIAN/control
|
||||||
|
cd $dir
|
||||||
|
dpkg-deb --build sonarr
|
||||||
|
cp sonarr.deb $current_dir/sonarr-$name-$arch.deb
|
||||||
|
cd $current_dir
|
||||||
|
else
|
||||||
|
echo "skipping arch $arch"
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in a new issue