From 26895a03d76f0ab3bc0f2824ca4dd58523a86ac8 Mon Sep 17 00:00:00 2001 From: Benjamin Slade Date: Thu, 2 Apr 2020 06:55:53 -0600 Subject: [PATCH] modify scripts to fallback to traditional commands if no systemd --- util/functions.sh | 8 ++++++++ x230/x230_heads.sh | 4 ++-- x230/x230_skulls.sh | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/util/functions.sh b/util/functions.sh index 526465d..1509682 100755 --- a/util/functions.sh +++ b/util/functions.sh @@ -57,3 +57,11 @@ warn_not_root() { echo -e "${YELLOW}WARNING:${NC} This should not be executed as root!" fi } + +poweroff() { + if command -v systemctl 2>/dev/null; then + systemctl poweroff + else + shutdown -P now + fi +} diff --git a/x230/x230_heads.sh b/x230/x230_heads.sh index 7c06b38..aa99bd3 100755 --- a/x230/x230_heads.sh +++ b/x230/x230_heads.sh @@ -155,8 +155,8 @@ rm -rf ${OUTPUT_PATH} while true; do read -r -p "Power off now? (please do!) Y/n: " yn case $yn in - [Yy]* ) systemctl poweroff ;; + [Yy]* ) poweroff ;; [Nn]* ) exit;; - * ) systemctl poweroff ;; + * ) poweroff ;; esac done diff --git a/x230/x230_skulls.sh b/x230/x230_skulls.sh index 8f76ef1..40ee1df 100755 --- a/x230/x230_skulls.sh +++ b/x230/x230_skulls.sh @@ -217,8 +217,8 @@ rm -rf ${OUTPUT_PATH} while true; do read -r -p "Power off now? (please do!) Y/n: " yn case $yn in - [Yy]* ) systemctl poweroff ;; + [Yy]* ) poweroff ;; [Nn]* ) exit;; - * ) systemctl poweroff ;; + * ) poweroff ;; esac done