diff --git a/main/venom-zram/.checksums b/main/venom-zram/.checksums new file mode 100644 index 000000000..1bce7ff64 --- /dev/null +++ b/main/venom-zram/.checksums @@ -0,0 +1,5 @@ +82cb6a55b9df9c192bee81b4b5d6516f finish.zramd +7689d3fcbc7780e7d9b39c0f7be462b2 rc.zramd +f4ff43043c8c6b1665b3566602382aae run.zramd +06bdfba41f6a66adb7a0670a2372bf19 venom-zram +cf416b521356b90db26aa99f94e55fa8 venom-zram.conf diff --git a/main/venom-zram/.pkgfiles b/main/venom-zram/.pkgfiles new file mode 100644 index 000000000..446f0df7f --- /dev/null +++ b/main/venom-zram/.pkgfiles @@ -0,0 +1,8 @@ +venom-zram-0.1-1 +drwxr-xr-x root/root etc/ +drwxr-xr-x root/root etc/rc.d/ +-rwxr-xr-x root/root etc/rc.d/zramd +-rw-r--r-- root/root etc/venom-zram.conf +drwxr-xr-x root/root usr/ +drwxr-xr-x root/root usr/bin/ +-rwxr-xr-x root/root usr/bin/venom-zram diff --git a/main/venom-zram/finish.zramd b/main/venom-zram/finish.zramd new file mode 100755 index 000000000..ecda0666c --- /dev/null +++ b/main/venom-zram/finish.zramd @@ -0,0 +1,2 @@ +#! /bin/sh +venom-zram toss diff --git a/main/venom-zram/rc.zramd b/main/venom-zram/rc.zramd new file mode 100755 index 000000000..5a0f3c22f --- /dev/null +++ b/main/venom-zram/rc.zramd @@ -0,0 +1,34 @@ +#!/bin/sh +# +# /etc/rc.d/zramd: start/stop Zram Service +# + +. /etc/rc.subr + +NAME="Zramd" +PROG="/usr/bin/venom-zram" + +case $1 in + start) + msg "Starting $NAME..." + $PROG make + ;; + stop) + msg "Stopping $NAME..." + $PROG toss + ;; + restart) + $0 stop + sleep 2 + $0 start + ;; + status) + [ -z "$( awk 'NR==2 {print $1}' /proc/swaps)" ] && \ + msg "$NAME is running\n" || msg "$NAME is not running\n" + ;; + *) + echo "usage: $0 [start|stop|restart|status]" + ;; +esac + +# End of file diff --git a/main/venom-zram/run.zramd b/main/venom-zram/run.zramd new file mode 100755 index 000000000..080e1df5a --- /dev/null +++ b/main/venom-zram/run.zramd @@ -0,0 +1,3 @@ +#!/bin/sh +[ -r /etc/venom-zram.conf ] && . /etc/venom-zram.conf +venom-zram make & diff --git a/main/venom-zram/spkgbuild b/main/venom-zram/spkgbuild new file mode 100644 index 000000000..428207d6d --- /dev/null +++ b/main/venom-zram/spkgbuild @@ -0,0 +1,25 @@ +# description : Manage zram space +# depends : util-linux lz4 +# optional : zstd + +name=venom-zram +version=0.1 +release=1 +source="venom-zram venom-zram.conf rc.zramd run.zramd finish.zramd" + +build() { + + install -Dm755 venom-zram -t $PKG/usr/bin/ + install -Dm644 venom-zram.conf -t $PKG/etc/ + _runit() { + install -Dm755 run.zramd $PKG/etc/sv/zramd/run + install -Dm755 finish.zramd $PKG/etc/sv/zramd/finish + ln -s /run/runit/supervise.zramd $PKG/etc/sv/zramd/supervise + } + + _sysv() { + install -Dm755 rc.zramd $PKG/etc/rc.d/zramd + } + + scratch isinstalled runit && _runit || _sysv +} diff --git a/main/venom-zram/venom-zram b/main/venom-zram/venom-zram new file mode 100755 index 000000000..6dc8489c0 --- /dev/null +++ b/main/venom-zram/venom-zram @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Venom Linux zram script +# +# License: GPLv3 +# + +# source config if exist + [ -f /etc/venom-zram.conf ] && . /etc/venom-zram.conf + +# check if the compressor is set if not set it + [ -z $COMP ] && COMP=lz4 + +# MEM is total ram value +MEM=$( free --mebi | awk '/Mem:/ {print $2}') + +# check if zram size is set if not set it + [ -z $SIZE ] && ZRAM_SIZE=$MEM + +# seting zram size + ZRAM_SIZE=$(( $MEM * $SIZE / 100 )) + +make() { + modprobe zram + zramctl -f -a $COMP -s ${ZRAM_SIZE}MiB > /dev/null + mkswap --quiet --label zram0 /dev/zram0 + swapon --priority 32767 /dev/zram0 +} + +toss() { + swapoff /dev/zram0 + sleep 1 + zramctl --reset /dev/zram0 + rmmod zram +} + + +case "$1" in + make) make ;; + toss) toss ;; +esac diff --git a/main/venom-zram/venom-zram.conf b/main/venom-zram/venom-zram.conf new file mode 100755 index 000000000..d8d2a69da --- /dev/null +++ b/main/venom-zram/venom-zram.conf @@ -0,0 +1,10 @@ +# Venom linux zram config +# Venom zram config file + +# Zram size percent +SIZE=20 + +# Compression algorithms supported : lzo, lz4, lz4hc, deflate, 842 , zstd +COMP=lz4 + +