The officially official Devuan Forum!

You are not logged in.

#1 2022-06-05 07:40:21

sudo
Member
Registered: 2022-04-06
Posts: 16  

[SOLVED] Runit Services?

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

#2 2022-06-05 11:20:03

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: [SOLVED] Runit Services?

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

#3 2022-06-05 14:36:21

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: [SOLVED] Runit Services?

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

#4 2022-06-05 18:58:50

sudo
Member
Registered: 2022-04-06
Posts: 16  

Re: [SOLVED] Runit Services?

Thanks!

Offline

Board footer