Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webOS <4.0 doesn't run startup.sh, hence no SSH or Telnet #124

Open
kopiro opened this issue Oct 29, 2022 · 44 comments
Open

webOS <4.0 doesn't run startup.sh, hence no SSH or Telnet #124

kopiro opened this issue Oct 29, 2022 · 44 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@kopiro
Copy link
Contributor

kopiro commented Oct 29, 2022

I had a working version of Homebrew until I decided to upgrade to 05.50 system software, now webOS 4.4.2 (from 05.40).

The initial symptoms after upgrading are that SSH server is not working, Telnet is not working and also PicCap doesn't auto-start - but I still have elevated privileges.

After some debugging, it looks like that the autostart service registered by Homebrew is not being called; hence no startup.sh called.

I built a companion app that tries to call the autostart service via LunaBus; once installed, you can see that the first call to the autostart services fails because of a LunaBus error - but trying again it works.

image

Our assumption is that probably the service doesn't get registered in time or there are some overloads of the LunaBus at startup.

The error we get from LunaBus is this: https://github.com/webosose/luna-service2/blob/master/src/libluna-service2/transport.c#L239


Most likely, this new method of using previewMetadata in the appinfo.json doesn't work on webOS 4+, and the startup method was working in the previous firmware because of the presence of /etc/wam/plugins/conf.sh that called our script in the $EXTRA_CONF path:

EXTRA_CONF=/mnt/lg/cmn_data/wam/extra_conf.sh

if test -f $EXTRA_CONF; then
    source $EXTRA_CONF;
fi

That has now been removed from the 4.4 firmware.

kopiro referenced this issue Oct 29, 2022
* adding discovery endpoint

* updated startup

* changed autostart endpoint name

* installs startup.sh if not present
@kopiro
Copy link
Contributor Author

kopiro commented Oct 29, 2022

In my case, I've a running Homebrew + startup with the companion app I built myself and managed to manually run the startup.sh script and everything works correctly, but U guess we ned to find a new way to run services at startup.

@kopiro kopiro changed the title After upgrade to 05.50, Autostart doesn't work webOS 4.4 doesn't run startup.sh, hence no SSH or Telnet Oct 29, 2022
@mariotaku
Copy link
Member

Hi, I think the previewMetadata was working on webOS 4 and above. Did it stop working recently?

@kopiro
Copy link
Contributor Author

kopiro commented Oct 30, 2022

It doesn't work for me on webOs 4.4 - and most likely not working before?

@mariotaku
Copy link
Member

I was using webOS 4.9 and 5.3 and it worked. Could you install Netflix and see if there are suggestions when you focus the icon?

@kopiro
Copy link
Contributor Author

kopiro commented Oct 31, 2022

Nope, no suggestions.

Also, the Netflix ipk I inspected installed on the TV doesn't have any previewMetadata attribute.

I did a grep search and none of the package appinfo.json have it.

This is a TV from 2018, LG B8 running latest software with webos 4.4

image

@kopiro
Copy link
Contributor Author

kopiro commented Oct 31, 2022

It may be possible that with webOS4.4 we are stick in a limbo where none of the previous startup method works (extra_conf.sh or start_devmode.sh) as they patched this but the firmware is too old to support new features like the previewMetadata.

Also, what I've noticed after some usage is that Homebrew stops working and all INSTALL options are greyed-out.

After some digging I found out that's because the LunaBus stop being responsive, causing no luna-message to be dispatched (by looking at ls-monitor).

@mariotaku
Copy link
Member

That's really unfortunate. I think in such case only crashd method is available (if they are still working).

@kopiro
Copy link
Contributor Author

kopiro commented Oct 31, 2022

Isn't crashd method only to gain root?

@mariotaku
Copy link
Member

IIRC if the file is there it will always work.

@fryc88
Copy link

fryc88 commented Nov 1, 2022

I'm on same boat with kopiro, with SK8500PLA, MY2018 tv, with webos 4.4 as well.
Looks like i have same issues with doing root, with help of hellobox on discord i've managed to get kopiros ipk working on my tv because even that didn't work for me at the beggining, it was just showing some weird output, but hellobox suggested to do some magic, and after that i've got it. However now, after starting up tv, few minutes later homebrew ipk stop working, root status becomes pending and i can't launch/install new apps. After power cycle it does work for few minutes and then back on that again.

@CoreyD97
Copy link

CoreyD97 commented Nov 8, 2022

Similar boat to @kopiro and @fryc88 here. Managed to crashd my way to root, but autostart isn't working for me. I tried installing https://github.com/kopiro/webosbrew-autostart, but that encounters errors when running the autostart service as luna-send -n 1 'luna://org.webosbrew.hbchannel.service/autostart' '{}' gives the error {"returnValue":false,"errorText":"undefined is not a function"}.

Unlike @kopiro though, I do seem to get suggestions when hovering over home icons like Netflix as suggested earlier ( #124 (comment))

@HagiaHaya
Copy link

If you can't access the telnet via homebrew app, add this repo https://repo.webosapp.club -> install root.telnet and connect normally.

@kopiro
Copy link
Contributor Author

kopiro commented Dec 14, 2022

@mariotaku yes, the file is there and you can get root - but no startup scripts.

@soeren-a
Copy link

I'm facing the exact same issue. Successfully rooted via crashd, PicCap and Hyperion are working as expected but only if I start the apps manually after TV start. Autostart is just not working, even though the option is enabled for both services.
Telnet and SSH are also not working.
Using webOS 5.50.10, and HomeBrew 0.5.1 on a OLED55B8LLA.
Any chance that the issue will be fixed?

@throwaway96
Copy link
Member

It's not something that can really be "fixed", since webOS 4.[0-4] is missing the feature we're currently using for autostart functionality. There are other ways of hooking into the boot process, but only for newer versions of webOS. The next version of Homebrew Channel will try to work around this to a limited extent by running startup.sh when the app is launched.

If anyone wants to look for new boot hooks, it would be greatly appreciated.

@kopiro
Copy link
Contributor Author

kopiro commented Jan 20, 2023

Hello; I'll share the solution that works for me.

The main problem with not having autostart so far is only that PicCap and Hyperion/HDR don't start automatically, hence no LEDs.

What you only need is a device that is always on in your network - example: a raspberry Pi.

Generic solution

Install https://github.com/merdok/homebridge-webos-tv using npm -g install homebridge-webos-tv - I't s a plugin for homebridge that also has a nice CLI tool (/usr/bin/webostv) you can use.

I recently added support for sending raw luna-messages, we're going to use that.

Create a binary on your system with the following (example: /usr/local/bin/tv-autostart)

#!/bin/sh
TV_IP=192.168.0.40
TV_MAC=AA-BB-CC-DD-EE-FF
if ! ping $TV_IP; then 
  echo "TV is off"
  exit 1
fi
if curl -s "http://$TV_IP:8090/json-rpc?request=%7B%22command%22:%22serverinfo%22%7D"; then 
  echo "TV already rooted"
  exit 2
fi
echo "Calling autostart"
webostv luna-message $TV_IP $TV_MAC luna://org.webosbrew.hbchannel.service/autostart '{}'

And of course chmod +x /usr/local/bin/tv-autostart

Now, what you're going to do with this binary is really up to you.

Solution 0: Call this script in a CRON

Well, simply enough, setup a CRON that calls /usr/local/bin/tv-autostart every minute.

Solution 1: Use HomeBridge create a switch that you can use when you want to switch LEDs on/off

Since I don't always want the LEDs on (especially during daylight), I've setup a switch using in HomeKit so that I can just say "Hey Siri, switch on TV LEDs" or use the Homekit app in order to switch them on-off.

The script i'm using is a bit more complex than the one above, since it's also controlling HyperHDR status on/off - you can find it here and put it in /usr/local/bin/tv-hyperhdr

Then, install the plugin "homebridge-cmdswitch2" and add the following:

 {
    "platform": "cmdSwitch2",
    "name": "homebridge-cmdswitch2",
    "switches": [
        {
            "name": "TV LED",
            "on_cmd": "/usr/local/bin/tv-hyperhdr on",
            "off_cmd": "/usr/local/bin/tv-hyperhdr off",
            "state_cmd": "/usr/local/bin/tv-hyperhdr status",
            "polling": true,
            "interval": 30,
            "timeout": 15,
            "manufacturer": "HyperHDR"
        }
    ]
}

Now that you have this switch, you can leave it there to manually call it, or, for example, you can configure it to run when TV get switched on, if you also have the TV in HomeKit.

@soeren-a
Copy link

soeren-a commented Jan 22, 2023

The luna://org.webosbrew.hbchannel.service/autostart '{}' call kills my Homebrew Channel app. After executing the command, I cannot install any apps from the Channel and the root status under"Settings" is shown as "pending".
It is "fixed" again after a restart if the TV was completely shut down.
But I can confirm that executing the command fixes the autostart and SSH issue for my TV.

@kopiro
Copy link
Contributor Author

kopiro commented Jan 22, 2023

Hello - I can confirm you that this behaviour is "everything is locked" happened to me as well, but not because of the luna message you just sent.

It may be that the luna bus is a bit buggy with this webOS version, and messages don't get delivered - therefore, also the "install app" message is not delivered, or the "get root status" message is never delivered and is always shown as pending.

I'm not sure if this is a specific webOS issue or a problem with the homebrew service itself (with this version). - perhaps @Informatic knows more :)

@soeren-a
Copy link

soeren-a commented Jan 22, 2023

As a workaround for anyone that uses the LG integration within Home Assistant:
I created a script that executes the command suggested by @kopiro, which can be used in an automation (e.g. on TV start):

alias: Enable app autostart on rooted LG TV
sequence:
  - service: webostv.command
    data:
      entity_id: media_player.lg_tv
      command: system.notifications/createAlert
      payload:
        message: Executing HB Channel autostart...
        modal: false
        buttons:
          - label: OK
            focus: true
            buttonType: ok
            onClick: luna://org.webosbrew.hbchannel.service/autostart
            params: {}
        type: confirm
        isSysReq: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
    alias: Delay for Button click to close the alert toast
  - service: webostv.button
    data:
      entity_id: media_player.lg_tv
      button: ENTER
mode: single
icon: mdi:television-ambient-light

@panic175
Copy link

My workaround also uses Home Assistant but with a custom component: https://github.com/panic175/webosbrew-autostart-helper

@popy2k14
Copy link

@panic175 tried your custom integration, sadly it doesn't work. The first time the remote control Dialog was presented on the tv. I clicked yes and nothing happens. Also she i run the custom component service again.

When I'll open HBC autostart apps will be launched. So my setup works, except autostart .

Any hints i can debug this?

@panic175
Copy link

@popy2k14 Do you see any errors from the custom component in your Home Assistant Logs?

@popy2k14
Copy link

@panic175 sorry for hijacking your thread. I have webOS 6.3.1-411 (kisscurl-kinglake). In my case i had to uncheck all EULAs and retry (incl. reboot) until they are unchecked (two times in my case). Then enabled the TOP one and autostart is working again.

Just if anybody like me has this issue and needs this information.
I am in conact with the https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f owner, so maybe this info get's also added there.

thx again

@kitsuned
Copy link
Member

kitsuned commented Jul 17, 2023

hi there!

I think I found a way:

luna-send -f -n 1 -m org.webosbrew.hbchannel.service luna://com.webos.service.activitymanager/create '{
 "activity": {
  "name": "org.webosbrew.hbchannel.service.autostart",
  "description": "who cares",
  "type": {
   "foreground": true,
   "persist": true, 
   "continuous": true
  },
  "trigger": {
   "method": "luna://com.webos.bootManager/getBootStatus",
   "params": {
    "subscribe": true
   },
   "where": {
    "prop": [
     "signals",
     "core-boot-done"
    ],
    "op": "=",
    "val": true
   }
  },
  "callback": {
   "method": "luna://org.webosbrew.hbchannel.service/autostart",
   "params": {}
  }
 },
 "replace": true,
 "start": true
}'

I haven't tested this on 4.4.
I would be glad to receive any feedback!

@Doridian
Copy link

Doridian commented Jul 17, 2023

hi there!

I think I found a way:

luna-send -f -n 1 -a org.webosbrew.hbchannel.service luna://com.webos.service.activitymanager/create '{
......
}'

I haven't tested this on 4.4. I would be glad to receive any feedback!

On my webOS TV (version 4.4.2), this above worked perfectly, I could finally disable my HomeAssistant automation :D

@kitsuned
Copy link
Member

On my webOS TV (version 4.4.2), this above worked perfectly, I could finally disable my HomeAssistant automation :D

that was quick! thank you for the feedback.

follow #143 👀

@Chaoscontrol
Copy link

Chaoscontrol commented Oct 11, 2023

As a workaround for anyone that uses the LG integration within Home Assistant: I created a script that executes the command suggested by @kopiro, which can be used in an automation (e.g. on TV start):

alias: Enable app autostart on rooted LG TV
sequence:
  - service: webostv.command
    data:
      entity_id: media_player.lg_tv
      command: system.notifications/createAlert
      payload:
        message: Executing HB Channel autostart...
        modal: false
        buttons:
          - label: OK
            focus: true
            buttonType: ok
            onClick: luna://org.webosbrew.hbchannel.service/autostart
            params: {}
        type: confirm
        isSysReq: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
    alias: Delay for Button click to close the alert toast
  - service: webostv.button
    data:
      entity_id: media_player.lg_tv
      button: ENTER
mode: single
icon: mdi:television-ambient-light

Massive thanks for this. It helped me find the syntax needed to run the PicCap service directly from Home Assistant, as it doesn't autorun in my webOS 3.4.0. Might be that the createAlert method doesn't exist in that version?

However, your script doesn't work for me. The button step works, but the toast alert doesn't appear at any time. Any idea why?

[21:14:25.594][INFO] com.webos.service.secondscreen.gateway SSG_PERM Failed to find permissions for ssap://system.notifications/createAlert: Error: method /createAlert not found in interface system.notifications {}

@soeren-a
Copy link

Hmm, yes, it seems that the method is not found on your OS. But the error message also indicates, that you do not have the right permissions to execute? Not sure what's the issue here. All available methods are listed here, but without OS version support information: https://github.com/bendavid/aiopylgtv/blob/master/aiopylgtv/endpoints.py

@Chaoscontrol
Copy link

Chaoscontrol commented Oct 11, 2023

@soeren-a Yeah, I have been checking that and testing all I can think of. But can't make it work. createToast works fine, but createAlert doesn't.

Isn't there any other way to send the command to start SSH from HA?

@soeren-a
Copy link

@soeren-a Yeah, I have been checking that and testing all I can think of. But can't make it work. createToast works fine, but createAlert doesn't.

Isn't there any other way to send the command to start SSH from HA?

Not that I'm aware of. As far as I know, a user interaction like a button click is needed to execute the call. Showing a toast with a button and click it was the easiest way to achieve that.

@TulipVang
Copy link

TulipVang commented Nov 14, 2023

In my case, I've a running Homebrew + startup with the companion app I built myself and managed to manually run the startup.sh script and everything works correctly, but U guess we ned to find a new way to run services at startup.

I face same issue.
Can you help me to manually run the startup.sh script please.

@throwaway96
Copy link
Member

@TulipVang

Opening recent versions of Homebrew Channel will execute startup.sh.

@swiss6th
Copy link

swiss6th commented Jan 6, 2024

I haven't tested this on 4.4. I would be glad to receive any feedback!

@kitsuned, I have a C8 on 4.4.2, and this solved the issue for me as well. startup.sh is now running, and the autostart of PicCap and HyperHDR are both working now.

@Dahman97
Copy link

I haven't tested this on 4.4. I would be glad to receive any feedback!

I would like to thank you for your solution as it worked like a charm, after reboot everything that is supposed to auto start runs as it should, including hyperhdr and picap.... WebOS V-4.4-x. thanks a lot dude! TV model from 2019 updated to last webOS available for its gen :)

@throwaway96 throwaway96 changed the title webOS 4.4 doesn't run startup.sh, hence no SSH or Telnet webOS <4.5 doesn't run startup.sh, hence no SSH or Telnet Feb 2, 2024
@throwaway96 throwaway96 added enhancement New feature or request help wanted Extra attention is needed bug Something isn't working labels Feb 2, 2024
@dancingmadkefka
Copy link

@TulipVang

Opening recent versions of Homebrew Channel will execute startup.sh.

Hey thanks a lot, I was struggling all day to try to ssh into my B8 running 4.4.2 and this advice helped. I ran the homebrew updater and when I rebooted it popped up with a message saying that "autostart.sh has been updated" or something. Once that happened, I was able to ssh into it. Also handy that the updater allows you to open an emergency telnet session".

@rmp63526
Copy link

rmp63526 commented Mar 4, 2024

@kitsuned
It also worked for my Oled TV, WebOs 4.4.2-11 Goldilocks - Gorongosa/ Softwareversion 05.50.15
I have only noticed that when I switch off the TV, wait 1 minute and then unplug it and switch it on again, it goes into failsafe mode the first time it starts. When I restart it, it works again.

@kitsuned kitsuned added this to the 0.6.4 milestone Jun 11, 2024
@kopiro
Copy link
Contributor Author

kopiro commented Jun 16, 2024

It looks like that 804f947 fixed this - we can close this issue!

@kopiro kopiro closed this as completed Jun 16, 2024
@throwaway96
Copy link
Member

It's not fixed on webOS <4.0.

@throwaway96 throwaway96 reopened this Jun 16, 2024
@throwaway96 throwaway96 changed the title webOS <4.5 doesn't run startup.sh, hence no SSH or Telnet webOS <4.0 doesn't run startup.sh, hence no SSH or Telnet Jun 16, 2024
@kopiro
Copy link
Contributor Author

kopiro commented Jun 16, 2024

Sorry! :)

@angyp
Copy link

angyp commented Jul 1, 2024

I would like to get this going on
OLED65C7T-T
Firmware version 06.10.30
webOS version 3.9.0
Used DejaVuln
The only way I can get it to run is to open the homebrew app.

@angyp
Copy link

angyp commented Jul 3, 2024

hi there!

I think I found a way:

luna-send -f -n 1 -m org.webosbrew.hbchannel.service luna://com.webos.service.activitymanager/create '{
 "activity": {
  "name": "org.webosbrew.hbchannel.service.autostart",
  "description": "who cares",
  "type": {
   "foreground": true,
   "persist": true, 
   "continuous": true
  },
  "trigger": {
   "method": "luna://com.webos.bootManager/getBootStatus",
   "params": {
    "subscribe": true
   },
   "where": {
    "prop": [
     "signals",
     "core-boot-done"
    ],
    "op": "=",
    "val": true
   }
  },
  "callback": {
   "method": "luna://org.webosbrew.hbchannel.service/autostart",
   "params": {}
  }
 },
 "replace": true,
 "start": true
}'

I haven't tested this on 4.4. I would be glad to receive any feedback!

How do I use this? Auto start doesn't work on my TV

@lsahnicne
Copy link

lsahnicne commented Aug 24, 2024

hi there!

I think I found a way:

luna-send -f -n 1 -m org.webosbrew.hbchannel.service luna://com.webos.service.activitymanager/create '{
 "activity": {
  "name": "org.webosbrew.hbchannel.service.autostart",
  "description": "who cares",
  "type": {
   "foreground": true,
   "persist": true, 
   "continuous": true
  },
  "trigger": {
   "method": "luna://com.webos.bootManager/getBootStatus",
   "params": {
    "subscribe": true
   },
   "where": {
    "prop": [
     "signals",
     "core-boot-done"
    ],
    "op": "=",
    "val": true
   }
  },
  "callback": {
   "method": "luna://org.webosbrew.hbchannel.service/autostart",
   "params": {}
  }
 },
 "replace": true,
 "start": true
}'

I haven't tested this on 4.4. I would be glad to receive any feedback!

It seems to take a few moments after turning the TV on to initialize (judging by lginputhook key binds activation), but ultimately works. Thanks!
LG OLED C2
webOS 7.2.0-47 (mullet-marine) 03.21.45
Homebrew channel 0.6.3

How do I use this? Auto start doesn't work on my TV

SSH into TV and execute the code

@angyp
Copy link

angyp commented Aug 24, 2024

I tried that and it didn't work on my OLED C7 so I thought I was doing it wrong. Seems no way to get autostart working on my TV. Everything starts working correctly after I open the Homebrew channel.

@xenouch
Copy link

xenouch commented Oct 25, 2024

Not work for me.
I need to open hbchannel after TV start if i want lginputhook to work.
But ssh work without starting hbchannel

Device Model
LG 43UR73006LA

Device OS
WebOS 8.3.0-2306

Software version
03.31.16

Hbchannel version
0.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests