-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncFiles.sh
executable file
·74 lines (64 loc) · 2.56 KB
/
syncFiles.sh
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
#!/bin/bash
# Use this script to:
# 1)sync protocol and main client files into the esp32 client directory.
# 2)sync protocol and main client files from esp32 into main client and protocol directories
# Options:
# -d: direction(which direction to tranfer files in): clientToEsp or espToClient
# -p: protocol (transfer protocol files or not): 1(for yes, to transfer protocol files), 0 (for no, wont transfer protocol files)
# -c: client (transfer cleint files or not): 1(for yes, to transfer client files), 0 (for no, wont transfer protocol files)
espClientDirectory="./nodeClient/testEsp32/main/"
espArrayListDirectory="./nodeClient/testEsp32/components/ArrayList/"
espPckDataDirectory="./nodeClient/testEsp32/components/pckData/"
while getopts d:p:c: flag
do
case "${flag}" in
d) direction=${OPTARG};;
p) protocol=${OPTARG};;
c) client=${OPTARG};;
esac
done
echo "Direction: $direction";
echo "Protocol: $protocol";
echo "Client: $client";
#Check if variables are empty, if not ask to confirm and start file transfer
if [ -z "$direction" ] || [ -z "$protocol" ] || [ -z "$client" ]
then
#Empty
echo "Incorrect input (need to pass every parameter!)";
exit 1
else
correctInputDirection=0;
correctInputProtocol=0;
correctInputClient=0;
if [ $direction == "clientToEsp" ] || [ $direction == "espToClient" ]
then
correctInputDirection=1;
fi
if [ $protocol == "0" ] || [ $protocol == "1" ]
then
correctInputProtocol=1;
fi
if [ $client == "0" ] || [ $client == "1" ]
then
correctInputClient=1;
fi
echo $correctInputDirection $correctInputProtocol $correctInputClient
if [ $correctInputDirection -eq 1 ] && [ $correctInputProtocol -eq 1 ] && [ $correctInputClient -eq 1 ]
then
#Execute the file transfer
echo "This will transfer the file in direction: $direction. Transferring the files(where 1 means files will be transferred, 0 means wont be transferred): client files: $client; protocol files: $protocol;"
echo "Type y to confirm that you want to start file transfer:"
read userConfirm
if [ $userConfirm == "y" ]
then
echo "Starting file transfer"
if [ $direction == "espToClient" ]
then
else
echo "Not confirmed, aborting script"
exit 1
fi
else
echo "Wrong input!"
fi
fi