diff options
| author | Dmitrii Morozov <snoopdesigns@gmail.com> | 2024-10-12 17:21:23 +0200 | 
|---|---|---|
| committer | Dmitrii Morozov <snoopdesigns@gmail.com> | 2024-10-12 17:21:23 +0200 | 
| commit | 07a8a4baa32aba7cf664715095e82742d1476cd9 (patch) | |
| tree | a9ced8a3430991764d9735d0b5df037b3814c65e /systemd/magic4linux-start | |
| parent | c6a5770721d1ebba0ef1ca79f8eff1a2d0cd4a0a (diff) | |
Diffstat (limited to 'systemd/magic4linux-start')
| -rwxr-xr-x | systemd/magic4linux-start | 62 | 
1 files changed, 46 insertions, 16 deletions
| diff --git a/systemd/magic4linux-start b/systemd/magic4linux-start index 971e478..058080d 100755 --- a/systemd/magic4linux-start +++ b/systemd/magic4linux-start @@ -2,8 +2,13 @@  ARES_DEVICE_INFO_CMD="$WEBOS_CLI_TV/ares-device-info"  ARES_LAUNCH_CMD="$WEBOS_CLI_TV/ares-launch" +ARES_INSTALL_CMD="$WEBOS_CLI_TV/ares-install"  GOPATH=$(/usr/bin/go env GOPATH) +echo "Using variables:" +echo "WEBOS_CLI_TV=$WEBOS_CLI_TV" +echo "MAGIC4PC_DIST=$MAGIC4PC_DIST" +  function ares_available() {    if ! command -v $ARES_DEVICE_INFO_CMD &> /dev/null    then @@ -21,25 +26,50 @@ function wait_ares_connection() {    echo "Connection to ares established"  } -function check_magic4pc_running() { -  $ARES_LAUNCH_CMD -r | grep -q 'me.wouterdek.magic4pc' -  return $? -} +function check_magic4pc_installed() {  +  $ARES_INSTALL_CMD -l | grep -q 'me.wouterdek.magic4pc'  +  return $?  +}  -function start_magic4pc() { -  $ARES_LAUNCH_CMD me.wouterdek.magic4pc -  return $? -} +function install_magic4pc() {  +  $ARES_INSTALL_CMD $MAGIC4PC_DIST  +}  -if ares_available; then +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 + +  if check_magic4pc_installed; then  +    echo "Magic4pc already installed"  +  else  +    echo "Magic4pc not installed, installing.."  +    if install_magic4pc; then  +      echo "Magic4pc installed"  +    else  +      exit 1  +    fi  +  fi  +   +  if check_magic4pc_running; then  +    echo "WebOS Magic4pc application is already running"  +  else  +    echo "WebOS Magic4pc application not running, starting.."  +    if start_magic4pc; then  +      echo "Magic4pc started"  +    else  +      exit 1  +    fi     fi -fi +fi  -echo "Starting magic4linux.." +echo "Starting magic4linux.."   $GOPATH/bin/magic4linux | 
