Skip to content

Commit 01acc6b

Browse files
tidy various
1 parent fb86812 commit 01acc6b

File tree

1 file changed

+20
-87
lines changed

1 file changed

+20
-87
lines changed

zram-config

+20-87
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,6 @@ case "$1" in
185185
rm -f ${ZSHARE}/zram-device-list >>${ZLOG}
186186
file=/etc/ztab
187187
ZTAB_EMPTY=true
188-
#Only 1 log can exist also make first as then last removed
189-
line=$(grep ^log $file | head -n 1)
190-
if [ ! -z "$line" ]
191-
then
192-
set -- $line
193-
echo "ztab create $1 $2 $3 $4 $5 $6 $7 $8 $9" >>${ZLOG}
194-
ZTAB_EMPTY=false
195-
ZTYPE=$1
196-
ALG=$2
197-
MEM_SIZE=$3
198-
DISK_SIZE=$4
199-
TARGET_DIR=$5
200-
BIND_DIR=$6
201-
OLDLOG_DIR=$7
202-
createZlog
203-
fi
204188
while read -r line; do
205189
case "$line" in
206190
"#"*)
@@ -213,10 +197,6 @@ case "$1" in
213197
continue
214198
;;
215199

216-
log*)
217-
# Skip empty line
218-
continue
219-
;;
220200
*)
221201
set -- $line
222202
echo "ztab create $1 $2 $3 $4 $5 $6 $7 $8 $9" >>${ZLOG}
@@ -237,12 +217,19 @@ case "$1" in
237217
BIND_DIR=$6
238218
createZdir
239219
;;
220+
log)
221+
TARGET_DIR=$5
222+
BIND_DIR=$6
223+
OLDLOG_DIR=$7
224+
createZlog
225+
;;
240226
esac
241227
;;
242228
esac
243229
done < "$file"
244230
if [ "$ZTAB_EMPTY" = true ] ; then
245231
echo '/etc/ztab is empty and needs to be configured' >>${ZLOG}
232+
exit 1
246233
fi
247234
;;
248235
stop)
@@ -260,92 +247,38 @@ case "$1" in
260247
# Skip empty line
261248
continue
262249
;;
263-
264-
log*)
265-
# Skip empty line
266-
continue
267-
;;
268-
269250
*)
270251
set -- $line
271252
echo "ztab remove $1 $2 $3 $4" >>${ZLOG}
272-
273253
case "$1" in
274254
swap)
255+
ZTYPE=$1
275256
ZRAM_DEV=$2
276257
LABEL=$3
277258
removeZswap
278259
;;
279260
dir)
261+
ZTYPE=$1
280262
ZRAM_DEV=$2
281263
TARGET_DIR=$3
282264
BIND_DIR=$4
283265
removeZdir
284266
;;
267+
log)
268+
ZTYPE=$1
269+
ZRAM_DEV=$2
270+
TARGET_DIR=$3
271+
BIND_DIR=$4
272+
removeZlog
273+
;;
285274
esac
286275
;;
287276
esac
288277
done < "$file"
289-
#Only 1 log can exist also make first as then last removed
290-
file=${ZSHARE}/zram-device-list.rev
291-
line=$(grep ^log $file | head -n 1)
292-
if [ ! -z "$line" ]
293-
then
294-
set -- $line
295-
echo "ztab remove $1 $2 $3 $4 $5 $6 $7 $8 $9" >>${ZLOG}
296-
ZTAB_EMPTY=false
297-
ZRAM_DEV=$2
298-
TARGET_DIR=$3
299-
BIND_DIR=$4
300-
removeZlog
301-
fi
302278
rm -v ${ZSHARE}/zram-device-list.rev >>${ZLOG}
303279
;;
304-
write)
305-
echo "zram-config write $(date +%Y-%m-%d-%H:%M:%S)" >>${ZLOG}
306-
file=/etc/ztab
307-
#Only 1 log can exist also make first as then last removed
308-
line=$(grep ^log $file | head -n 1)
309-
if [ ! -z "$line" ]
310-
then
311-
set -- $line
312-
echo "ztab write $1 $2 $3 $4 $5 $6 $7 $8 $9" >>${ZLOG}
313-
ZTAB_EMPTY=false
314-
ALG=$2
315-
MEM_SIZE=$3
316-
DISK_SIZE=$4
317-
TARGET_DIR=$5
318-
BIND_DIR=$6
319-
OLDLOG_DIR=$7
320-
syncToDisk
321-
fi
322-
while read -r line; do
323-
case "$line" in
324-
"#"*)
325-
# Skip comment line
326-
continue
327-
;;
328-
329-
"")
330-
# Skip empty line
331-
continue
332-
;;
333-
334-
*)
335-
set -- $line
336-
ALG=$2
337-
MEM_SIZE=$3
338-
DISK_SIZE=$4
339-
case "$1" in
340-
dir)
341-
echo "ztab write $1 $2 $3 $4 $5 $6 $7 $8 $9" >>${ZLOG}
342-
TARGET_DIR=$5
343-
BIND_DIR=$6
344-
syncToDisk
345-
;;
346-
esac
347-
;;
348-
esac
349-
done < "$file"
350-
;;
280+
*)
281+
echo "Usage: zram-config {start|stop}" >&2
282+
exit 1
283+
;;
351284
esac

0 commit comments

Comments
 (0)