/
ddwrt-update.TEMPLATE
executable file
·77 lines (53 loc) · 2.28 KB
/
ddwrt-update.TEMPLATE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# This is a template for DD-WRT device configuration files:
# - Create a copy of this file for each of your devices.
# - Name it 'ddwrt-update-<your_device_name>'.
# - Mark it as executable if necessary.
set -eu
# Configure the location of the 'ddwrt-autoupdater' software:
# - By default use the directory where this device configuration file is located:
base_dir="$(dirname "$(readlink -f "$0")")"
# - But if you move your device configuration file(s) (eg: to '$HOME/bin/'), configure the installation directory here:
#base_dir="$HOME/opt/ddwrt-autoupdate"
# Configure parameters for your device:
device_type="netgear-ac1450"
device_name="$device_type"
device_address="http://192.168.1.1"
device_https_config="--insecure"
device_credentials="ADMIN_USER:ADMIN_PASSWORD"
# The location of the local repository of downloaded firmware images and configuration backups for this device:
local_repo="$base_dir/repos/$device_name"
# The location and naming of firmware images for this device:
set_firmware_files() {
# Available variables:
# - year, month, day
# - date_US, date_int, date_num
# - release_tag, release_num, tag
# Variable 'tag' can be customized here.
local firmware_file="$device_type-webflash.bin"
remote_firmware_file="$device_type/$firmware_file"
local_firmware_file="$tag-$firmware_file"
}
# Device backup callback:
on_device_backup() {
# Use 'cat /proc/mtd' to list mtd partitions.
#backup_partition mtd0 boot
#backup_partition mtd1 nvram
#backup_partition mtd4 board_data
:
}
backup_partition() {
local device="$1"
local name="$2"
local device_ssh="< ssh parameters needed to connect to your device >"
echo "Backing up $device partition ($name)..."
ssh -q $device_ssh "cat /dev/$device" >$device-$name.img
}
# Defective DD-WRT releases are usually pulled from the download servers soon after their release.
# It is recommended to skip the latest release(s) to avoid installing untested firmware images.
# Configure the number of releases prior to the latest release to use (0 means use latest release):
prior_to_latest=1
# Configure whether to wait for and ping the device after firmware updates (either "yes" or "no"):
ping_device="yes"
# Now run the main updater code:
source "$base_dir/ddwrt-autoupdate" "$@"