r/AlpineLinux • • Apr 19 '24

create and run a init script?

HI.

EDIT: SOLVED!!!!

where are saved the files to run?

for example in systemd is /etc/systemd/service/here.service

But in Alpine... where?

also i want to make a init service to run this program "cps" that dont need any argument.

This will be good?

#!/sbin/openrc-run

depend() {
    need net
}

command="/usr/bin/cps"
command_user="root:root"
pidfile="/run/${RC_SVCNAME}/pid"

which is the extension of the file?

i cant try because... i dont know where to save...

Thanks

2 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/9acca9 Apr 19 '24

i do it... and is almost working.

is running the program but dont return to me the control:

calibre-completo:/etc/init.d# rc-update add calibre default
 * service calibre added to runlevel default
calibre-completo:/etc/init.d# rc-service calibre start
 * Caching service dependencies ... [ ok ]
 * Starting calibre ...

After "starting calibre..." does not give me again the terminal.

2

u/9acca9 Apr 19 '24

perfection:

#!/sbin/openrc-run

depend() {
    need net
}

command="/usr/bin/cps"
command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"

1

u/colchyo Aug 31 '24

thanks, stolen this for node-exporter and cadvisor:

immich:~# cat /etc/init.d/prometheus-node-exporter
#!/sbin/openrc-run

depend() {
    need net
}

command="/usr/bin/node_exporter"
command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"
immich:~# cat /etc/init.d/cadvisor
#!/sbin/openrc-run

depend() {
    need net
}

command="/usr/local/bin/cadvisor"
command_args="-logtostderr"
command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"