-
Notifications
You must be signed in to change notification settings - Fork 1
/
configureFTP.sh
executable file
·50 lines (39 loc) · 1001 Bytes
/
configureFTP.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
#!/bin/bash
#set -x
BACKTITLE="raspberryEasySurvillance"
TITLE="Configuration FTP"
MENU="Choose one of the following options: "
server="nas1.local"
password="geheim23"
user="camUser2"
# open fd
exec 3>&1
# Store data to $VALUES variable
VALUES=$(dialog --ok-label "Submit" \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--form "$MENU" \
15 50 0 \
"Username:" 1 1 "$user" 1 10 30 0 \
"Server:" 2 1 "$server" 2 10 30 0 \
"Password:" 3 1 "$password" 3 10 30 0 \
2>&1 1>&3)
# close fd
exec 3>&-
# display values just entered
echo "$VALUES"
i=0
while read -r line; do
((i++))
declare var$i="${line}"
done <<< "${VALUES}"
if [ -n "$VALUES" ]; then
echo "Write ~/.netrc"
echo machine "$var2" login "$var1" password "$var3" > ~/.netrc
. config
find="FTP_SERVER_RECORDINGS=$FTP_SERVER_RECORDINGS"
replace="FTP_SERVER_RECORDINGS=$var2"
sed -i'.backup' "s+${find}+${replace}+g" config
else
echo "empty"
fi