-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an example using 'firmwarecfg' to reboot
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#! /bin/bash | ||
##################################################################################### | ||
# # | ||
# create the HTTP request # | ||
# # | ||
##################################################################################### | ||
post_request() | ||
{ | ||
printf "POST /cgi-bin/firmwarecfg HTTP/1.1\r\n" | ||
printf "User-Agent: handcrafted_request/1 (shell)\r\n" | ||
printf "Accept: */*\r\n" | ||
printf "Host: %s\r\n" "$2" | ||
printf "Connection: Close\r\n" | ||
printf "%s" "$1" | ||
} | ||
##################################################################################### | ||
# # | ||
# parameters and defaults # | ||
# # | ||
##################################################################################### | ||
# IP address of FRITZ!Box | ||
host="${2:-192.168.178.1}" | ||
##################################################################################### | ||
# # | ||
# SID has to be the first parameter # | ||
# # | ||
##################################################################################### | ||
[ -z "$1" ] && echo "Missing SID ..." && exit 1 | ||
. $YF_SCRIPT_DIR/multipart_form | ||
td=$(multipart_form new) | ||
multipart_form addfield $td sid $1 | ||
multipart_form addfield $td reboot | ||
request="$(multipart_form postdata $td)" | ||
printf "=== request ===\n" 1>&2 | ||
printf "%s\n" "$(post_request "$request" "$host")" 1>&2 | ||
printf "=== response ===\n" 1>&2 | ||
post_request "$request" "$host" | nc -q 1 -C -w 2 $host 80 | ||
printf "\n=== end of communication ===\n" 1>&2 | ||
multipart_form cleanup "$td" |