Customized Scripting

Follow

Comments

42 comments

  • Avatar
    Bill Bradstreet

    @Michael.

    At this point, I am just focusing on the chpasswd command. I'm not even running in a script... just running the sudo echo UID:PWD | sudo chpasswd.

    Once I have this step working I will move on to the next. I'm going to ask Stack Exchange or something similar to see if they have any suggestions. That is probably more appropriate. I'll report back when I have something to share.

    0
    Comment actions Permalink
  • Avatar
    Firewalla Support

    In case any special characters in your password, you might want to do

    echo '<username>:<password>' | sudo chpasswd

    For example,

    echo 'pi:mySecretpa$s' | sudo chpasswd

    Or use variables instead

    username=pi

    # set password directly(non-secure)
    password='mySecretpa$s'
    # or, set password more securely
    password=$(cat) #input password, ENTER and Ctrl-D to finish

    echo $username:$password | sudo chpasswd

    Please have a try and see if it works

     

    0
    Comment actions Permalink
  • 0
    Comment actions Permalink
  • Avatar
    Bill Bradstreet

    Thanks for the advice. In the end, I will be looking at that. But, first, I need to get a script that works. Then I can focus on making it fancy/secure. 

    0
    Comment actions Permalink
  • Avatar
    Pavel

    Hi,

    How can I find out why script not working after restarting my firewall blue plus?

    pi@Firewalla:~/.firewalla/config/post_main.d (Firewalla Blue Plus) $ pwd
    /home/pi/.firewalla/config/post_main.d
    pi@Firewalla:~/.firewalla/config/post_main.d (Firewalla Blue Plus) $ ls -lh
    total 4.0K
    -rwxr-xr-x 1 root root 161 Oct 23 19:05 hello.sh
    pi@Firewalla:~/.firewalla/config/post_main.d (Firewalla Blue Plus) $ cat hello.sh
    #!/bin/bash
    sudo ip route add 3.5.0.0/16 dev vpn_8BB6_8BB62
    sudo ip route add 52.88.0.0/13 dev vpn_8BB6_8BB62
    sudo ip route add 52.216.0.0/14 dev vpn_8BB6_8BB62
    pi@Firewalla:~/.firewalla/config/post_main.d (Firewalla Blue Plus) $

    Thank you.

     
    0
    Comment actions Permalink
  • Avatar
    Sven Moderow

    I don't understand the example "Customized Cron jobs". How do I add a custom cronjob and where. Can someone give a step-b-step example? Adding with "cronjob -e" the job is lost after restart of Firewalla.

    cat: /home/pi/.firewalla/config/user_crontab: No such file or directory

    0
    Comment actions Permalink
  • Avatar
    Support Team

    Create a new file /home/pi/.firewalla/config/user_crontab, and add cronjobs to it. File format is the same as system cronjob.

    It will be loaded as system cronjob when booting up.

    Example:

    $ cat /home/pi/.firewalla/config/user_crontab
    1 1 1 * * echo hi &> /dev/null

    You can reboot and test it. After the system is fully up, you can verify by crontab -l

    1
    Comment actions Permalink
  • Avatar
    Michael Bierman

    @Sven you are correct you can't use cronjob -e. 

    1. create this file using your favorite editor. 

    /home/pi/.firewalla/config/user_crontab

    Add your cron job(s) in there exactly as you would with cron.

    2. Save the file. 

    3. Reboot firewalla. 

    4. Verify using

    crontab -l 
    1
    Comment actions Permalink
  • Avatar
    Christian Kuhtz

    Can you please provide a method to trigger the merge of the user_crontab/* files at runtime without reboot?

    0
    Comment actions Permalink
  • Avatar
    Samuel

    For any one having issues checking custom crontabs, here is some additional steps the above guide does not provide:

    chown pi:pi /home/pi/.firewalla/config/user_crontab

    Next restart firewalla; then check to ensure cronjob is present with this command:

    crontab -l -u pi

    You should now see the entries of user_crontab added to the bottom of the crontab for user "pi".

     

     

     

    0
    Comment actions Permalink
  • Avatar
    swrobel

    What about /etc/cron.{hourly|daily|monthly|weekly}/? Can I drop scripts in there to run in the specified intervals?

    0
    Comment actions Permalink
  • Avatar
    Michael Bierman

    swrobel you should use user cron to schedule scripts. You can set any schedule you like. 

     

    0
    Comment actions Permalink

Please sign in to leave a comment.