Skip to content

Commit

Permalink
fix zram-device-list for multiple starts or stops in a row
Browse files Browse the repository at this point in the history
  • Loading branch information
mstormi authored Aug 23, 2019
1 parent f968616 commit 0f145d2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions zram-config
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fi
case "$1" in
start)
echo "zram-config start $(date +%Y-%m-%d-%H:%M:%S)" >>${ZLOG}
rm -f ${ZSHARE}/zram-device-list >>${ZLOG}
rm -f ${ZSHARE}/zram-device-list.new >>${ZLOG}
file=/etc/ztab
ZTAB_EMPTY=true
while read -r line; do
Expand All @@ -268,6 +268,18 @@ case "$1" in
ALG=$2
MEM_SIZE=$3
DISK_SIZE=$4
if [ "$1" = "swap" ]; then
entry=$(egrep "^swap" ${ZSHARE}/zram-device-list)
else
entry=$(egrep "$1.*$5" ${ZSHARE}/zram-device-list)
fi
if [ -n "$entry" ]; then
echo "entry $entry already exists as zram."
echo $entry >> ${ZSHARE}/zram-device-list.new
continue
fi
mv ${ZSHARE}/zram-device-list.new ${ZSHARE}/zram-device-list

case "$1" in
swap)
PRIORITY=$5
Expand Down Expand Up @@ -346,7 +358,7 @@ case "$1" in
;;
esac
done < "$file"
rm -v ${ZSHARE}/zram-device-list.rev >>${ZLOG}
rm -fv ${ZSHARE}/zram-device-list.rev ${ZSHARE}/zram-device-list >>${ZLOG}
;;

enable-ephemeral)
Expand Down

0 comments on commit 0f145d2

Please sign in to comment.