So as an interim update, until I find the next thing I've done wrong,
here's my current ngrok_startup.sh


Code:
--------------------
    ##!/bin/sh
  
  # autostart and autoupdate ngrok for Media Server skill
  
  # enter your own details here
  TUNNELNAME="mediaservertunnel" # whatever you named the tunnel in 
/home/tc/.ngrok2/ngrok.yml
  UUID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # from account linking step
  
  logfile="/home/tc/ngrok.log"
  date > $logfile
  
  #
  # Start ngrok
  #
  
  # path to ngrok executable.  It's a big file, so keep it out of the pCP 
backup, e.g. put it on the third partition
  ngrok_exec="/mnt/PCP_DATA/ngrok/ngrok"
  
  # make sure ngrok is started by the authorised user, i.e. 'tc'.  When run as 
a user command at boot, the user is 'root'
  user=$(id | awk -F\( {'print $2'} | awk -F\) {'print $1'})
  if [ $user = "tc" ]; then  # ngrok command can be run without modification
        $ngrok_exec start $TUNNELNAME > /dev/null 2>&1 &
  elif [ $user = "root" ]; then # force ngrok command to be run by user 'tc'
        sudo -u tc $ngrok_exec start $TUNNELNAME > /dev/null 2>&1 &
  fi
  
  # wait for ngrok to initialise
  sleep $1      # send sleep time in seconds as command line parameter:
                        # 1 second seems to be enough once booted, 5 seconds to 
play safe during boot.
  
  #
  # Update ngrok
  #
  
  # get URL
  URL=https://$(wget -qO- http://localhost:4040/api/tunnels/${TUNNELNAME} | awk 
-F\"https:// {'print $2'} | awk -F\" {'print $1'})
  echo "URL = "$URL >> $logfile
  
  # construct JSON data
  DATA=[{\"name\":\"${TUNNELNAME}\",\"url\":\"${URL}\"}]
  echo "DATA = "$DATA >> $logfile
  
  # see what the update command looks like
  CMD=$(echo wget -qO- 
https://smartskills.tech/linking/updateNgrok.php?uuid=$UUID\&data=$DATA)
  echo "CMD = "$CMD >> $logfile
  
  # send the update command
  RES=$(wget -qO- 
https://smartskills.tech/linking/updateNgrok.php?uuid=$UUID\&data=$DATA)
  echo "RES = "$RES >> $logfile
--------------------


------------------------------------------------------------------------
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
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to