Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languagede

Mit diesem Beispielskript lässt sich ein automatisiertes Update mehrerer MultiSensoren durchführen.

  1. Erstellen sie eine Datei mit dem Namen update.sh und fügen dort den Codeblock ein
  2. Als Variable geben Sie den Pfad zur Update-Datei, den API-Key, sowie die IP-Adressen der MultiSensoren an (getrennt durch ein Leerzeichen)
Code Block
languageapplescript
linenumberstrue
#! /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




Sv translation
languageen

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)

    Code Block
    languageapplescript
    linenumberstrue
    #! /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