Change dir of openwrt and refactor sh script
This commit is contained in:
7
openwrt/files/usbserial-dw.config
Normal file
7
openwrt/files/usbserial-dw.config
Normal file
@@ -0,0 +1,7 @@
|
||||
config capture
|
||||
option port /dev/ttyUSB0
|
||||
option speed 115200
|
||||
option directory /tmp
|
||||
option file camera.jpg
|
||||
option url https://meranie.bh.ttx.sk/upload/image
|
||||
option time 300
|
||||
29
openwrt/files/usbserial-dw.sh
Normal file
29
openwrt/files/usbserial-dw.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2018 wongsyrone
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
PROG=/usr/bin/usbserial-dw
|
||||
CURL=/usr/bin/curl
|
||||
|
||||
parse_capture() {
|
||||
local section="$1"
|
||||
local _port
|
||||
local _speed
|
||||
local _dir
|
||||
local _file
|
||||
|
||||
config_get _port "$section" "port"
|
||||
config_get _speed "$section" "speed"
|
||||
config_get _dir "$section" "dir"
|
||||
config_get _file "$section" "file"
|
||||
config_get _url "$section" "url"
|
||||
|
||||
$PROG --port $_port --speed $_speed --dir $_dir --file $_file
|
||||
cd $_dir
|
||||
$CURL -v -X POST -F "submit=OK" -F "file=@camera.jpg" $_url
|
||||
rm $_file
|
||||
}
|
||||
|
||||
config_load usbserial
|
||||
config_foreach parse_capture capture
|
||||
Reference in New Issue
Block a user