Automaticity run a command after reboot?



  • I’m trying to get this command to work when issued automaticity in pfsense:

    screen -dmS tunnel stunnel vpn.ssl

    It runs fine if I type it into the shell but I need it to load automaticity upon reboot. More importantly I need it to load after all packages have been loaded I think.

    I tried putting this:

    <shellcmd>screen -dmS tunnel stunnel vpn.ssl</shellcmd>

    In the backup config xml file but I think its running too soon before stunnel is loaded though i’m not really sure.

    I’ve looked at cron but I cant seem to understand how that works well enough to get it to do anything useful. I could get */1 * * * * root /usr/local/bin/minicron to work but when I try putting the command in it doesn’t.

    I tried to read up about how cron works but I found it very confusing.

    Ideally I'd like to get it work without cron as it seems to be a big headache to deal with.

    Does anyone know how I can get this to work?


  • Banned

    https://doc.pfsense.org/index.php/Executing_commands_at_boot_time those are the options.

    Edit: Also read up on limits/differences/issues with scripts run by the system versus scripts run in a interactive environment. For example always use the full path to binaries and other files.



  • Yeah that's what I found to do <shellcmd>screen -dmS tunnel stunnel vpn.ssl</shellcmd> but it doesn’t seem to work. From what I could quickly read of all the text scrolling up the screen it executes like this

    xxxxxx
    xxxxx
    xx
    x
    xxxxxxxxx
    xxxx
    xxxxxxxxxxx
    xxxx
    xxxxxxxxx
    <shellcmd>screen -dmS tunnel stunnel vpn.ssl</shellcmd>
    xxxxxxxxxxxxxxxx
    xxxxx
    xxxxxxxxxxx
    xxxxxxxxxxxxxxxx
    xxxxxxxxxxxxx
    xxxxxxx
    xxxxxxxxxxxxxxxx
    Starting package stunnel…done.
    Bootup complete.

    Which makes me assume its not working because stunnel doesn’t exist when the command is issued?


  • Banned

    @smegheed:

    Which makes me assume its not working because stunnel doesn’t exist when the command is issued?

    If the package is installed the binary exists and can be used. So your likely running into a pathing issue, read my edit above.

    If all else fails write a shellscript that loops until the stunnel is succesfully started. Be prepared to sink a few hours into this if it's new to you.



  • While trying to understand cron I did get the impression it needed to know where the binaries are. What I couldn’t figure out is how to present them in the command. Would it be something like this:

    root /usr/local/bin/screen usr/local/bin/stunnel screen -dmS tunnel stunnel vpn.ssl ?

    Do I need to include everything it could possibly use like the openvpn binary etc?

    @Grimson:

    Be prepared to sink a few hours into this if it's new to you.

    1 week 2 days and about 10 hours already sunk  :)


  • Banned

    @smegheed:

    root /usr/local/bin/screen usr/local/bin/stunnel screen -dmS tunnel stunnel vpn.ssl ?

    :o

    Take your command and add the full path to binaries and (config) files. So:

    screen -dmS tunnel stunnel vpn.ssl
    

    becomes

    /usr/local/bin/screen -dmS tunnel /usr/local/bin/stunnel /root/vpn.ssl
    

    Note: Paths in the example above are just guessed, so make sure they are correct.

    Also I'd advise to use the shellcmd and cron packages to configure this instead of messing with the config.xml by hand.


Log in to reply