#!/sbin/openrc-run
# SPDX-License-Identifier: GPL-2.0-only

depend() {
  need localmount
  after bootmisc modules
  provide swap
}

start() {
  ebegin "Starting zram swap"
  if [ ! -f /usr/share/misc/source_deviceinfo ]; then
    eend 1 "deviceinfo not found"
    return 1
  fi

  zramstart
  eend $?
}

stop() {
  if [ "$RC_RUNLEVEL" = "shutdown" ]; then
    return 0
  fi
  ebegin "Stopping zram swap"
  zramstop
  eend $?
}
