#!/bin/sh
#
# enable swap if zram is configured
#

# sanity check
if [ ! -b /dev/zram0 ]; then
    exit 1
fi

if ! grep -q zram0 /proc/swaps; then
    mkswap /dev/zram0 || true
    swapon /dev/zram0 || true
fi
# if we use zram anyway lets drop the slow on disk swap file
if grep -q /userdata/SWAP.img /proc/swaps && grep -q zram0 /proc/swaps; then
    swapoff /userdata/SWAP.img
fi
