diff options
author | PradeepKiruvale <pradeepkumar.kj@softwareag.com> | 2022-05-06 18:19:05 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-06 18:19:05 +0530 |
commit | 73c38bc07f3e0cef2c230c0a47f73b9e36e70d72 (patch) | |
tree | 373d5628f66f51e85580a30366d43bc294878016 /configuration | |
parent | 7c8bc1bedc9990e1c493a0678ba0470a959196da (diff) |
Closes #1131, reate tedge user in preinst (#1132)
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
Diffstat (limited to 'configuration')
-rwxr-xr-x | configuration/debian/tedge/postinst | 18 | ||||
-rw-r--r-- | configuration/debian/tedge/postrm | 9 | ||||
-rw-r--r-- | configuration/debian/tedge/preinst | 19 | ||||
-rw-r--r-- | configuration/debian/tedge_agent/postrm | 7 | ||||
-rw-r--r-- | configuration/debian/tedge_mapper/postrm | 23 |
5 files changed, 45 insertions, 31 deletions
diff --git a/configuration/debian/tedge/postinst b/configuration/debian/tedge/postinst index 21794570..f2a096f9 100755 --- a/configuration/debian/tedge/postinst +++ b/configuration/debian/tedge/postinst @@ -1,29 +1,11 @@ #!/bin/sh set -e -### Create groups -if ! getent group tedge >/dev/null; then - addgroup --quiet --system tedge -fi - -### Create users -# Create user tedge with no additional info(--gecos "") no home(--no-create-home), no login(--shell) and in group tedge(--ingroup) -if ! getent passwd tedge >/dev/null; then - adduser --quiet --system --gecos "" --no-create-home --disabled-login --shell /sbin/nologin --ingroup tedge tedge -fi - ### Add include to mosquitto.conf so tedge specific conf will be loaded if ! grep -q "/etc/tedge/mosquitto-conf" "/etc/mosquitto/mosquitto.conf"; then echo "include_dir /etc/tedge/mosquitto-conf" >>/etc/mosquitto/mosquitto.conf fi -### Create file in /etc/sudoers.d directory. With this configuration, the tedge user have the right to call the tedge command with sudo rights, which is required for system-wide configuration in "/etc/tedge" -echo "tedge ALL = (ALL) NOPASSWD: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" >/etc/sudoers.d/tedge - -if [ -f "/etc/sudoers.d/010_pi-nopasswd" ]; then - echo "tedge ALL = (ALL) NOPASSWD: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" >/etc/sudoers.d/tedge-nopasswd -fi - # Initialize the tedge tedge --init diff --git a/configuration/debian/tedge/postrm b/configuration/debian/tedge/postrm index ab676b96..6fb8021f 100644 --- a/configuration/debian/tedge/postrm +++ b/configuration/debian/tedge/postrm @@ -51,14 +51,7 @@ case "$1" in purge_var_log ;; - remove) - remove_user_tedge - remove_tedge_group - remove_mosquitto_edit - remove_sudoers_file - ;; - - upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) diff --git a/configuration/debian/tedge/preinst b/configuration/debian/tedge/preinst index e5e37fed..b2843104 100644 --- a/configuration/debian/tedge/preinst +++ b/configuration/debian/tedge/preinst @@ -1,6 +1,25 @@ #!/bin/sh set -e +### Create groups +if ! getent group tedge >/dev/null; then + addgroup --quiet --system tedge +fi + +### Create users +# Create user tedge with no additional info(--gecos "") no home(--no-create-home), no login(--shell) and in group tedge(--ingroup) +if ! getent passwd tedge >/dev/null; then + adduser --quiet --system --gecos "" --no-create-home --disabled-login --shell /sbin/nologin --ingroup tedge tedge +fi + +### Create file in /etc/sudoers.d directory. With this configuration, the tedge user have the right to call the tedge command with sudo rights, which is required for system-wide configuration in "/etc/tedge" +echo "tedge ALL = (ALL) NOPASSWD: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" >/etc/sudoers.d/tedge + +if [ -f "/etc/sudoers.d/010_pi-nopasswd" ]; then + echo "tedge ALL = (ALL) NOPASSWD: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" >/etc/sudoers.d/tedge-nopasswd +fi + + # change the owenership of the below directories/files to `tedge` user, # as there is only `tedge` user exists. diff --git a/configuration/debian/tedge_agent/postrm b/configuration/debian/tedge_agent/postrm index 9b4c4681..eda59965 100644 --- a/configuration/debian/tedge_agent/postrm +++ b/configuration/debian/tedge_agent/postrm @@ -7,9 +7,16 @@ purge_agent_directory() { fi } +purge_agent_lock() { + if [ -f "/run/lock/tedge_agent.lock" ]; then + rm -rf /run/lock/tedge_agent.lock + fi +} + case "$1" in purge) purge_agent_directory + purge_agent_lock ;; remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) diff --git a/configuration/debian/tedge_mapper/postrm b/configuration/debian/tedge_mapper/postrm index 150afe9d..8bc8f35a 100644 --- a/configuration/debian/tedge_mapper/postrm +++ b/configuration/debian/tedge_mapper/postrm @@ -7,15 +7,28 @@ purge_operations() { fi } +purge_mapper_lock() { + if [ -f "/run/lock/tedge-mapper-c8y.lock" ]; then + rm -rf /run/lock/tedge-mapper-c8y.lock + fi + + if [ -f "/run/lock/tedge-mapper-az.lock" ]; then + rm -rf /run/lock/tedge-mapper-az.lock + fi + + if [ -f "/run/lock/tedge-mapper-collectd.lock" ]; then + rm -rf /run/lock/tedge-mapper-collectd.lock + fi + +} + case "$1" in purge) - purge_operations - ;; - - remove) + purge_operations + purge_mapper_lock ;; - upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) |