Closed a-schaefers closed 4 years ago
I chose nomenclature of "rc.conf" because that's what morpheus uses http://git.2f30.org/fs/files.html
Accidentally made a commit to the wrong branch. Fixed Sorry.
Not sure why shellcheck isn't happy
Fixed the warnings in the scripts as they're due to shellcheck not being able to lint the files sourced. Find to disable the warning.
I am trying to give us a kind of framework to work with. Obviously it's just a shell script and you could hijack the init script with it, but I don't think that should be an official intention. If you have a better idea what do you have in mind?
On Fri, Jan 10, 2020, 10:02 AM dylan notifications@github.com wrote:
@dylanaraps commented on this pull request.
In lib/init/rc.boot https://github.com/kisslinux/init/pull/3#discussion_r365359392:
- log "Loading rc.conf settings..."; {
- [ -f /etc/rc.conf ] && . /etc/rc.conf
- }
Is rc.conf 100% limited to 'var=value'? I have a simpler alternative to . if so.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kisslinux/init/pull/3?email_source=notifications&email_token=AGMPBIYS6MRLWOGX4M4WGFTQ5CZ4NA5CNFSM4KDS3BK2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCRMEP5Y#pullrequestreview-341329911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMPBI2JS6UIJ7HXGKSVT73Q5CZ4NANCNFSM4KDS3BKQ .
Well, if we want to treat it 100% as a config file we can do the following:
while read -r line; do
[ "${line##\#*}" ] || continue
export "$line"
done < /etc/rc.conf
This might be faster than .
and it treats everything after '=' as plain-text.
Well, if we want to treat it 100% as a config file we can do the following:
while read -r line; do [ "${line##\#*}" ] || continue export "$line" done < /etc/rc.conf
This might be faster than
.
and it treats everything after '=' as plain-text.
This is great.
Better:
while read -r line || [ "$line" ]; do
[ "${line##\#*}" ] && export "$line"
done < /etc/rc.conf
Go ahead and check the latest. I also moved the shutdown pre and post hooks in to main() now.
@dylanaraps
rc.boot 112 42 warning SC2163 This does not export 'line'. Remove $/${} for that, or use ${var?} to quiet. (sh-shellcheck)
rc.boot 175 33 warning SC1090 Can't follow non-constant source. Use a directive to specify location. (sh-shellcheck)
This is due to shellcheck being unable to "see" that we're dynamically allocating variables. Changing export "$line"
to export "${line?}"
will suppress the errors.
I'll also send you a new version which ignores lines which don't contain =
. This will make the parser also ignore lines containing shell code.
I'm going to add a "rc.common" file which contains functions shared between the two scripts. This will reduce the code overall while providing reusable functions between the two.
The new parser code for rc.conf
could be a function as well as the loops for boot/shutdown scripts.
Merged with the above mentioned changes. Also see: https://github.com/kisslinux/init/commit/0204205f20f0198d1d9ec11d44575859a7679b07
Packaging sinit https://github.com/kisslinux/community/pull/200 requires this, and it could be useful for other ideas,
For example, if you decide to rehash the rc.boot script, you could make a lot of it toggle-able options, which can be switched and diddled with by the user's settings in rc.conf