This script should download the 64-bit ngrok binary, convert it to a tcz
package and make it load on boot.

To use it, create a file 'ngrok_installer.sh' in your home directory
(/home/tc aka ~), paste the lines of the script into it, and make the
script executable (chmod +x ngrok_installer.sh).

Then simply run the script (./ngrok_installer.sh) and reboot.

Once the Pi reboots you can type 'which ngrok' to see if it has
installed.  It should show a single entry '/usr/local/bin/ngrok'.

Everything else in the home directory should have been tidied up by the
script.  The script itself will even have disappeared unless you did a
'backup' before rebooting.


Code:
--------------------
    #!/bin/sh
  
  # download ngrok and convert to installable package, so that the executable 
is placed into /usr/local/bin
  
  # setup some path shortcuts
  packagename=ngrok
  workingdir=~/$packagename
  rootpath=$workingdir/usr/local/bin
  tgz=~/$packagename.tgz
  tcz=~/$packagename.tcz
  
  # create folder structure
  mkdir -p $rootpath
  
  # fetch ngrok tgz - N.B. may need to check path to this file in case it 
changes in the future
  wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.tgz -O $tgz
  
  # extract the ngrok executable into the required part of the folder structure
  tar -x -f $tgz -C $rootpath
  
  # download and load squashfs-tools
  tce-load -w squashfs-tools.tcz
  tce-load -i squashfs-tools.tcz
  
  # create the ngrok package
  mksquashfs $workingdir/ $tcz
  
  # tidy up
  rm $tgz
  rm -Rf $workingdir/
  
  # move the ngrok package to the tce/optional folder
  TCEMNT="/mnt/$(readlink /etc/sysconfig/tcedir | cut -d '/' -f3)"
  mv $tcz $TCEMNT/tce/optional
  
  # add ngrok.tcz to tce/onboot.lst
  sed -i '/^ngrok.tcz/d' $TCEMNT/tce/onboot.lst #remove all previous ngrok 
entries, to make sure it's only listed once
  echo $packagename.tcz >> $TCEMNT/tce/onboot.lst
--------------------


I've tested this on a fresh pCP install, and also on a machine where
ngrok was already installed, and seems to work ok.  You don't need to
change any of the path variables at the start of the script, but if you
do, TAKE CARE, because in the 'tidy up' section of the script it will
recursively and silently delete everything in $workingdir/

This also worth keeping in mind if you DON'T change the path variables,
and you already have a folder called ~/ngrok.  That will be GONE after
this script runs :)


------------------------------------------------------------------------
chill's Profile: http://forums.slimdevices.com/member.php?userid=10839
View this thread: http://forums.slimdevices.com/showthread.php?t=111016

_______________________________________________
plugins mailing list
plugins@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to