Announcement

Collapse
No announcement yet.

[Announce] Easy ngrok-setup for MediaServer & LMS-lite Alexa skills

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • [Announce] Easy ngrok-setup for MediaServer & LMS-lite Alexa skills

    Click image for larger version

Name:	1.png
Views:	1
Size:	39.8 KB
ID:	1578851

    There's a new completely-automated setup procedure for deploying ngrok for use with the MediaServer and LMS-lite skills.

    It automatically downloads/configures ngrok and also sets it up to autostart at boot on the target system. Your account-linking UUID is automagically deployed to update the skill(s) when tunnel details change (i.e. upon ngrok restart or system reboot). There's no more manually creating systemd services or tweaking Python/Perl updaters because the installer handles everything

    To make it as easy to use as possible, the user visits a web form (see above) and enters details which are then pre-populated into a downloaded installer script.
    Your choice of platform/OS in the form not only determines what version of the ngrok binary to download for you, it also results in a script that matches the native capabilities of the target platform/OS so there are no dependencies to install.

    The process is currently available for:

    * pCP: with a sh script as installer that builds a tcz package and adds an entry to /opt/bootlocal.sh for autostart.
    * Debian-Linuxes: with a bash script as installer for distros like Raspberry Pi OS, Max2Play, Ubuntu — it uses systemd to daemonize ngrok.
    * MacOS: with a bash script as an installer run from a terminal — it uses launchd to daemonize ngrok.
    * Windows10: with a PowerShell script as installer that runs ngrok as a hidden background process at boot.

    The old Python/Perl script for updating tunnel details to the skills has been superseded by a native sh/bash/pwsh script that the installer creates on your system.

    The process is fully documented in the new instructions at https://smartskills.tech/lmslitesetup (one installer handles both skills).

    When filled out, the form might look as follows:

    Click image for larger version

Name:	2.png
Views:	1
Size:	37.3 KB
ID:	1578852

    For noobs evaluating the skills, the recommended platform is probably now Windows 10. There's no need to use ssh to transfer the installer to a headless machine - it's just right-click and run. Remember, ngrok on a PC will happily proxy for a NAS or pi elsewhere in your LAN.

    Many thanks to @chill for the pioneering work on the pCP platform script !
    Last edited by philchillbill; 2021-09-04, 12:45. Reason: Added MacOS support

  • #2
    This setup is a great improvement over the original one. Just one thing, could you please provide a link to the previous instructions to jog the memories of us who already have ngrok installed so that we can clean up the previous files and changes to files before doing the new setup, if and when required. Thanks...

    Comment


    • #3
      Originally posted by raglencross
      This setup is a great improvement over the original one. Just one thing, could you please provide a link to the previous instructions to jog the memories of us who already have ngrok installed so that we can clean up the previous files and changes to files before doing the new setup, if and when required. Thanks...
      Good idea. I've linked them in a footnote on the first tab in the latest instructions.

      That said, if you're already set up then there's no need to change a working installation just for the sake of it. The new procedure does not do anything 'better' than the old way, it's just scripted instead of manual. But for a new install, do it the new way for sure.
      Last edited by philchillbill; 2021-02-23, 18:00.

      Comment


      • #4
        Thanks!

        Just installed and it works like a charm. Much easier set up! Thanks very much.
        FYI - I had to do it twice. The 1st time, I didn't start the install from pi/home and when I restarted Max2Play it didn't work anymore.
        Cheers!
        Transporter, Touch, SB3, SB2, Duet, Booms, Radios, piCorePlayer --- iPeng & Material --- LMS Version: 8.4.0 - 1676612311 on Pi4 4GB - Max2Play --- Qobuz

        Comment


        • #5
          The requirement to manually run the updater script once AFTER linking the skills has now been relaxed, as your uuid is already in the setup script when you download it.

          This means that setup is now a single-pass process and no restart of e.g. pCP is required (thanks @chill !). On Windows 10, the desktop shortcut is no longer created or necessary.

          All this magic will only work in modern browsers with localStorage enabled and functioning. If you're still on Netscape Navigator, a popup will remind you it's 2021

          The docs have already been updated to reflect the simplification.
          Last edited by philchillbill; 2021-03-22, 19:17.

          Comment


          • #6
            App-to-App automatic account linking implemented

            Amazon is trying to make skill setup and account-linking easier, and a while back they introduced so-called app-to-app account linking. The idea is that you don't have to visit the Alexa app or web-portal to perform account-linking, but instead can do it from the app or website of the skill author. It not only links the skill but will even install it if you haven’t already done so.

            I now have it live for both skills and links are available in the online setup-help pages that will automatically perform account-linking for you. There's no more need to paste your ngrok URL and chosen credentials into the landing page at the Alexa portal. Instead you will log in to your regular Amazon account (if you still have a valid cookie from the last time you logged in then you won't even need to do this) and authorize Amazon to link the skill(s) in question by just clicking on a pop-up.

            It's a complicated flow under the hood with 3 different bouts of oauth2 to-and-fro-ing but it's very secure and worked well in my testing and the user does not see any of it. MediaServer has now been upgraded to use full authorization code grant instead of implicit tokens (LMS-lite already had that).

            If you encounter any problems, please report them here as I will not see anything in the skill logs to indicate failed attempts.

            This is as easy as skill setup will ever get until Amazon releases the promised capability to use an Echo as a native proxy device inside your LAN (announced last Sept as 'coming soon')


            Click image for larger version

Name:	apptoapp.png
Views:	1
Size:	18.1 KB
ID:	1571881
            Last edited by philchillbill; 2021-04-17, 19:19.

            Comment


            • #7
              Hi, I've installed this today on pcp v7.0.1 running on wifi, the same pcp is running lms.
              The first time the script runs everything works as expected. Alexa discovers and can control devices, I can use the tunnel link and see my lms from the internet.
              Unfortunately it doesn't survive a reboot. The tunnel link says
              Tunnel {MYTUNNEL}.eu.ngrok.io not found

              This is my /opt/bootlocal.sh
              Code:
              #!/bin/sh
              # put other system startup commands here
              
              echo "Starting SQLITE-control.sh from /opt/bootlocal.sh..." | tee -a /var/log/pcp_b>
              /home/tc/SQLITE-control.sh find M6 &
              GREEN="$(echo -e '\033[1;32m')"
              
              echo
              echo "${GREEN}Running bootlocal.sh..."
              #pCPstart------
              /usr/local/etc/init.d/pcp_startup.sh 2>&1 | tee -a /var/log/pcp_boot.log
              #pCPstop------
              
              ### BH1750 start ------
              # Enabling kernel module i2c-dev
              /sbin/modprobe i2c-dev
              # starting shell script to control display brightness
              /home/tc/lux/display-control.py
              ### BH1750 stop ------
              I expected something about ngrok in here, but I don't know what.

              Comment


              • #8
                Originally posted by Bogg
                Hi, I've installed this today on pcp v7.0.1 running on wifi, the same pcp is running lms.
                The first time the script runs everything works as expected. Alexa discovers and can control devices, I can use the tunnel link and see my lms from the internet.
                Unfortunately it doesn't survive a reboot. The tunnel link says
                Tunnel {MYTUNNEL}.eu.ngrok.io not found

                This is my /opt/bootlocal.sh
                Code:
                #!/bin/sh
                # put other system startup commands here
                
                echo "Starting SQLITE-control.sh from /opt/bootlocal.sh..." | tee -a /var/log/pcp_b>
                /home/tc/SQLITE-control.sh find M6 &
                GREEN="$(echo -e '\033[1;32m')"
                
                echo
                echo "${GREEN}Running bootlocal.sh..."
                #pCPstart------
                /usr/local/etc/init.d/pcp_startup.sh 2>&1 | tee -a /var/log/pcp_boot.log
                #pCPstop------
                
                ### BH1750 start ------
                # Enabling kernel module i2c-dev
                /sbin/modprobe i2c-dev
                # starting shell script to control display brightness
                /home/tc/lux/display-control.py
                ### BH1750 stop ------
                I expected something about ngrok in here, but I don't know what.
                setup.sh should have added a single line to bootlocal.sh - maybe it did but the final pcp bu step failed? Run setup.sh again and watch for any error messages. When it completes, do a pcp bu yourself. Any error?
                If that fails, the correct entry is

                /bin/sh /home/tc/ngrok_startup.sh

                But you should try to understand why the setup process failed. Did you change permissions or ownership in the past?

                Comment


                • #9
                  Hi, Thanks for your swift reply.

                  I think it is a permissions issue. I don't recall changing the permissions for /opt/bootlocal.sh, but I do recall having permissions issues for the display control script, and maybe the sqlite control script too. I started with a standard pcp installation, so I'm unsure why I seem to get permission issues.

                  Unfortunately I'm too stupid to work them out myself, so if you could help me with the actual code to copy and paste it would be most helpful.

                  Here's the likely problem from the script rerun -

                  Code:
                  --> Adding autostart entry to /opt/bootlocal.sh
                  
                  sed: can't create temp file '/opt/bootlocal.shfdHyWV': Permission denied
                  sed: can't create temp file '/opt/bootlocal.shnvI1x3': Permission denied
                  sed: can't create temp file '/opt/bootlocal.shlgWw98': Permission denied
                  --> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [SqDisplayLMSTunnel]
                  
                  --> Backing up changes using pcp bu.

                  Comment


                  • #10
                    Originally posted by Bogg;
                    I think it is a permissions issue. I don't recall changing the permissions for /opt/bootlocal.sh, but I do recall having permissions issues for the display control script, and maybe the sqlite control script too. I started with a standard pcp installation, so I'm unsure why I seem to get permission issues.

                    Unfortunately I'm too stupid to work them out myself, so if you could help me with the actual code to copy and paste it would be most helpful.

                    Here's the likely problem from the script rerun -

                    Code:
                    --> Adding autostart entry to /opt/bootlocal.sh
                    
                    sed: can't create temp file '/opt/bootlocal.shfdHyWV': Permission denied
                    sed: can't create temp file '/opt/bootlocal.shnvI1x3': Permission denied
                    sed: can't create temp file '/opt/bootlocal.shlgWw98': Permission denied
                    --> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [SqDisplayLMSTunnel]
                    
                    --> Backing up changes using pcp bu.
                    If you do 'cd /opt' and then 'sudo chown tc:staff bootlocal.sh' (both commands without the quotes) then bootlocal.sh will be editable by tc. The script should then run fine.
                    Last edited by philchillbill; 2021-04-17, 19:06.

                    Comment


                    • #11
                      Originally posted by philchillbill
                      If you do 'cd /opt' and then 'sudo chown tc:staff bootlocal.sh' (both commands without the quotes) then bootlocal.sh will be editable by tc. The script should then run fine.
                      Hi, I've done the above
                      Code:
                      tc@pCP:~$ cd /opt
                      tc@pCP:/opt$ sudo chown tc:staff bootlocal.sh
                      tc@pCP:/opt$
                      I then do pcp br, then run the script again. But still get the exact same problems as before -

                      Code:
                      sed: can't create temp file '/opt/bootlocal.shzizocx': Permission denied
                      sed: can't create temp file '/opt/bootlocal.shKZBUqA': Permission denied
                      sed: can't create temp file '/opt/bootlocal.shyZHzKI': Permission denied
                      --> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [SqDisplayLMSTunnel]
                      
                      --> Backing up changes using pcp bu.

                      Comment


                      • #12
                        Originally posted by Bogg
                        Hi, I've done the above
                        Code:
                        tc@pCP:~$ cd /opt
                        tc@pCP:/opt$ sudo chown tc:staff bootlocal.sh
                        tc@pCP:/opt$
                        I then do pcp br, then run the script again. But still get the exact same problems as before -

                        Code:
                        sed: can't create temp file '/opt/bootlocal.shzizocx': Permission denied
                        sed: can't create temp file '/opt/bootlocal.shKZBUqA': Permission denied
                        sed: can't create temp file '/opt/bootlocal.shyZHzKI': Permission denied
                        --> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [SqDisplayLMSTunnel]
                        
                        --> Backing up changes using pcp bu.
                        Sounds like some other startup script you are using has ‘sudoitis’ and is undoing the chown. Try not doing pcp br after issuing the command and run the setup script immediately while things are still owned by tc:staff.

                        Many people use sudo for just about everything but any files handled when a script is run with sudo wil subsequently be owned by root. Always ask yourself if sudo is really needed.

                        Comment


                        • #13
                          No change when trying without a reboot -
                          Code:
                          tc@pCP:~$ cd /opt
                          tc@pCP:/opt$ sudo chown tc:staff bootlocal.sh
                          tc@pCP:/opt$ cd ~
                          tc@pCP:~$ sh setup.sh
                          
                          
                          sed: can't create temp file '/opt/bootlocal.sh6tG6uu': Permission denied
                          sed: can't create temp file '/opt/bootlocal.sh4ag2uy': Permission denied
                          sed: can't create temp file '/opt/bootlocal.shQgibYE': Permission denied
                          --> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [SqDisplayLMSTunnel]

                          Comment


                          • #14
                            Originally posted by Bogg
                            No change when trying without a reboot -
                            Code:
                            tc@pCP:~$ cd /opt
                            tc@pCP:/opt$ sudo chown tc:staff bootlocal.sh
                            tc@pCP:/opt$ cd ~
                            tc@pCP:~$ sh setup.sh
                            
                            
                            sed: can't create temp file '/opt/bootlocal.sh6tG6uu': Permission denied
                            sed: can't create temp file '/opt/bootlocal.sh4ag2uy': Permission denied
                            sed: can't create temp file '/opt/bootlocal.shQgibYE': Permission denied
                            --> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [SqDisplayLMSTunnel]
                            The issue is then with the /opt directory itself. But as I’m not a pCP guru I don’t know what the permissions and ownership on that directory ‘normally’ are.

                            Maybe ask over at the pCP forum. Worst case, start with a clean pCP install and do any other install stuff you recently did without the sudo.

                            Comment


                            • #15
                              The /opt directory is supposed to be

                              root:staff owned
                              775 + suid bit on the group.
                              piCorePlayer a small player for the Raspberry Pi in RAM.
                              Homepage: https://www.picoreplayer.org

                              Please donate if you like the piCorePlayer

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎