Make a script to run AFTER the init of the Piratebox

Posted by juanstdio 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
Make a script to run AFTER the init of the Piratebox
May 06, 2018 07:06PM
Hi,

I've just asking if its possible to put some an extra script for doing small things, for example, do SSH to a RPi via LAN and do some stuff there..

My current setup is

----------- LAN ------------------------
PBox | --------> | RaspberryPiA+ |
---------- -----------------------
where my PBox device is a MR-3020.

Where I can put that script with the certainty that, once the initialization is complete (Of the PBox), the script will be executed?

Thanks!
Re: Make a script to run AFTER the init of the Piratebox
May 07, 2018 07:10PM
I do not know if there is a SSH client pre installed on OpenWrt based PirateBox, but to answer your question:

We have a couple of "hook" where you can place your custom scripts
/opt/piratebox/bin/hooks: 
hook_piratebox_start_done.sh
hook_piratebox_start.sh
hook_piratebox_stop_done.sh
hook_piratebox_stop.sh
hook_post_init.sh
hook_pre_init.sh
hook_pre_openwrt_init.sh

The default empty script looks like this (hook_piratebox_start_done.sh)
#!/bin/sh

# ---- TEMPLATE ----

# Runs on every Startup after the normal init-steps are done
#  get config file 

if [ !  -f $1 ] ; then
  echo "Config-File $1 not found..."
  exit 255
fi

#Load config
. $1

# You can uncommend this line to see when hook is starting:
# echo "------------------ Running $0 ------------------"

You can put your scripts there. I recommend to uncomment the "Running" line to get an idea if that script was executed...

best regards Matthias
Re: Make a script to run AFTER the init of the Piratebox
May 09, 2018 06:15PM
Hi Matthias,

I didn't find on any of the scripts
hook_piratebox_start_done.sh
hook_piratebox_start.sh
hook_piratebox_stop_done.sh
hook_piratebox_stop.sh
hook_post_init.sh
hook_pre_init.sh
hook_pre_openwrt_init.sh
than give me a message in dmesg, or i'm just looking in the wrong logfile?

Thanks!

Juan
Re: Make a script to run AFTER the init of the Piratebox
May 09, 2018 06:44PM
Those scripts are at /opt/piratebox/bin/hooks

dmsg only contains Kernel messages. You will see the message while being connected via serial cable or when you manually restart PirateBox with /etc/init.d/piratebox restart

Best regards Matthias