add pasty-git

This commit is contained in:
leafee98 2024-03-12 17:36:16 +08:00
parent 39b75dfe92
commit 16ef2d96d5
3 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,53 @@
#/usr/bin/env bash
pkgname="pasty-git"
arch="amd64"
pkgrel=1
pkgver=20240312172222-39b75df
pkgdesc="pasty is a fast and lightweight code pasting server"
url="https://github.com/leafee98/pasty"
maintainer="Leafee98 <me@leafee98.com>"
source=(
"pasty::git+https://github.com/leafee98/pasty.git"
"pasty.service::materials/pasty.service"
"env::materials/env"
)
function pkgver {
echo "$(date +%Y%m%d%H%M%S)-$(git rev-parse --short HEAD)"
}
function build {
(
cd ${srcdir}/pasty
go build -o pasty ./cmd/pasty/main.go
)
}
function package {
install -Dm755 ${srcdir}/pasty/pasty ${pkgdir}/usr/lib/pasty/pasty
install -Dm644 ${srcdir}/pasty/LICENSE ${pkgdir}/usr/share/licenses/pasty/LICENSE
cp -r ${srcdir}/pasty/web ${pkgdir}/usr/lib/pasty/web
install -Dm644 ${srcdir}/pasty.service ${pkgdir}/usr/lib/systemd/system/pasty.service
# We haven't implement the 'conffiles', so don't create this file in case override user's config
#install -Dm644 ${srcdir}/env ${pkgdir}/etc/pasty/env
}
function debian_postinst {
cat << 'EOF'
#!/usr/bin/env bash
service_name="pasty.service"
adduser --system --group pasty
chown -R pasty:pasty /usr/lib/pasty
systemctl daemon-reload
if systemctl is-active --quiet ${service_name} ; then
systemctl restart ${service_name}
fi
EOF
}

View file

@ -0,0 +1 @@
# See README on https://github.com/lus/pasty

View file

@ -0,0 +1,18 @@
[Unit]
Description=Pasty is a fast and lightweight code pasting server
After=network.target
[Service]
User=pasty
# Here store the configs
EnvironmentFile=/etc/pasty/env
# Start program here, the pasty read `./web` to find the front pages
WorkingDirectory=/usr/lib/pasty/
ExecStart=/usr/lib/pasty/pasty
Restart=on-failure
[Install]
WantedBy=multi-user.target