From 9be31c30319e5b9ea1d809bc2b9ea5c6238254a3 Mon Sep 17 00:00:00 2001 From: dominikn Date: Mon, 16 Sep 2024 19:04:49 +0000 Subject: [PATCH] add restart app --- snap/local/post_install.sh | 14 ++++++++++++++ snap/local/restart_launcher.sh | 9 +++++++++ snapcraft_template.yaml.jinja2 | 6 ++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 snap/local/post_install.sh create mode 100755 snap/local/restart_launcher.sh diff --git a/snap/local/post_install.sh b/snap/local/post_install.sh new file mode 100755 index 0000000..705dfcd --- /dev/null +++ b/snap/local/post_install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +sudo snap connect rosbot-xl:raw-usb +sudo snap connect rosbot-xl:hardware-observe +sudo snap connect rosbot-xl:joystick +sudo snap connect rosbot-xl:shm-plug rosbot-xl:shm-slot +sudo snap connect rosbot-xl:shutdown + +sudo rosbot-xl.restart \ No newline at end of file diff --git a/snap/local/restart_launcher.sh b/snap/local/restart_launcher.sh new file mode 100755 index 0000000..e294370 --- /dev/null +++ b/snap/local/restart_launcher.sh @@ -0,0 +1,9 @@ +#!/bin/bash -e + +source $SNAP/usr/bin/utils.sh + +log "Restart ${SNAP_NAME}.daemon service" +snapctl restart --enable ${SNAP_NAME}.daemon 2>&1 || true + +log "Restart ${SNAP_NAME}.joy service" +snapctl restart --enable ${SNAP_NAME}.joy 2>&1 || true \ No newline at end of file diff --git a/snapcraft_template.yaml.jinja2 b/snapcraft_template.yaml.jinja2 index 69b3bb3..fbea1d6 100644 --- a/snapcraft_template.yaml.jinja2 +++ b/snapcraft_template.yaml.jinja2 @@ -201,6 +201,9 @@ apps: stop: command: usr/bin/stop_launcher.sh + restart: + command: usr/bin/restart_launcher.sh + reset-stm32: command: usr/bin/reset_stm32_launcher.sh plugs: [raw-usb, network-bind] @@ -326,6 +329,7 @@ parts: stage: - "-usr/bin/start_launcher.sh" - "-usr/bin/stop_launcher.sh" + - "-usr/bin/restart_launcher.sh" local-files: plugin: dump @@ -335,5 +339,3 @@ parts: '*.py': usr/bin/ '*.yaml': usr/share/rosbot-xl/config/ '*.xml': usr/share/rosbot-xl/config/ - '*.json': usr/share/rosbot-xl/config/ - 'Caddyfile': usr/share/rosbot-xl/config/