This shows you the differences between two versions of the page.
| — | sdk:remote-configdownload [2017/11/16 14:19] (current) – created juraschek | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Download a Remote Config File and Delete it afterwards ====== | ||
| + | |||
| + | A very simple Method to roll out configfiles on a bunch of Router: | ||
| + | |||
| + | The Router will try to download a config file from a ftp server with a unique part in the URL. | ||
| + | After the File was downloaded successfully it will be deleted on the remote ftp server. | ||
| + | |||
| + | This way you won't have a endless download. | ||
| + | |||
| + | This Script can be used with various triggers: periodicly every XX min, after wan-up, sdk-startup and so on | ||
| + | |||
| + | |||
| + | <code c remote-config-download.are> | ||
| + | /* DESC: The Router will try to download a config file from a ftp server with a unique part in the URL. | ||
| + | * DESC: After the File was downloaded successfully it will be deleted on the remote ftp server | ||
| + | * Copyright (C) 2017 JJ NetModule AG, Switzerland | ||
| + | */ | ||
| + | |||
| + | // ftp/ | ||
| + | url=" | ||
| + | user=" | ||
| + | pw=" | ||
| + | |||
| + | // Get Unique Part of the URL via Serial Number or Hostname | ||
| + | // | ||
| + | unique=nb_config_get(" | ||
| + | // File name on the server | ||
| + | image=" | ||
| + | |||
| + | |||
| + | // local file for storage | ||
| + | local=" | ||
| + | |||
| + | |||
| + | //We will have a remote update Link like: ftp:// | ||
| + | link=sprintf(" | ||
| + | |||
| + | |||
| + | DELAY=120; | ||
| + | TRIES=5; | ||
| + | for (i=0; | ||
| + | if (0 == nb_transfer_get(user, | ||
| + | nb_syslog(" | ||
| + | nb_transfer_delete(user, | ||
| + | nb_update_config(sprintf(" | ||
| + | exit(0); | ||
| + | } else { | ||
| + | nb_syslog(" | ||
| + | } | ||
| + | |||
| + | sleep (DELAY); | ||
| + | |||
| + | } | ||
| + | nb_syslog(" | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | |||