-
Notifications
You must be signed in to change notification settings - Fork 542
Write alpine service scripts directly #2117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5492,15 +5492,22 @@ install_alpine_linux_post() { | |
| [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue | ||
|
|
||
| if [ -f /sbin/rc-update ]; then | ||
| script_url="${_SALTSTACK_REPO_URL%.git}/raw/master/pkg/alpine/salt-$fname" | ||
| [ -f "/etc/init.d/salt-$fname" ] || __fetch_url "/etc/init.d/salt-$fname" "$script_url" | ||
| local script_path="/etc/init.d/salt-$fname" | ||
| if ! [ -f "$script_path" ]; then | ||
| cat <<_eof > "$script_path" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the heredoc delimiter For example, line 5499 ( To pass the text completely literally and allow OpenRC to handle its own variable definitions cleanly, we should quote the delimiter. Suggested Change: cat << '_eof' > "$script_path" |
||
| #!/sbin/openrc-run | ||
| command="/usr/bin/salt-${fname}" | ||
| command_args="--daemon" | ||
| pidfile="/var/run/salt-${fname}.pid" | ||
| name="Salt ${fname} daemon" | ||
|
|
||
| # shellcheck disable=SC2181 | ||
| if [ $? -eq 0 ]; then | ||
| chmod +x "/etc/init.d/salt-$fname" | ||
| else | ||
| echoerror "Failed to get OpenRC init script for $OS_NAME from $script_url." | ||
| return 1 | ||
| depend() { | ||
| need localmount | ||
| use net | ||
| after bootmisc | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the heredoc delimiter is quoted, these lines will write nicely to the file. However, standard ShellCheck guidelines for OpenRC scripts recommend ensuring variables inside the definitions are safe. It looks clean, but just double-check that the indentation within the |
||
| _eof | ||
| chmod +x "$script_path" | ||
| fi | ||
|
|
||
| # Skip salt-api since the service should be opt-in and not necessarily started on boot | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While
script_pathis correctly defined as a local variable,fnameis used throughout this block without being explicitly declared local at the top of theinstall_alpine_linux_post()function. If it isn't already, we should ensure fname is scoped locally to avoid leaking or mutating global state.