Skip to main content
Topic: Does sysvinit require shell scripts or can it be written in zig/rust? (Read 211 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Does sysvinit require shell scripts or can it be written in zig/rust?

Can sysvinit scripts be written in any programming language?
Does it have to be a posix shell script?
Or can it be a C/C++ script instead in /etc/init.d/?

Re: Does sysvinit require shell scripts or can it be written in zig/rust?

Reply #1
Can sysvinit scripts be written in any programming language?
Does it have to be a posix shell script?
Or can it be a C/C++ script instead in /etc/init.d/?
A 'script' can only be written in a scripting programming language.
Some of which are Unix Shell scripts (ksh, csh, bash, sh etc) which have various degrees of POSIX compliance.

C and C++ are not scripted languages so you can't put a  C/C++ script anywhere.

What is it you are actually trying to do ?

Re: Does sysvinit require shell scripts or can it be written in zig/rust?

Reply #2
never mind.
Will try dinit instead.
Thanks.

Re: Does sysvinit require shell scripts or can it be written in zig/rust?

Reply #3
Artix doesn't offer sysvinit as an init anyway. OpenRC is similar but the init scripts use OpenRC specific instructions which aren't sh or bash, but you can use elements of those too. So in practice you can usually write a simple init script of just a few lines using the OpenRC keywords (which are calling the OpenRC internal functions written in C) with no real shell scripting at all, not too dissimilar to a systemd service. Also you can write a compiled C program and call that from the init script if you want. That is all a shell script does really though, and the reason writing in C is faster is because under the hood the shell script is a higher level language that calls other programs, ie you write a single line saying ls /somedir |grep somestring and you are really running the thousands of lines of C code that make up "ls" and "grep" which also contain functionality you don't actually need for that specific task, so it would be faster to write your own specific C app but then it would take hundreds of lines of code to replace one, and it would save no appreciable time for that one simple task. Running a few lines of shell script at boot is irrelevant compared to the vast quantities of other things that happen then - it's not the init scripts which define the boot time, probably more like how inits use parallelism. The benefit of OpenRC is that it's well tested and can usually be relied on to bring up things in the right order without hitting race conditions.
Go for dinit if you want though, the choice is yours!  ;D

 

Re: Does sysvinit require shell scripts or can it be written in zig/rust?

Reply #4
I use dinit.  I like it a lot.  I also recommend it or openrc.
Cat Herders of Linux