diff options
author | Dmitrii Morozov <snoopdesigns@gmail.com> | 2024-03-27 21:05:38 +0100 |
---|---|---|
committer | Dmitrii Morozov <snoopdesigns@gmail.com> | 2024-03-27 21:05:38 +0100 |
commit | 5ebd786a63ac36d68e9a342c9ff474993903db94 (patch) | |
tree | 3d5d1b9549a4f1d6f6f12b60969e0cfac2dad9ef /systemd/magic4linux-start | |
parent | 993f290594c9c97bb516d834d1619a22c1346abd (diff) |
Added systemd service descriptor
Diffstat (limited to 'systemd/magic4linux-start')
-rwxr-xr-x | systemd/magic4linux-start | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/systemd/magic4linux-start b/systemd/magic4linux-start new file mode 100755 index 0000000..971e478 --- /dev/null +++ b/systemd/magic4linux-start @@ -0,0 +1,45 @@ +#! /usr/bin/bash + +ARES_DEVICE_INFO_CMD="$WEBOS_CLI_TV/ares-device-info" +ARES_LAUNCH_CMD="$WEBOS_CLI_TV/ares-launch" +GOPATH=$(/usr/bin/go env GOPATH) + +function ares_available() { + if ! command -v $ARES_DEVICE_INFO_CMD &> /dev/null + then + echo "$ARES_DEVICE_INFO_CMD could not be found" + exit 1 + fi +} + +function wait_ares_connection() { + until $ARES_DEVICE_INFO_CMD > /dev/null + do + echo "Cannot establish connection to ares" + sleep 1 + done + echo "Connection to ares established" +} + +function check_magic4pc_running() { + $ARES_LAUNCH_CMD -r | grep -q 'me.wouterdek.magic4pc' + return $? +} + +function start_magic4pc() { + $ARES_LAUNCH_CMD me.wouterdek.magic4pc + return $? +} + +if ares_available; then + wait_ares_connection + if check_magic4pc_running; then + echo "WebOS Magic4pc application is already running" + else + echo "WebOS Magic4pc application not running, starting.." + start_magic4pc + fi +fi + +echo "Starting magic4linux.." +$GOPATH/bin/magic4linux |