forked from Danw33/usb-modeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemd-detection.patch
45 lines (42 loc) · 1.9 KB
/
systemd-detection.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
diff --git a/usb-modeswitch/Makefile b/usb-modeswitch/Makefile
index 9aa7356..47f9859 100644
--- a/usb-modeswitch/Makefile
+++ b/usb-modeswitch/Makefile
@@ -7,7 +7,7 @@ RM = /bin/rm -f
OBJS = usb_modeswitch.c
PREFIX = $(DESTDIR)/usr
ETCDIR = $(DESTDIR)/etc
-SYSDIR = $(ETCDIR)/systemd/system
+SYSDIR = $(DESTDIR)/lib/systemd/system
UPSDIR = $(ETCDIR)/init
UDEVDIR = $(DESTDIR)/lib/udev
SBINDIR = $(PREFIX)/sbin
@@ -61,8 +61,7 @@ install-common: $(PROG) $(DISPATCH)
install -D --mode=644 usb_modeswitch_dispatcher.1 $(MANDIR)/usb_modeswitch_dispatcher.1
install -D --mode=755 usb_modeswitch_dispatcher $(SBINDIR)/usb_modeswitch_dispatcher
install -d $(DESTDIR)/var/lib/usb_modeswitch
- test -d $(UPSDIR) -a -e /sbin/initctl && install --mode=644 usb-modeswitch-upstart.conf $(UPSDIR) || test 1
- test -d $(SYSDIR) -a \( -e /usr/bin/systemctl -o -e /bin/systemctl \) && install --mode=644 usb_modeswitch@.service $(SYSDIR) || test 1
+ install -D --mode=644 usb_modeswitch@.service $(SYSDIR)/usb_modeswitch@.service
install: install-script
diff --git a/usb-modeswitch/usb_modeswitch.sh b/usb-modeswitch/usb_modeswitch.sh
index 57c2dfe..f70e04c 100755
--- a/usb-modeswitch/usb_modeswitch.sh
+++ b/usb-modeswitch/usb_modeswitch.sh
@@ -63,13 +63,12 @@ fi
PATH=/bin:/sbin:/usr/bin:/usr/sbin
init_path=`readlink -f /sbin/init`
-if [ `basename $init_path` = "systemd" ]; then
- systemctl --no-block restart usb_modeswitch@$p2.service
-elif [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
- initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$p2
+if sd_booted; then
+ systemctl=/bin/systemctl
+ exec $systemctl --no-block start usb_modeswitch@"${1%%/*}_${1##*/}".service
else
# only old distros, new udev will kill all subprocesses
exec 1<&- 2<&- 5<&- 7<&-
- exec usb_modeswitch_dispatcher --switch-mode $p2 &
+ exec usb_modeswitch_dispatcher --switch-mode "$p2"
fi
exit 0