Skip to content

Commit 657aa71

Browse files
authored
CA-405864: Drop usage of init.d functions (xapi-project#6339)
init.d are from initscripts which are legacy and removed from XS9 This commit drop the usage of the scripts
2 parents 80956ca + 118fd8e commit 657aa71

File tree

8 files changed

+42
-307
lines changed

8 files changed

+42
-307
lines changed

ocaml/squeezed/scripts/init.d-squeezed

-106
This file was deleted.

ocaml/xcp-rrdd/bin/rrdp-scripts/rrdd-plugins-init

-126
This file was deleted.

scripts/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ install:
4646
$(IDATA) xapi.conf $(DESTDIR)$(XAPICONF)
4747
$(IPROG) db.conf.skel $(DESTDIR)$(ETCXENDIR)/db.conf
4848
$(IPROG) rio.db.conf.skel $(DESTDIR)$(ETCXENDIR)/db.conf.rio
49-
$(IPROG) init.d-xapi $(DESTDIR)$(LIBEXECDIR)/xapi-init
50-
$(IPROG) init.d-save-boot-info $(DESTDIR)$(LIBEXECDIR)/save-boot-info
51-
$(IPROG) init.d-attach-static-vdis $(DESTDIR)$(LIBEXECDIR)/attach-static-vdis
49+
$(IPROG) xapi-init $(DESTDIR)$(LIBEXECDIR)/xapi-init
50+
$(IPROG) save-boot-info $(DESTDIR)$(LIBEXECDIR)/save-boot-info
51+
$(IPROG) attach-static-vdis $(DESTDIR)$(LIBEXECDIR)/attach-static-vdis
5252
$(IPROG) generate-iscsi-iqn $(DESTDIR)$(LIBEXECDIR)/generate-iscsi-iqn
5353
$(IPROG) network-init $(DESTDIR)$(LIBEXECDIR)/network-init
5454
$(IPROG) control-domain-params-init $(DESTDIR)$(LIBEXECDIR)/control-domain-params-init

scripts/init.d-attach-static-vdis renamed to scripts/attach-static-vdis

+11-19
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,28 @@ STATE_DIR=/etc/xensource/static-vdis
77
[ -d ${STATE_DIR} ] || exit 0
88
[ -e /opt/xensource/bin/static-vdis ] || exit 0
99

10-
# Source function library.
11-
. /etc/init.d/functions
12-
1310
clear_stale_state(){
14-
for i in $(ls -1 ${STATE_DIR}); do
11+
for i in "${STATE_DIR}"/*; do
1512
# Clear the now-stale symlink to the attached disk. From this point the disk will
1613
# be considered 'currently-attached=false'
17-
rm -f ${STATE_DIR}/${i}/disk
14+
rm -f "${i}"/disk
1815

1916
# If the disk was supposed to be deleted altogether on reboot then do it now
20-
UUID=$(cat ${STATE_DIR}/${i}/vdi-uuid)
21-
if [ -e ${STATE_DIR}/${i}/delete-next-boot ]; then
17+
UUID=$(cat "${i}"/vdi-uuid)
18+
if [ -e "${i}"/delete-next-boot ]; then
2219
logger "Deleting stale static-configured state for VDI: ${UUID}"
23-
rm -rf ${STATE_DIR}/${i}
20+
rm -rf "${i}"
2421
fi;
2522
done
2623
}
2724

2825
attach_all(){
2926
RC=0
30-
ALL=$(ls -1 ${STATE_DIR})
3127

32-
for i in ${ALL}; do
33-
UUID=$(cat ${STATE_DIR}/${i}/vdi-uuid)
28+
for i in "${STATE_DIR}"/*; do
29+
UUID=$(cat "${i}"/vdi-uuid)
3430
logger "Attempting to attach VDI: ${UUID}"
35-
OUTPUT=$(/opt/xensource/bin/static-vdis attach ${UUID} 2>&1)
36-
if [ $? -ne 0 ]; then
31+
if ! OUTPUT=$(/opt/xensource/bin/static-vdis attach "${UUID}" 2>&1); then
3732
RC=1
3833
logger "Attempt to attach VDI: ${UUID} failed -- skipping (Error was: ${OUTPUT})"
3934
return $RC
@@ -43,13 +38,10 @@ attach_all(){
4338
}
4439

4540
detach_all(){
46-
ALL=$(ls -1 ${STATE_DIR})
47-
48-
for i in ${ALL}; do
49-
UUID=$(cat ${STATE_DIR}/${i}/vdi-uuid)
41+
for i in "${STATE_DIR}"/*; do
42+
UUID=$(cat "${i}"/vdi-uuid)
5043
logger "Attempting to detach VDI: ${UUID}"
51-
OUTPUT=$(/opt/xensource/bin/static-vdis detach ${UUID} 2>&1)
52-
if [ $? -ne 0 ]; then
44+
if ! OUTPUT=$(/opt/xensource/bin/static-vdis detach "${UUID}" 2>&1); then
5345
logger "Attempt to detach VDI: ${UUID} failed -- skipping (Error was: ${OUTPUT})"
5446
fi
5547
done

scripts/on-master-start

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
#!/bin/sh
22

33
# Example on-master-start script
4-
5-
# Source function library.
6-
. /etc/init.d/functions
7-
4+
#
85
start() {
9-
echo -n $"Assuming role of master: "
6+
printf "%s" "Assuming role of master: "
107
touch /tmp/master
11-
echo -n $"OK"
12-
success $"OK"
13-
echo
8+
echo "OK"
149
return 0
1510
}
1611

1712
stop() {
18-
echo -n $"Dropping role of master: "
13+
echo "Dropping role of master: "
1914
rm -f /tmp/master
20-
echo
2115
return 0
2216
}
2317

@@ -37,6 +31,6 @@ case "$1" in
3731
restart
3832
;;
3933
*)
40-
echo $"Usage: $0 {start|stop|restart}"
34+
echo "Usage: $0 {start|stop|restart}"
4135
exit 1
4236
esac
File renamed without changes.

0 commit comments

Comments
 (0)