Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-05-22 18:03:48 -04:00
parent 1663feca9e
commit 8ea59c07e7
2 changed files with 58 additions and 0 deletions

15
.rpm/printerfacts.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=Printer facts API
Wants=network-pre.target
After=network-pre.target
[Service]
EnvironmentFile=/etc/default/printerfacts
ExecStart=/usr/bin/printerfacts
Restart=on-failure
User=printerfacts
WorkingDirectory=/var/lib/printerfacts
Environment=RUST_LOG=info
[Install]
WantedBy=multi-user.target

View File

@ -9,12 +9,55 @@ Release: @@RELEASE@@%{?dist}
License: MIT License: MIT
Group: Applications/System Group: Applications/System
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
Source1: printerfacts.service
Requires(pre): /usr/sbin/useradd, /usr/bin/getent
Requires(postun): /usr/sbin/userdel
BuildRequires: systemd-rpm-macros
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description %description
%{summary} %{summary}
%pre
/usr/bin/getent group printerfacts || /usr/sbin/groupadd -r printerfacts
/usr/bin/getent passwd printerfacts || /usr/sbin/useradd -r -d /usr/bin/printerfacts -s /sbin/nologin printerfacts
#Upgrading
if [ $1 -eq 2 ]; then
/usr/bin/systemctl stop %{pkgname}.service >/dev/null 2>&1 ||:
fi
%post
%systemd_post %{pkgname}.service
if [ $1 -eq 1 ]; then
/usr/bin/systemctl daemon-reload
/usr/bin/systemctl start %{pkgname}.service
fi
if [ $1 -eq 2 ]; then
/usr/bin/systemctl daemon-reload
/usr/bin/systemctl start %{pkgname}.service
fi
%preun
%systemd_preun %{pkgname}.service
#old package
#uninstall
if [ $1 -eq 0 ]; then
/usr/bin/systemctl --no-reload disable %{pkgname}.service
/usr/bin/systemctl stop %{pkgname}.service >/dev/null 2>&1 ||:
/usr/bin/systemctl disable %{pkgname}.service
fi
if [ $1 -eq 1 ]; then
/usr/bin/systemctl --no-reload disable %{pkgname}.service
/usr/bin/systemctl stop %{pkgname}.service
fi
%postun
/usr/sbin/userdel printerfacts
%prep %prep
%setup -q %setup -q