-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhd-webupload.cmd
84 lines (64 loc) · 2.02 KB
/
hd-webupload.cmd
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
78
79
80
81
82
83
84
@echo off
SETLOCAL EnableDelayedExpansion
echo.
echo [1mHomeDing upload utility uploading web files to device.[0m
echo.
REM == Default Values ==
set _webfolder=.\dist
set _curlopts=--retry 2
set _folder=dist
set _help=
set _clean=
if "%*"=="" ( set _help=1 )
:restart
REM == Option Values ==
if [%~1]==[--help] ( set _help=1 && shift /1 && goto :restart )
if [%~1]==[-h] ( set _help=1 && shift /1 && goto :restart )
if [%~1]==[/h] ( set _help=1 && shift /1 && goto :restart )
if [%~1]==[/?] ( set _help=1 && shift /1 && goto :restart )
if [%~1]==[-c] ( set _clean=1 && shift /1 && goto :restart )
if [%~1]==[--clean] ( set _clean=1 && shift /1 && goto :restart )
set devicename=%~1
if DEFINED _help (
echo This utility enables uploading files from a folder into the filesystem of a device
echo using http uploads.
echo.
echo To create the distribution files use [1mnpm run build[0m and [1mnpm run pack[0m
echo.
echo Usage: hd-webupload.bat [options] ^<devicename^> [folder]
echo. -h, --help Get a brief help on using this tool
echo. -c, --clean Clean existing files on device before upload
echo.
echo When no example parameter is given the files from the [1mstandard[0m data folder are used.
echo.
)
if NOT DEFINED devicename (
echo.
echo [31mmissing device name as parameter[30m
goto :end
)
if NOT [%~2]==[] (
set _webfolder=.\%~2
)
rem == execute ==
if DEFINED _clean (
echo [1mCleaning...[0m
curl http://%devicename%/api/cleanweb
)
echo [1mUploading...[0m
echo. Device name = %devicename%
echo. from folder = %_webfolder%
echo.
FOR %%F IN (%_webfolder%\*.*) DO (
echo [37m%%F[30m
curl --form "fileupload=@%%F;filename=/%%~nxF" http://%devicename%/ %_curlopts%
)
FOR %%F IN ("%_webfolder%\i\*.svg") DO (
echo [37m%%F[30m
curl --form "fileupload=@%%F;filename=/i/%%~nxF" http://%devicename%/ %_curlopts%
)
echo.
echo http://%devicename%/ updated.
:end
set _folder=
echo.