From 79a7a43cd5f3c3c1e9262196d8b3413baad2fe03 Mon Sep 17 00:00:00 2001 From: Revertron Date: Sat, 3 Apr 2021 20:57:18 +0200 Subject: [PATCH] Fixed creation of user and group in deb-package post-install. --- contrib/deb/generate.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/deb/generate.sh b/contrib/deb/generate.sh index 4ed86a2..e011b8c 100755 --- a/contrib/deb/generate.sh +++ b/contrib/deb/generate.sh @@ -22,7 +22,7 @@ PKGREPLACES=alfis #fi # Building nogui versions only -if [ $PKGARCH = "amd64" ]; then cargo build --release --no-default-features && cp target/release/alfis ./alfis +if [ $PKGARCH = "amd64" ]; then cargo build --release --no-default-features --target x86_64-unknown-linux-musl && cp target/x86_64-unknown-linux-musl/release/alfis ./alfis elif [ $PKGARCH = "i686" ]; then cross build --target i686-unknown-linux-gnu --release --no-default-features && cp target/i686-unknown-linux-gnu/release/alfis ./alfis elif [ $PKGARCH = "mipsel" ]; then cross build --release --no-default-features --target mipsel-unknown-linux-gnu && cp target/mipsel-unknown-linux-gnu/release/alfis ./alfis elif [ $PKGARCH = "mips" ]; then cross build --release --no-default-features --target mips-unknown-linux-gnu && cp target/mips-unknown-linux-gnu/release/alfis ./alfis @@ -70,14 +70,16 @@ usr/bin/alfis usr/bin etc/systemd/system/*.service etc/systemd/system EOF cat > /tmp/$PKGNAME/debian/postinst << EOF -#!/bin/sh - -id -u alfis &>/dev/null || useradd --system alfis || echo "Failed to create user 'alfis' - please create it manually and reinstall" +#!/bin/sh -e if ! getent group alfis 2>&1 > /dev/null; then groupadd --system --force alfis || echo "Failed to create group 'alfis' - please create it manually and reinstall" fi +if ! getent passwd alfis >/dev/null 2>&1; then + adduser --system --ingroup alfis --disabled-password --home /var/lib/alfis alfis +fi + mkdir -p /var/lib/alfis chgrp alfis /var/lib/alfis @@ -112,7 +114,7 @@ if command -v systemctl >/dev/null; then fi EOF -cp alfis /tmp/$PKGNAME/usr/bin/ +sudo cp alfis /tmp/$PKGNAME/usr/bin/ cp contrib/systemd/*.service /tmp/$PKGNAME/etc/systemd/system/ tar -czvf /tmp/$PKGNAME/data.tar.gz -C /tmp/$PKGNAME/ \