summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 80d7f42af9b3029e213f12872a884d2172fcc82a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Maintainer: primordialhuman https://github.com/primordial-human
pkgname=seanime
pkgver=2.1.1
pkgrel=1
pkgdesc="A self-hosted server that seamlessly integrates with your local anime collection with anilist integration."
arch=(x86_64)
url="https://github.com/5rahim/seanime"
license=('MIT')
conflicts=()
depends=('systemd')
source=("https://github.com/5rahim/seanime/releases/download/v${pkgver}/seanime-${pkgver}_Linux_x86_64.tar.gz")
sha256sums=('66447d0b87a4705c7f81c15331f54b4f550f34e66b97f5cc0a7f962855d35782')

package() {
    # Install the binary
    install -d "${pkgdir}/usr/bin/"
    install -dm755 "${pkgdir}/opt/${pkgname}"
    install -m 755 "${srcdir}/seanime" -t "${pkgdir}/opt/${pkgname}/"
    ln -s "/opt/${pkgname}/seanime" "${pkgdir}/usr/bin/"

    # Dynamically insert the user who runs the script
    local user=${USER:-root}  # Get the username of the user running the script, default to root
    local group=${USER:-root}  # Same for the group

    # Create the systemd service file with the dynamic user and group
    install -Dm644 /dev/stdin "${pkgdir}/usr/lib/systemd/system/seanime.service" <<EOF
[Unit]
Description=Seanime Service
After=network.target

[Service]
ExecStart=/usr/bin/seanime
Restart=always
User=$user
Group=$group

[Install]
WantedBy=multi-user.target
EOF
}

post_install() {
    # Enable and start the service after installation
    systemctl enable seanime.service
    systemctl start seanime.service
}