Merge ~cjwatson/launchpad-bastion-scripts:run-action-restart-services into launchpad-bastion-scripts:main

Proposed by Colin Watson
Status: Merged
Merged at revision: aaddd21fd5ec6c60c691994234b04bdb209f4520
Proposed branch: ~cjwatson/launchpad-bastion-scripts:run-action-restart-services
Merge into: launchpad-bastion-scripts:main
Diff against target: 20 lines (+11/-1)
1 file modified
run-action (+11/-1)
Reviewer Review Type Date Requested Status
Simone Pelosi Approve
Review via email: mp+447998@code.launchpad.net

Commit message

run-action: Add convenience for restarting services

Description of the change

Our service charms typically define `stop-services` and `start-services` actions where relevant. Add a `restart-services` form for convenience, which calls them both in sequence.

To post a comment you must log in.
Revision history for this message
Simone Pelosi (pelpsi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/run-action b/run-action
2index c37b62d..73d6c15 100755
3--- a/run-action
4+++ b/run-action
5@@ -18,4 +18,14 @@ case $unit in
6 esac
7
8 mkdir -p "$HOME/logs"
9-ssh -i ~/.ssh/id-run-action_ed25519 prod-launchpad@is-bastion-ps5.internal "$unit" "$action" 2>&1 | tee -a "$HOME/logs/$(date +%F).log"
10+
11+run_action () {
12+ ssh -i ~/.ssh/id-run-action_ed25519 prod-launchpad@is-bastion-ps5.internal "$1" "$2" 2>&1 | tee -a "$HOME/logs/$(date +%F).log"
13+}
14+
15+if [ "$action" = restart-services ]; then
16+ run_action "$unit" stop-services
17+ run_action "$unit" start-services
18+else
19+ run_action "$unit" "$action"
20+fi

Subscribers

People subscribed via source and target branches