Skip to content

Commit

Permalink
fix: fix Linux package scripts (#800)
Browse files Browse the repository at this point in the history
* reload systemd daemon to make it aware of an updated service file
  after package update
* restart service to use the new binary after a package update
* don't stop and disable service after rpm package update

fixes #799
  • Loading branch information
netsandbox authored Jan 21, 2025
1 parent 6d091db commit f109066
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
25 changes: 25 additions & 0 deletions .chloggen/fix_linux_package_scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: packaging

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix Linux package scripts

# One or more tracking issues or pull requests related to the change
issues: [799]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
3 changes: 2 additions & 1 deletion distributions/otelcol-contrib/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# limitations under the License.

if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload
systemctl enable otelcol-contrib.service
if [ -f /etc/otelcol-contrib/config.yaml ]; then
systemctl start otelcol-contrib.service
systemctl restart otelcol-contrib.service
fi
fi
8 changes: 5 additions & 3 deletions distributions/otelcol-contrib/preremove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if command -v systemctl >/dev/null 2>&1; then
systemctl stop otelcol-contrib.service
systemctl disable otelcol-contrib.service
if [ "$1" != "1" ]; then
if command -v systemctl >/dev/null 2>&1; then
systemctl stop otelcol-contrib.service
systemctl disable otelcol-contrib.service
fi
fi
3 changes: 2 additions & 1 deletion distributions/otelcol-otlp/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# limitations under the License.

if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload
systemctl enable otelcol-otlp.service
if [ -f /etc/otelcol-otlp/config.yaml ]; then
systemctl start otelcol-otlp.service
systemctl restart otelcol-otlp.service
else
echo "Make sure to configure otelcol-otlp by creating /etc/otelcol-otlp/config.yaml"
fi
Expand Down
8 changes: 5 additions & 3 deletions distributions/otelcol-otlp/preremove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if command -v systemctl >/dev/null 2>&1; then
systemctl stop otelcol-otlp.service
systemctl disable otelcol-otlp.service
if [ "$1" != "1" ]; then
if command -v systemctl >/dev/null 2>&1; then
systemctl stop otelcol-otlp.service
systemctl disable otelcol-otlp.service
fi
fi
3 changes: 2 additions & 1 deletion distributions/otelcol/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# limitations under the License.

if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload
systemctl enable otelcol.service
if [ -f /etc/otelcol/config.yaml ]; then
systemctl start otelcol.service
systemctl restart otelcol.service
fi
fi
8 changes: 5 additions & 3 deletions distributions/otelcol/preremove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if command -v systemctl >/dev/null 2>&1; then
systemctl stop otelcol.service
systemctl disable otelcol.service
if [ "$1" != "1" ]; then
if command -v systemctl >/dev/null 2>&1; then
systemctl stop otelcol.service
systemctl disable otelcol.service
fi
fi

0 comments on commit f109066

Please sign in to comment.