Skip to content

Commit

Permalink
Fix shutdown service
Browse files Browse the repository at this point in the history
Fixes: #51

Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Dec 28, 2020
1 parent 2034d9f commit d716edc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions zram-config
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ serviceConfiguration() {
ZSHARE="/usr/local/share/zram-config"
ZLOG="${ZSHARE}/log/zram-config.log"
ZDIR="/opt/zram"
if [[ $2 == "shutdown" ]]; then
SERVICE="1"
fi
if [[ -f /boot/cmdline.txt ]] && grep -qs "init=/bin/ro-root.sh" /boot/cmdline.txt; then
ZEPHEMERAL="true"
else
Expand Down Expand Up @@ -282,6 +285,7 @@ case "$1" in
TARGET_DIR="$5"
BIND_DIR="$6"
if [[ $ZEPHEMERAL == "false" ]]; then
serviceConfiguration "stop"
createZdir
fi
;;
Expand Down Expand Up @@ -339,6 +343,9 @@ case "$1" in
TARGET_DIR="$3"
BIND_DIR="$4"
if [[ $ZEPHEMERAL == "false" ]]; then
if [[ -z $SERVICE ]]; then
serviceConfiguration "stop"
fi
removeZdir
fi
;;
Expand All @@ -348,7 +355,9 @@ case "$1" in
TARGET_DIR="$3"
BIND_DIR="$4"
if [[ $ZEPHEMERAL == "false" ]]; then
serviceConfiguration "stop"
if [[ -z $SERVICE ]]; then
serviceConfiguration "stop"
fi
removeZdir
fi
;;
Expand All @@ -372,4 +381,6 @@ case "$1" in
exit 1
;;
esac
serviceConfiguration "start"
if [[ -z $SERVICE ]]; then
serviceConfiguration "start"
fi
2 changes: 1 addition & 1 deletion zram-config.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Type=simple
TimeoutSec=300
RemainAfterExit=yes
ExecStart=/usr/local/sbin/zram-config "start"
ExecStop=/usr/local/sbin/zram-config "stop"
ExecStop=/usr/local/sbin/zram-config "stop" "shutdown"

[Install]
WantedBy=basic.target

0 comments on commit d716edc

Please sign in to comment.