You are not logged in.
Pages: 1
Hi friends, I wrote the following script for OpenRC that when the computer comes up, start Zram as well, but I decide to use Runit, how is this script written for Runit?
#!/sbin/openrc-run
name=$RC_SVCNAME
command="zramswap start"
My language is not English, so I apologize in advance for the mistakes you see in my grammar and writing.
Last edited by sudo (2022-06-05 07:41:03)
Offline
A sysvinit script can be used with runit and sysd2v.sh can be used to convert the systemd zramswap.service unit file:
[Unit]
Description=Linux zramswap setup
Documentation=man:zramswap(8)
[Service]
EnvironmentFile=-/etc/default/zramswap
ExecStart=/usr/sbin/zramswap start
ExecStop=/usr/sbin/zramswap stop
ExecReload=/usr/sbin/zramswap restart
Type=oneshot
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
^ Copy that to zramswap.service then run these commands in the directory containing that file:
wget https://git.savannah.nongnu.org/cgit/sysvinit.git/plain/contrib/sysd2v.sh
chmod +x sysd2v.sh
./sysd2v.sh zramswap.service > zramswap
sudo mv zramswap /etc/init.d/
sudo update-rc.d zramswap defaults
If you want to make a proper runit service instead then see https://salsa.debian.org/runit-team/run … ian/README
Brianna Ghey — Rest In Power
Offline
Maybe like this.
Create the following three files:
/etc/sv/zramswap/run
#!/usr/bin/env /lib/runit/invoke-run
set -e
exec 2>&1
# don't restart zramswap when it's done
sv once zramswap
exec /usr/sbin/zramswap
/etc/sv/zramswap/finish
#!/bin/sh
set -e
. /lib/runit/finish-default "$@"
/etc/sv/zramswap/log/run
#!/bin/sh
set -e
NAME=zramswap
LOG="/var/log/runit/$NAME"
test -d "$LOG" || mkdir "$LOG" && chown -R _runit-log:adm "$LOG"
exec chpst -u _runit-log svlogd -tt "$LOG"
Make all three files executable:
chmod +x /etc/sv/zramswap/run /etc/sv/zramswap/finish /etc/sv/zramswap/log/run
Add the service and test to see if it's running:
update-service --add /etc/sv/zramswap
sv status zramswap
Offline
Thanks!
Offline
Pages: 1