-
Notifications
You must be signed in to change notification settings - Fork 100
fix: avoid stopping nginx-agent service on package upgrade #352
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
Merged
oliveromahony
merged 7 commits into
nginx:main
from
defanator:AMP-796-fix-stop-on-upgrade
Nov 17, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3b48190
fix: restart service on package upgrade on Debian/Ubuntu
defanator 5841374
fix: do not stop service on upgrade (RHEL-based distros)
defanator 41b3d94
Avoid restarting nginx-agent service from pkg on FreeBSD during upgrades
defanator 5285e6a
feat: OpenRC package scripts for Alpine Linux
defanator 920ad17
chore: add Alpine Linux instructions to README
defanator 35a82dc
chore: adjust service description, remove modelines
defanator 9d70b92
chore: remove leading underscore from shell func names
defanator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/sbin/openrc-run | ||
|
|
||
| description="NGINX Agent" | ||
| command_background=true | ||
|
|
||
| cfgfile=${cfgfile:-/etc/nginx-agent/nginx-agent.conf} | ||
| pidfile=/var/run/nginx-agent.pid | ||
| command=/usr/bin/nginx-agent | ||
| command_args="" | ||
| required_files="$cfgfile" | ||
|
|
||
| depend() { | ||
| need net | ||
| use dns logger netmount | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,68 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Determine OS platform | ||
| # shellcheck source=/dev/null | ||
| . /etc/os-release | ||
|
|
||
| if [ "$ID" = "freebsd" ]; then | ||
| echo "Stop and remove nginx-agent service" | ||
| stop_agent_freebsd() { | ||
| echo "Stopping nginx-agent service" | ||
| service nginx-agent onestop >/dev/null 2>&1 || true | ||
| } | ||
|
|
||
| disable_agent_freebsd() { | ||
| echo "Disabling nginx-agent service" | ||
| sysrc -x nginx_agent_enable >/dev/null 2>&1 || true | ||
| elif command -V systemctl >/dev/null 2>&1; then | ||
| echo "Stop and disable nginx-agent service" | ||
| } | ||
|
|
||
| stop_agent_systemd() { | ||
| echo "Stopping nginx-agent service" | ||
| systemctl stop nginx-agent >/dev/null 2>&1 || true | ||
| } | ||
|
|
||
| disable_agent_systemd() { | ||
| echo "Disabling nginx-agent service" | ||
| systemctl disable nginx-agent >/dev/null 2>&1 || true | ||
| } | ||
|
|
||
| systemd_daemon_reload() { | ||
| echo "Running daemon-reload" | ||
| systemctl daemon-reload || true | ||
| fi | ||
| } | ||
|
|
||
| cleanup() { | ||
| echo "Removing /var/run/nginx-agent directory" | ||
| rm -rf "/var/run/nginx-agent" | ||
| } | ||
|
|
||
| echo "Removing /var/run/nginx-agent directory" | ||
| rm -rf "/var/run/nginx-agent" | ||
| echo "Removing /var/log/nginx-agent directory" | ||
| rm -rf "/var/log/nginx-agent" | ||
| case "$ID" in | ||
| freebsd) | ||
| stop_agent_freebsd | ||
| disable_agent_freebsd | ||
| cleanup | ||
| ;; | ||
| debian|ubuntu) | ||
| if [ "$1" = "remove" ]; then | ||
| stop_agent_systemd | ||
| disable_agent_systemd | ||
| systemd_daemon_reload | ||
| cleanup | ||
| fi | ||
| ;; | ||
| rhel|fedora|centos|amzn|almalinux|rocky) | ||
| if [ "$1" = "0" ]; then | ||
| stop_agent_systemd | ||
| disable_agent_systemd | ||
| systemd_daemon_reload | ||
| cleanup | ||
| fi | ||
| ;; | ||
| alpine) | ||
| cleanup | ||
| ;; | ||
| *) | ||
| stop_agent_systemd | ||
| disable_agent_systemd | ||
| systemd_daemon_reload | ||
| cleanup | ||
| ;; | ||
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/sh | ||
|
|
||
| NEWVER="$1" | ||
| OLDVER="$2" | ||
|
|
||
| restart_agent_if_required() { | ||
| if service nginx-agent status >/dev/null 2>&1; then | ||
| printf "PostUpgrade: Restarting nginx agent (upgraded to %s from %s)\n" "$NEWVER" "$OLDVER" | ||
| service nginx-agent restart || true | ||
| fi | ||
| } | ||
|
|
||
| # Determine OS platform | ||
| # shellcheck source=/dev/null | ||
| . /etc/os-release | ||
|
|
||
| case "$ID" in | ||
| alpine) | ||
| restart_agent_if_required | ||
| ;; | ||
| esac | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,4 +164,4 @@ update_config_file() { | |
| ensure_sudo | ||
| load_config_values | ||
| update_config_file | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,17 @@ | ||
| #!/bin/sh | ||
| # Pre Remove Steps | ||
|
|
||
| # Determine OS platform | ||
| # shellcheck source=/dev/null | ||
| . /etc/os-release | ||
|
|
||
| stop_agent_openrc() { | ||
| echo "Stopping nginx-agent service" | ||
| service nginx-agent stop 2>&1 || true | ||
| } | ||
|
|
||
| case "$ID" in | ||
| alpine) | ||
| stop_agent_openrc | ||
| ;; | ||
| esac |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.