<farkuhar>
zorz_: SiFuh_: While we've been content to hash out the /etc/rc issues over IRC, darfo went ahead and opened a Gitea issue. Maybe now it will get the discussion it deserves. https://git.crux.nu/tools/rc/issues/1
<zorz_>
i added bootlogd for bootlogin
<zorz_>
yeah, sifuh will finish it.
zorz_ has quit [Quit: leaving]
SiFuh_ has quit [Remote host closed the connection]
SiFuh_ has joined #crux-musl
zorz_ has joined #crux-musl
<farkuhar>
Hahaha, all those users having problems with pkexec. Serves them right for installing junk like linux-pam.
zorz_ has quit [Quit: leaving]
zorz_ has joined #crux-musl
zorz_ has quit [Quit: leaving]
zorz_ has joined #crux-musl
<farkuhar>
SiFuh_: I just tested the latest /etc/rc from my forked Gitea repo. It reboots and shuts down fine, although the /sbin/ldconfig command always seems to have nonzero exit status, generating the [ERROR] message.
<SiFuh_>
Don't care. You went way off the beaten path of what I wanted.
<SiFuh_>
I have no intention of making ansi.colours into a function whatsoever
<SiFuh_>
And I do not have plans to include rc.fix in the rc. I have other ideas for that.
<SiFuh_>
The idea of making a colour script is to be just that. Nothing more, nothing less. As I said. If you are going to inject functions into a plain text file then you may as well rename it to rc.functions like beerman did.
<farkuhar>
Heh, if you're willing to rely on bashisms, you could define an associative array using almost the same formatting as the text file in https://dpaste.com/8P7EJFYYX.txt
zorz_ has quit [Quit: Lost terminal]
<farkuhar>
And with an associative array, it's a quick and easy lookup to obtain the colour code.
<SiFuh_>
I could but the array will need to be in rc and not in the text file.
<farkuhar>
Let the text file serve as input to a `while read` loop in rc, and populate the associative array that way.
<SiFuh_>
Yes, I have a few examples. I am looking specifically for something small, clean and fast. I did similar in a few other scripts.
<SiFuh_>
And I did an array in a driver modification script for keyboard color light codes on a laptop once.
<SiFuh_>
farkuhar: And I have a POSIX client snippet I did earlier with a while loop. But I am still wondering why rc is written in bash and not POSIX
<farkuhar>
If we ever switch the interpreter of /etc/rc from bash to dash, then we'd have to avoid associative arrays. That's why I went with a function instead (more portable, and more forgiving of users permuting the arguments).
<farkuhar>
We'd also have to avoid the SERVICES array, with dash as the interpreter. I wrote a prototype back in January, where the SERVICES array was replaced by a list_enabled_services() function.
<farkuhar>
Now if we ported NetBSD's rcorder to CRUX, then the services could be enabled or disabled by setting a string variable for each one, and letting rcorder parse the headers in the rc.d service files to determine the appropriate startup sequence.
<farkuhar>
I'm a bit wary of relying on external binaries like rcorder or gawk, though. If rc can be written using only internal shell functions, then startup is more resilient against breakage due to dynamically-linked external programs.
<farkuhar>
SiFuh_: Yeah, that's not very portable if we eventually moved to dash.
<SiFuh_>
stick with sh ;-)
<farkuhar>
I doubt we can persuade the core team to give up the historical dependence on bash. So we might as well adopt whatever bashisms are needed, to obtain the lookup table from a plain-text file living in /etc.
<SiFuh_>
farkuhar: I don't. I am sure if the entire rc was written for sh and peformed as it should, they probably would accept it or wouldn't notice
<farkuhar>
The problem is not necessarily the core team themselves, but the pushback they'd give on behalf of users who are accustomed to bashisms like the SERVICES array. Having to overhaul their customized rc.conf because the interpreter changed, is a lot to ask of some CRUX users.
<farkuhar>
SiFuh_: https://dpaste.com/2TL9SACKQ <- associative array created using bash pattern trimming operators.
<SiFuh_>
farkuhar: Do you know 'hum' in Thai slang means penis right?
<SiFuh_>
Hahaha
<farkuhar>
Hmm, I'll have to watch my vocabulary carefully if I ever visit Thailand.
<SiFuh_>
farkuhar: I knew a German man in China. His name is Bodoh. I told him that he shouldn't to Indonesia or Malaysia because Bodoh actually means idiot/stupid
<farkuhar>
Oh, https://dpaste.com/2TL9SACKQ might only work if the leading spaces are deleted from each line of the text file. I forgot your copy had indented lines.
<SiFuh_>
Yeah, I ran into that problem with tabs and spaces. This is the most simple solution cat ansi.colors |grep "bold red" | awk '{print $NF}'
<farkuhar>
Better to save the file on disk in a format that bash can process quickly on its own, rather than spawning a separate grep or gawk process. It's not any less "human readable" if the lines aren't indented.
<SiFuh_>
Yep
<SiFuh_>
Mine aren't indented anymore, but I think emacs set my tabs up as spaces. :-)
<farkuhar>
Heh, apparently /sbin/ldconfig is provided by musl, and it must have a different API than the glibc-provided version (no support for empty arguments). That's why appending '|| { printerror; }' to the ldconfig line produced the error message.
<SiFuh_>
And it means I can strip alot of functions out
<SiFuh_>
And it is a bit faster than some of the others too
<SiFuh_>
farkuhar: Test 4 and test 9 are the fastest test 4 is the fastes
<SiFuh_>
So I have a fair idea which style of all the 11 I will probably choose.
zorz_ has joined #crux-musl
<SiFuh_>
Did you notice on the beerman rc that the system pauses around Screen Timeout ?
<farkuhar>
No, it hasn't been noticeable on any of my startups.
<SiFuh_>
Probably I notice it on the slower systems. rc.modules and /bin/dmesg > /var/log/boot
<SiFuh_>
They are after it. I might chuck a couple of echoes to see which is doing it.
<farkuhar>
So the pipe to xargs is in lieu of an early exit from the loop, when blank or commented lines are encountered?
<SiFuh_>
Trim all of the trailing whitespace
<SiFuh_>
clean_name and clean_code
<farkuhar>
That's not an internal bash function, though. Can you get a speedup by rewriting it in terms of internal bash functions?
<SiFuh_>
test 4 is way different
<SiFuh_>
test 4 uses full_name="${full_name%"${full_name##*[![:space:]]}"}"
<SiFuh_>
I just checked. It is the loading of modules that slows the computer down. I am using the modular kernel though.
<farkuhar>
I was leaning towards a bash pattern trimming operator too. But rather than nesting one match inside another, I just scanned for two consecutive whitespaces, which seems to work equally well at separating the columns.
<SiFuh_>
farkuhar: You ready for one of the ideas I never mentioned yet?
<farkuhar>
It's helpful that /sbin/ldconfig exits with nonzero status on CRUX-MUSL when no arguments are passed. That triggers the printerror() function so I can see that the colours are loaded correctly.
<farkuhar>
SiFuh_: Go ahead, share away.
<SiFuh_>
/etc/rc.modules.d <-- user run scripts or extra rc modules. rc.fix can be made a port and go into there, rc.shutdown also could go into there and so could the colour additions including ansi.colors
<SiFuh_>
rc would need to check this directory. It could be done automatically but some scripts that users could introduce may need to be run at different times or levels in the rc.
<farkuhar>
And that's where NetBSD's rcorder would come in handy. All that needs to be added is a header at the top of every script, indicating any dependencies that need to be started earlier in the sequence.