-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautoSCP.sh
50 lines (45 loc) · 1.17 KB
/
autoSCP.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
#!/bin/sh
#meant to be used in a cron job to upload all files in a specific folder when the system connects to a wireless network
# redirect all output into a logfile
exec 1>> /home/pi/test.log 2>&1
#TODO:Add ability for user to specify folders & IP & port & username
PORT=22
IP='10.10.10.10'
localFolder='./'
remoteFolder='/'
USER='kali'
case "$1" in
wlan0)
case "$2" in
CONNECTED)
# do stuff on connect with wlan0
echo wlan0 connected
# copy all files to remote system with SCP
scp -rP $PORT $localFolder $USER@$IP:$remoteFolder
#turn wireless off after successful transfer?
;;
DISCONNECTED)
# do stuff on disconnect with wlan0
echo wlan0 disconnected
# sudo motion stop
# sudo service motion stop
;;
*)
>&2 echo empty or undefined event for wlan0: "$2"
exit 1
;;
esac
;;
wlan1)
case "$2" in
CONNECTED)
# do stuff on connect with wlan1
echo wlan1 connected
;;
DISCONNECTED)
# do stuff on disconnect with wlan1
echo wlan1 disconnected
;;
*)
>&2 echo empty or undefined event for wlan1: "$2"
exit 1