Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
configuration:usb-autorun [2015/04/03 13:19]
127.0.0.1 external edit
configuration:usb-autorun [2021/11/11 14:30] (current)
dodenhoeft [Useful USB autorun]
Line 1: Line 1:
-====== USB Autorun ======+====== ​ USB Autorun ​ ======
 This feature can be used to automatically launch a shell script or perform a software/​config update as soon as an USB storage stick has been plugged in. For authentication,​ a file called ''​autorun.key''​ must exist in the root directory of a FAT16/32 formatted stick. This feature can be used to automatically launch a shell script or perform a software/​config update as soon as an USB storage stick has been plugged in. For authentication,​ a file called ''​autorun.key''​ must exist in the root directory of a FAT16/32 formatted stick.
 It can be downloaded from that page and holds the SHA256 hash key of the admin password. The file can hold multiple hashes which will be processed line-by-line during authentication which can be used for setting up more systems with different admin It can be downloaded from that page and holds the SHA256 hash key of the admin password. The file can hold multiple hashes which will be processed line-by-line during authentication which can be used for setting up more systems with different admin
Line 7: Line 7:
 The hash keys can be generated by running the command ''​echo -n "<​admin-password>"​ | sha256sum''​ on a Linux system or an Internet hash key generator (search for "​sha-256 hash calculator"​). The hash keys can be generated by running the command ''​echo -n "<​admin-password>"​ | sha256sum''​ on a Linux system or an Internet hash key generator (search for "​sha-256 hash calculator"​).
 Once authentication has succeeded, the system scans for other files in the root directory which can perform the following actions: Once authentication has succeeded, the system scans for other files in the root directory which can perform the following actions:
-  - For running a script: ''​autorun.sh''​+ 
   - For a configuration update: ''​cfg-<​SERIALNO>​.zip''​ (e.g. ''​cfg-00112B000815.zip''​),​ or if not available ''​cfg.zip''​   - For a configuration update: ''​cfg-<​SERIALNO>​.zip''​ (e.g. ''​cfg-00112B000815.zip''​),​ or if not available ''​cfg.zip''​
   - For a software update: ''​sw-update.img''​   - For a software update: ''​sw-update.img''​
 +  - For running a script: ''​autorun.sh''​
  
-===== Example =====+===== Example ​autorun.key ​=====
 <code - autorun.key>​ <code - autorun.key>​
 # corresponds to password in factory defaults # corresponds to password in factory defaults
Line 19: Line 20:
 </​code>​ </​code>​
  
-<code bash autorun.sh>​ +===== Procedure =====
-# This autorun.sh script applies all *.cfg files that are provided on a USB stick +
-# Make sure autorun.status=1 or the router is set back to factory defaults +
-# and a file autorun.key with e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 is on the stick as well+
  
-# $MNTPATH is passed via environment variable but we want to be sure :)  +The autorun feature need to be enabledThis is case case either ​in the factory state or when you have it enabled ​on purpose ​in the Config
-mountpoint=""​ +
-max=60 +
-config="/​tmp/​myconfig.cfg" +
-serial=$(cli status system -s | grep SERIAL_NUMBER | cut -d= -f2 | tr -d '"'​) +
-for i in `seq 1 $max` +
-do +
-    /​usr/​bin/​logger -s -p "​local1.notice"​ -t "​autorun"​ "mount test $i of $max"​ +
-    mountpoint=$(mount | grep sda | cut -d" " -f3) +
-    if [ -n "​$mountpoint"​ ]; then +
-      /​usr/​bin/​logger -s -p "​local1.notice"​ -t "​autorun"​ "Stick in now mounted ​on $mountpoint"​ +
-      break +
-    fi +
-    sleep 1 +
-done +
-# concatenate common.cfg and individual.cfg on USB stick and save it in temp file. +
-cat $mountpoint/​*.cfg > $config +
-# apply the whole config in one step +
-cli update config "​file://​$config"​ +
-/​usr/​bin/​logger -s -p "​local1.notice"​ -t "​autorun"​ "​config applied, dumping user config and log on stick for your reference and exiting..."​ +
-# write applied config and log back on stick +
-cat /​etc/​config/​user-config.cfg > $mountpoint/​$serial.cfg +
-tail -n 100 /​var/​log/​messages > $mountpoint/​$serial.log +
-exit 0+
  
 +  - Please do not plug in the USB Stick before the System is bootet completly (Status LED need to light steady green). ​
 +  - After that pluging the USB Stick.
 +  - If the Autorun was triggert correctly all LEDs need to flash GREEN at the same time
  
-</​code>​ 
  
 +===== Function is not always enabled =====
 +
 +Please keep in mind that the usb autorun function is not always enabled:
 +
 +  - It's enabled in Factory State until you define your admin password
 +  - After that you need to enable it either via Webinterface or config parameter: ''​autorun.status=1''​
 +
 +===== Useful USB autorun =====
 +
 +  * [[configuration:​firmware-update|Firmware update]]
 +  * [[configuration:​software-update|Software update]]
 +  * [[configuration:​config-update|Config update]]