With this example script an automated update of several MultiSensors can be performed.

  1. Create a file with the name update.sh and insert the code block
  2. As variable enter the path to the update file, the API key, and the IP addresses of the multi-sensors (separated by a space)

    #! /bin/bash
    
    pathToUpdatefile="path/to/kms_update.bin"
    apiKey="API-KEY"
    hosts=(192.168.100.223 192.168.100.233 192.168.100.244)
    hasUnknownOption=0
    ignoreRemainingParams=0
    
    while [ "$1" != "" ]; do
        case $1 in
            -f | --file )           shift
                                    pathToUpdatefile=$1 # Set path to update file
                                    ;;
            -k | --key )            shift
                                    apiKey=$1 # Set API authentication key
                                    ;;
            -H | --hosts )          shift
                                    hosts=( $@ ) # Set list of hosts to update
                                    ignoreRemainingParams=1 # Mark remaining parameters as not unkown
                                    ;;
            * )                     if [ $ignoreRemainingParams -eq 0 ]; then # If the remaining parameters are not hosts, give a warning
                                        echo "Unknown option: $1"
                                        hasUnknownOption=1;
                                    fi
                                    shift
                                    ;;
        esac
        shift
    done
    
    if [ $hasUnknownOption -eq 1 ]; then # If unkown parameters are found, stop execution
        exit 1
    fi
    
    
    
    echo "Uploading file $pathToUpdatefile to hosts:"
    
    for host in "${hosts[@]}" # Traverse the hosts
    do
        :
        echo -e "\n https://"$host"/api/remote-update"
        # Send a POST form-request with Basic Authentication via curl to each specified host
        curl --insecure -H "Authorization: Basic $(echo -n $apiKey':' | base64)" -F "file=@$pathToUpdatefile" "https://"$host"/api/remote-update"
    done