Skip to content

Commit

Permalink
Improve shutdown detection
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Dec 18, 2024
1 parent ac5e06f commit e8b2457
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion service/SystemD/zram-config.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ After=local-fs.target

[Service]
Type=oneshot
TimeoutStopSec=120
TimeoutStopSec=240
RemainAfterExit=yes
WorkingDirectory=/usr/local/lib/zram-config
ExecStart=/usr/local/sbin/zram-config "start"
Expand Down
10 changes: 5 additions & 5 deletions zram-config
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ removeZdir() {
return 1
fi

umountTarget "$TARGET_DIR" || return 1
umountTarget "$TARGET_DIR"

mergeOverlay || return 1

Expand All @@ -239,7 +239,7 @@ removeZdir() {
removeZswap() {
log "INFO" "Beginning removal of swap device."

if [[ -z $SHUTDOWN ]] && swapoff "/dev${ZRAM_DEV}" &> /dev/null; then
if [[ -z $SHUTDOWN ]] && ! swapoff "/dev${ZRAM_DEV}" &> /dev/null; then
log "ERROR" "Failed to swapoff /dev${ZRAM_DEV}."
return 1
fi
Expand Down Expand Up @@ -323,8 +323,8 @@ TMPDIR="/usr/local/lib/zram-config"
ZDIR="/opt/zram"
ZLOG="/usr/local/share/zram-config/log/zram-config.log"
OS="$(grep -o '^ID=.*$' /etc/os-release | cut -d'=' -f2)"
if [[ -s /run/systemd/shutdown/scheduled ]]; then
SHUTDOWN="1"
if systemctl list-jobs | grep -q 'shutdown.target.*start' || systemctl list-jobs | grep -q 'reboot.target.*start'; then
SHUTDOWN=1
fi

case "$1" in
Expand Down Expand Up @@ -420,7 +420,7 @@ case "$1" in
ZRAM_DEV="$2"
TARGET_DIR="$3"
BIND_DIR="$4"
[[ -z $SHUTDOWN ]] && serviceConfiguration "stop"
serviceConfiguration "stop"
removeZdir
;;
esac
Expand Down

0 comments on commit e8b2457

Please sign in to comment.