1 Star 0 Fork 50

zhongling.h/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0965-test-use-quotes-where-necessary.patch 3.35 KB
一键复制 编辑 原始数据 按行查看 历史
Zhao Hang 提交于 2023-12-26 10:07 . update to systemd-239-78.src.rpm
From 209b8c92f0c44644d0476349b4a65f4b9ad942de Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <[email protected]>
Date: Fri, 9 Apr 2021 19:49:32 +0200
Subject: [PATCH] test: use quotes where necessary
to avoid possible word splitting.
[dtardon: Dropped changes to other files.]
(cherry picked from commit 38825267983a439f2cf8375463b1edc9ca2d3323)
Related: #2156620
---
test/TEST-15-DROPIN/test-dropin.sh | 44 ++++++++++++++++--------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
index 30f1e84954..a197989f72 100755
--- a/test/TEST-15-DROPIN/test-dropin.sh
+++ b/test/TEST-15-DROPIN/test-dropin.sh
@@ -4,51 +4,53 @@ set -e
set -x
_clear_service () {
- systemctl stop $1.service 2>/dev/null || :
- rm -f /{etc,run,usr/lib}/systemd/system/$1.service
- rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d
- rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}
- if [[ $1 == *@ ]]; then
- systemctl stop $1*.service 2>/dev/null || :
- rm -f /{etc,run,usr/lib}/systemd/system/$1*.service
- rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.d
- rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.{wants,requires}
+ local SERVICE_NAME="${1:?_clear_service: missing argument}"
+ systemctl stop "$SERVICE_NAME.service" 2>/dev/null || :
+ rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.{wants,requires}
+ if [[ $SERVICE_NAME == *@ ]]; then
+ systemctl stop "$SERVICE_NAME"*.service 2>/dev/null || :
+ rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.d
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.{wants,requires}
fi
}
clear_services () {
- for u in $*; do
- _clear_service $u
+ for u in "$@"; do
+ _clear_service "$u"
done
systemctl daemon-reload
}
create_service () {
- clear_services $1
+ local SERVICE_NAME="${1:?create_service: missing argument}"
+ clear_services "$SERVICE_NAME"
- cat >/etc/systemd/system/$1.service<<EOF
+ cat >/etc/systemd/system/"$SERVICE_NAME".service <<EOF
[Unit]
-Description=$1 unit
+Description=$SERVICE_NAME unit
[Service]
ExecStart=/bin/sleep 100000
EOF
- mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d
- mkdir -p /etc/systemd/system/$1.service.{wants,requires}
- mkdir -p /run/systemd/system/$1.service.{wants,requires}
- mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires}
+ mkdir -p /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d
+ mkdir -p /etc/systemd/system/"$SERVICE_NAME".service.{wants,requires}
+ mkdir -p /run/systemd/system/"$SERVICE_NAME".service.{wants,requires}
+ mkdir -p /usr/lib/systemd/system/"$SERVICE_NAME".service.{wants,requires}
}
create_services () {
- for u in $*; do
- create_service $u
+ for u in "$@"; do
+ create_service "$u"
done
}
check_ok () {
[ $# -eq 3 ] || return
- x="$(systemctl show --value -p $2 $1)"
+ x="$(systemctl show --value -p "$2" "$1")"
case "$x" in
*$3*) return 0 ;;
*) return 1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhonglingh/systemd.git
[email protected]:zhonglingh/systemd.git
zhonglingh
systemd
systemd
a8

搜索帮助