← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad-bastion-scripts:run-action-restart-services into launchpad-bastion-scripts:main.

Commit message:
run-action: Add convenience for restarting services

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-bastion-scripts/+git/launchpad-bastion-scripts/+merge/447998

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-bastion-scripts:run-action-restart-services into launchpad-bastion-scripts:main.
diff --git a/run-action b/run-action
index c37b62d..73d6c15 100755
--- a/run-action
+++ b/run-action
@@ -18,4 +18,14 @@ case $unit in
 esac
 
 mkdir -p "$HOME/logs"
-ssh -i ~/.ssh/id-run-action_ed25519 prod-launchpad@is-bastion-ps5.internal "$unit" "$action" 2>&1 | tee -a "$HOME/logs/$(date +%F).log"
+
+run_action () {
+	ssh -i ~/.ssh/id-run-action_ed25519 prod-launchpad@is-bastion-ps5.internal "$1" "$2" 2>&1 | tee -a "$HOME/logs/$(date +%F).log"
+}
+
+if [ "$action" = restart-services ]; then
+	run_action "$unit" stop-services
+	run_action "$unit" start-services
+else
+	run_action "$unit" "$action"
+fi