From b42ef9c1d539fb783f20180fec8cfb86c5d65030 Mon Sep 17 00:00:00 2001 From: "Vladimir D. Seleznev" Date: Thu, 4 Mar 2021 19:47:24 +0300 Subject: [PATCH] scripts: double-quote variables and expansions, copy file with archive mode --- scripts/bootup/systemd/lkrg-systemd.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/bootup/systemd/lkrg-systemd.sh b/scripts/bootup/systemd/lkrg-systemd.sh index 63d5a92..1a2e282 100755 --- a/scripts/bootup/systemd/lkrg-systemd.sh +++ b/scripts/bootup/systemd/lkrg-systemd.sh @@ -6,7 +6,7 @@ # - Adam 'pi3' Zabrocki (http://pi3.com.pl) ## -P_SYSTEMD_DIR=`systemctl show -p UnitPath | cut -d " " -f5` +P_SYSTEMD_DIR="$(systemctl show -p UnitPath | cut -d " " -f5)" case "$P_SYSTEMD_DIR" in \/run/*) P_SYSTEMD_DIR=/etc/systemd/system ;; @@ -22,12 +22,12 @@ P_NC='\033[0m' # No Color echo -e " ${P_GREEN}[+] ${P_WHITE}Systemd detected${P_NC}" if [ "$1" == "install" ]; then - if [ -f $P_SYSTEMD_DIR/lkrg.service ]; then + if [ -f "$P_SYSTEMD_DIR/lkrg.service" ]; then echo -e " ${P_RED}ERROR! ${P_YL}lkrg.service${P_RED} file already exists under ${P_YL}$P_SYSTEMD_DIR${P_RED} folder${P_NC}" exit 1 else echo -e " ${P_GREEN}Installing ${P_YL}lkrg.service${P_GREEN} file under ${P_YL}$P_SYSTEMD_DIR${P_GREEN} folder${P_NC}" - cp scripts/bootup/systemd/lkrg.service $P_SYSTEMD_DIR/lkrg.service + cp -a scripts/bootup/systemd/lkrg.service "$P_SYSTEMD_DIR/lkrg.service" echo -e " ${P_GREEN}Enabling ${P_YL}lkrg.service${P_GREEN} on bootup${P_NC}" systemctl enable lkrg.service echo -e " ${P_GREEN}To start ${P_YL}lkrg.service${P_GREEN} please use: ${P_YL}systemctl start lkrg${P_NC}" @@ -38,7 +38,7 @@ elif [ "$1" == "uninstall" ]; then echo -e " ${P_GREEN}Disabling ${P_YL}lkrg.service${P_GREEN} on bootup${P_NC}" systemctl disable lkrg.service echo -e " ${P_GREEN}Deleting ${P_YL}lkrg.service${P_GREEN} file from the ${P_YL}$P_SYSTEMD_DIR${P_GREEN} folder${P_NC}" - rm $P_SYSTEMD_DIR/lkrg.service + rm "$P_SYSTEMD_DIR/lkrg.service" else echo -e " ${P_RED}ERROR! Unknown option!${P_NC}" exit 1