Browse Source

the new version zram raid, new name, new installer

master 5 years ago
parent
commit
8d3a7f1543
1 changed files with 28 additions and 47 deletions
  1. 28 47
      zramraid.deb/zramraid-install

+ 28 - 47
zramraid.deb/zramraid-install

@@ -2,17 +2,15 @@
2 2
 ## zramraid-install (Default for Debian & Ubuntu)
3 3
 ## (c) author's idea and realization: Kleemov A. & Koshuba V.
4 4
 ## script author: Koshuba V - stvixfree@gmail.com
5
-## version = 10.03.18
5
+## version = 26.06.18
6 6
 option=$1;
7 7
 rdate=$(date +%c);
8 8
 reports=();
9
+getpkg=( "jq" "mdadm" "lsb-release" );
9 10
 test_module=$(find /lib/modules/$kernel_version -name '*.ko'|grep zram|wc -m);
10
-test_jq=$(apt-cache policy jq | grep status);
11
-test_mdadm=$(apt-cache policy mdadm | grep status);
12
-test_lsb_release=$(apt-cache policy lsb-release | grep status);
13 11
 log="/var/log/syslog";
14 12
 eval kernel_version="(" $(uname -r|sed 's/\./ /g') ")";
15
-debversion=$(lsb_release -c);
13
+deb_release=""
16 14
 ## functions & operations
17 15
 operation_install=( "clear" "testId" "checkDep" "checkMod" "install" "printInfo" );
18 16
 operation_uninstall=( "clear" "testId" "checkDep" "checkMod" "uninstall" "printInfo" );
@@ -120,29 +118,21 @@ fi
120 118
 
121 119
 ##--@F Check the program dependency
122 120
 function checkDep() {
123
-# This installation check jq
124
-if [ ! "$test_jq" ]
125
-    then
126
-    ## lang messages if yes then lang else us...
127
-    reports[${#reports[@]}]="Do not set jq package";
128
-    makeErr;
129
-fi
130
-# This installation check mdadm
131
-if [ ! "$test_mdadm" ]
132
-    then
133
-    reports[${#reports[@]}]="Do not set mdadm package";
134
-    makeErr;
121
+if [[ ! $(apt-cache policy ${getpkg[@]} | grep status|wc -l) = $(echo -e ${#getpkg[@]}) ]];
122
+    then apt-get install $(echo ${getpkg[@]});
135 123
 fi
136 124
 
137
-# This installation check mdadm
138
-if [ ! "$test_lsb_release" ]
125
+for ((ipkg=0; ipkg != ${#getpkg[@]}; ipkg++))
126
+ do
127
+    if [ ! "$(apt-cache policy ${getpkg[$ipkg]} | grep status)" ]
139 128
     then
140
-    reports[${#reports[@]}]="Do not set lsb_release package";
129
+    ## lang messages if yes then lang else us...
130
+    reports[${#reports[@]}]="Do not set ${getpkg[$ipkg]} package";
141 131
     makeErr;
142 132
 fi
143
-
144
-## check Debian or Ubuntu...
145
-##
133
+done
134
+local lsbtools=$(whereis -b lsb_release|awk '/^lsb_release:/{print $2}');
135
+deb_release=$( $lsbtools -r|awk '/^Release:/{print $2}'|sed 's/\./ /g'|awk '{print$1}' );
146 136
 }
147 137
 
148 138
 
@@ -158,19 +148,14 @@ cp -f $PWD/etc/init.d/zramraid-manager /etc/init.d/zramraid-manager;
158 148
 cp -f $PWD/etc/default/zramraid /etc/default/zramraid;
159 149
 ln -s /etc/zramraid/zramraid-maker /usr/local/bin/zramraid-maker;
160 150
 ln -s /etc/zramraid/zramraid-config /usr/local/bin/zramraid-config;
161
-## 4 deb 8.x end up
162
-if [ $(echo $debversion|grep jessie|wc -m) != 0 ]
163
-    then
164
-cp -f $PWD/lib/systemd/system/zramraid-start.service /lib/systemd/system/zramraid-start.service;
165
-cp -f $PWD/lib/systemd/system/zramraid-monitor.service /lib/systemd/system/zramraid-monitor.service;
166
-/bin/systemctl enable zramraid-start.service;
167
-/bin/systemctl enable zramraid-monitor.service;
168
-fi
169
-if [ $(echo $debversion|grep wheezy|wc -m) != 0 ]
170
-    then
171
-    update-rc.d -n zramraid-manager defaults;
151
+
152
+if [[ $deb_release < 8 ]]; 
153
+     then
154
+	update-rc.d -n zramraid-manager defaults;
155
+     else
156
+	cp -f $PWD/lib/systemd/system/zramraid.service /lib/systemd/system/zramraid.service;
157
+	/bin/systemctl enable zramraid.service;
172 158
 fi
173
-## update-rc.0 ..
174 159
 reports[${#reports[@]}]="zramraid install susseful";
175 160
 reports[${#reports[@]}]="please setup config for autostart from boot: /etc/default/zramraid.";
176 161
 writeToLog;
@@ -180,18 +165,14 @@ printInfo;
180 165
 function uninstall() {
181 166
 
182 167
 function zrDel() {
183
-if [ $(echo $debversion|grep jessie|wc -m) != 0 ]
184
-    then
185
-/bin/systemctl stop zramraid-manager;
186
-/bin/systemctl disable zramraid-start.service;
187
-/bin/systemctl disable zramraid-monitor.service;
188
-rm /lib/systemd/system/zramraid-start.service;
189
-rm /lib/systemd/system/zramraid-monitor.service;
190
-fi
191
-if [ $(echo $debversion|grep wheezy|wc -m) != 0 ]
192
-    then
193
-    /etc/init.d/zramraid-manager stop;
194
-    update-rc.d -n zramraid-manager remove;
168
+if [[ $deb_release < 8 ]]; 
169
+     then
170
+	/etc/init.d/zramraid-manager stop;
171
+	update-rc.d -n zramraid-manager remove;
172
+     else
173
+    /bin/systemctl stop zramraid-manager;
174
+    /bin/systemctl disable zramraid.service;
175
+    rm /lib/systemd/system/zramraid.service;
195 176
 fi
196 177
 	rm -f /usr/local/bin/zramraid-maker;
197 178
 	rm -f /usr/local/bin/zramraid-config;