From b8c0111e91409a030a5f4546ad88100e5f2344a6 Mon Sep 17 00:00:00 2001 From: dernasherbrezon Date: Sun, 29 Sep 2024 19:00:22 +0100 Subject: [PATCH] better installation scripts --- src/main/deb/postinst | 25 ++++++++++++++++--------- src/main/deb/prerm | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/deb/postinst b/src/main/deb/postinst index 779e71ec..a2c97f82 100644 --- a/src/main/deb/postinst +++ b/src/main/deb/postinst @@ -6,15 +6,26 @@ if id "${config.user}" &>/dev/null; then else useradd -m ${config.user} echo "User '${config.user}' created." +fi + +if ! getent group ${config.group} > /dev/null; then + groupadd ${config.group} + echo "Group '${config.group}' created." +fi - if ! getent group ${config.group} > /dev/null; then - groupadd ${config.group} - echo "Group '${config.group}' created." - fi +if [ $(getent group dialout) ]; then + usermod -a -G dialout ${config.user} +fi - usermod -aG dialout,plugdev ${config.user} +if [ $(getent group plugdev) ]; then + usermod -a -G plugdev ${config.user} fi +if [ $(getent group systemd-journal) ]; then + usermod -a -G systemd-journal ${config.user} +fi + + chown -R ${config.user}:${config.group} ${config.installDir} /usr/share/java/r2cloud/*.jar chmod 640 ${config.installDir}/lib/*.jar /usr/share/java/r2cloud/*.jar @@ -58,10 +69,6 @@ if [ -f /etc/sudoers.d/nginx ]; then chmod 440 /etc/sudoers.d/nginx fi -if [ $(getent group systemd-journal) ]; then - usermod -a -G systemd-journal ${config.user} -fi - if [ ! -d /var/log/journal ]; then echo "enable persistent journald logs" mkdir -p /var/log/journal diff --git a/src/main/deb/prerm b/src/main/deb/prerm index 9c0db991..104b090f 100644 --- a/src/main/deb/prerm +++ b/src/main/deb/prerm @@ -1,2 +1,2 @@ echo "removing libs..." -rm ${config.installDir}/lib/*.jar \ No newline at end of file +rm -f ${config.installDir}/lib/*.jar \ No newline at end of file