From 22f49c212d5d3d694b01eceef641b2a06e80f858 Mon Sep 17 00:00:00 2001 From: FroggyFlox Date: Sun, 4 Jun 2023 10:07:52 -0400 Subject: [PATCH] Move UDEVADM and SHUTDOWN definitions to runtime constants #2564 --- src/rockstor/settings.py | 9 --------- src/rockstor/system/constants.py | 4 ++++ src/rockstor/system/osi.py | 4 +--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/rockstor/settings.py b/src/rockstor/settings.py index 59a328df2..822a02105 100644 --- a/src/rockstor/settings.py +++ b/src/rockstor/settings.py @@ -426,15 +426,6 @@ OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' -# Setup OS specific command paths via 'which cmd' calls -# N.B. this method will not work with an alias, ie in CentOS -# which ls -# alias ls='ls --color=auto' -# /usr/bin/ls -# The following have been tested in CentOS, openSUSE Leap15, and Tumbleweed -UDEVADM = subprocess.check_output(["which", "udevadm"]).rstrip() -SHUTDOWN = subprocess.check_output(["which", "shutdown"]).rstrip() - # Establish our OS base id, name, and version: # Use id for code path decisions. Others are for Web-UI display purposes. # Examples given are for CentOS Rockstor variant, Leap 15, and Tumblweed. diff --git a/src/rockstor/system/constants.py b/src/rockstor/system/constants.py index 5e5dcec82..d3ce3d5d5 100644 --- a/src/rockstor/system/constants.py +++ b/src/rockstor/system/constants.py @@ -30,3 +30,7 @@ USERMOD = "/usr/sbin/usermod" SYSTEMCTL = "/usr/bin/systemctl" + +# Works in Leap 15.4 (systemd-249.16-150400.8.28.3) and Tumbleweed (systemd-253.4-2.1) +UDEVADM = "/usr/bin/udevadm" +SHUTDOWN = "/sbin/shutdown" diff --git a/src/rockstor/system/osi.py b/src/rockstor/system/osi.py index b43895532..2a82c0ffa 100644 --- a/src/rockstor/system/osi.py +++ b/src/rockstor/system/osi.py @@ -35,7 +35,7 @@ from django.conf import settings from system.exceptions import CommandException, NonBTRFSRootException -from system.constants import SYSTEMCTL, MKDIR, RMDIR, MOUNT, UMOUNT, DEFAULT_MNT_DIR +from system.constants import SYSTEMCTL, MKDIR, RMDIR, MOUNT, UMOUNT, DEFAULT_MNT_DIR, UDEVADM, SHUTDOWN logger = logging.getLogger(__name__) @@ -52,10 +52,8 @@ LS = "/usr/bin/ls" LSBLK = "/usr/bin/lsblk" NMCLI = "/usr/bin/nmcli" -SHUTDOWN = settings.SHUTDOWN SYSTEMD_ESCAPE = "/usr/bin/systemd-escape" SYSTEMD_DIR = "/usr/lib/systemd/system" -UDEVADM = settings.UDEVADM WIPEFS = "/usr/sbin/wipefs" RTC_WAKE_FILE = "/sys/class/rtc/rtc0/wakealarm" PING = "/usr/bin/ping"