tftpd-hpa + 12.04 LTS

728

Here is my working one. There is a workaround for the fore mentioned IPv4 issue.

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp" 
TFTP_DIRECTORY="/tftp"
TFTP_ADDRESS="[::]:69"
TFTP_OPTIONS="-4 --secure --create"

The --create allows users to upload without having to do a touch.

Share:
728

Related videos on Youtube

gilbertasm
Author by

gilbertasm

Updated on September 18, 2022

Comments

  • gilbertasm
    gilbertasm over 1 year

    I want to use flock to make sure only once instance of script is running at any given time.

    Script skeleton looks like this:

    ME=`basename "$0"`;
    LOCK="/tmp/${ME}.LCK";
    exec 8>$LOCK;
    
    
    
    if flock -n -x 8; then
        do things
    
         if [ condition ]; then
           /path/asterisk_restart.sh
         fi
    else
        echo "$(date) script already running >> $log_file"
    
    fi
    

    Now the script /path/asterisk_restart.sh do many things, but in the end asterisk is stopped and last command is service asterisk start

    The problem is this: as file handles and locks are shared across fork()/exec(), 8 filehandle remained locked in asterisk process, so the script will not run again once /path/asterisk_restart.sh is executed (and asterisk are not stopped/restarted by other means outside this script)

    So my approach is to start sub-shell and close 8 file handle just before executing /path/asterisk_restart.sh.

    It looks like this:

        ME=`basename "$0"`;
        LOCK="/tmp/${ME}.LCK";
        exec 8>$LOCK;
    
    
    
        if flock -n -x 8; then
             do things
    
             if [ condition ]; then
                (
                   exec 8>&-
                   /path/asterisk_restart.sh
                )
             fi
        else
            echo "$(date) script already running >> $log_file"
    
        fi
    

    Is this a sound approach?

    • afifim
      afifim almost 11 years
      Is anyone able to help out with this question!? I am sure I am just missing a tiny bit of configuration but I just can't figure it out unfortunately.
    • irfan_np
      irfan_np over 10 years
      I have few queries 1. How did you try downloading or uploading to the TFTP server ? Any error message you get during testing ? 2. Try some other already exisiting folder like "/home/<username>/Desktop" as the TFTP_DIRECTORY. Dont change the ownership of the folder. Also just verify steps with this blogpost.
  • gilbertasm
    gilbertasm almost 9 years
    Thank you for your comment, but this does not answer my question. First of all, I am using flock, not simple check if file exists. Flock is atomic too, It also works if server is restarted unexpectedly, and temporary files/directories remain.