Browse Source

bugfix systemd working 27.06.18:4.30

master 5 years ago
parent
commit
1c87452963

+ 23 - 7
zramraid.deb/etc/init.d/zramraid-manager

@@ -10,12 +10,12 @@
10
 ### END INIT INFO
10
 ### END INIT INFO
11
 ## version =25.06.18
11
 ## version =25.06.18
12
 PARMS=$1
12
 PARMS=$1
13
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
13
+PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/zramraid";
14
 DESC="Zram Raid"
14
 DESC="Zram Raid"
15
 NAME="zramraid"
15
 NAME="zramraid"
16
 SCRIPTNAME="zramraid-maker";
16
 SCRIPTNAME="zramraid-maker";
17
 ZPATH="/etc/zramraid"
17
 ZPATH="/etc/zramraid"
18
-MODE="/etc/defaults/zramraid";
18
+MODE="/etc/default/zramraid";
19
 ##
19
 ##
20
 
20
 
21
 if [[ "$PARMS" = '' ]];
21
 if [[ "$PARMS" = '' ]];
@@ -24,16 +24,27 @@ if [[ "$PARMS" = '' ]];
24
  exit 0
24
  exit 0
25
 fi
25
 fi
26
 
26
 
27
-function zramraidBoot() {
28
-if [ $(echo $(($(echo $USER|wc -m)-1))) == 0 ]
27
+function zBoot() {
28
+if [ ! $(echo $USER|grep root|wc -m) = 0 ]
29
     then
29
     then
30
     if [ $(cat $MODE |grep mode|grep -v '#'|sed 's/\mode=//g'|sed 's/\"//g;s/\;//g'|grep auto|wc -m) == 0 ]
30
     if [ $(cat $MODE |grep mode|grep -v '#'|sed 's/\mode=//g'|sed 's/\"//g;s/\;//g'|grep auto|wc -m) == 0 ]
31
 	then
31
 	then
32
+	    echo "$(date) $NAME: no autostart from boot! mode=manual - /etc/defaults/zramraid">>/var/log/zramraid.log
32
 	    exit 0;
33
 	    exit 0;
33
 	else
34
 	else
34
 	$ZPATH/$SCRIPTNAME --on
35
 	$ZPATH/$SCRIPTNAME --on
35
     fi
36
     fi
36
-    echo "$NAME:Sorry.. The only root privileges!"
37
+    echo "$NAME:Sorry.. The only root privileges! user:$USER"
38
+    exit 0;
39
+fi
40
+}
41
+
42
+function zRun() {
43
+if [ ! $(echo $USER|grep root|wc -m) = 0 ]
44
+    then
45
+	$ZPATH/$SCRIPTNAME --on
46
+    else
47
+    echo "$NAME:Sorry.. The only root privileges! user:$USER"
37
     exit 0;
48
     exit 0;
38
 fi
49
 fi
39
 }
50
 }
@@ -41,7 +52,7 @@ fi
41
 ### begin
52
 ### begin
42
 case "$PARMS" in
53
 case "$PARMS" in
43
 "start" | "start" )
54
 "start" | "start" )
44
-zramraidBoot;
55
+zRun;
45
 exit 0
56
 exit 0
46
 ;;
57
 ;;
47
 
58
 
@@ -53,7 +64,7 @@ exit 0
53
 "restart" | "restart" )
64
 "restart" | "restart" )
54
 $ZPATH/$SCRIPTNAME --off
65
 $ZPATH/$SCRIPTNAME --off
55
 sleep 3
66
 sleep 3
56
-zramraidBoot;
67
+zRun;
57
 exit 0
68
 exit 0
58
 ;;
69
 ;;
59
 
70
 
@@ -62,6 +73,11 @@ $ZPATH/$SCRIPTNAME --status
62
 exit 0
73
 exit 0
63
 ;;
74
 ;;
64
 
75
 
76
+"boot" | "boot" )
77
+zBoot;
78
+exit 0
79
+;;
80
+
65
 * )
81
 * )
66
 echo
82
 echo
67
 echo "no input parameters."
83
 echo "no input parameters."

+ 7 - 0
zramraid.deb/lib/systemd/system/zramraid.service

@@ -6,9 +6,16 @@ After=dbus.service iscsid.service apparmor.service local-fs.target
6
 Conflicts=shutdown.target 
6
 Conflicts=shutdown.target 
7
 
7
 
8
 [Service]
8
 [Service]
9
+User=root
10
+Group=root
9
 Type=oneshot
11
 Type=oneshot
12
+GuessMainPID=no
13
+RemainAfterExit=yes
14
+WorkingDirectory=/etc/zramraid/
10
 ExecStart=/etc/init.d/zramraid-manager start
15
 ExecStart=/etc/init.d/zramraid-manager start
11
 ExecStop=/etc/init.d/zramraid-manager stop
16
 ExecStop=/etc/init.d/zramraid-manager stop
17
+ExecReload=/etc/init.d/zramraid-manager restart
18
+TimeoutSec=5min
12
 
19
 
13
 [Install]
20
 [Install]
14
 WantedBy=multi-user.target
21
 WantedBy=multi-user.target