-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptS1.sh
33 lines (33 loc) · 822 Bytes
/
ScriptS1.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
#!/bin/bash
# This Script will being copy folders from a local Server to a Cloud Drive
# if success, the folders will be removed from the source
# read Foldernames from Arguments
qpath=$1
dpath=$2
#LOG=$0.log
LOG=Script.log
if [ -d "log" ];then LOG="log/$LOG";fi
# check if fhemcl exists
file=fhemcl.sh
{
date
if [ ! -e $file ]
then
echo "$file is missing"
wget https://raw.githubusercontent.com/heinz-otto/fhemcl/master/$file
chmod +x $file
fi
# mount, sync and trigger
mount "$qpath"
mount "$dpath"
# if rsync ist ok then remove the synced files at source, set status in fhem
if rsync -rut --inplace ${qpath}/S* ${dpath}
then
rm -r "${qpath}/S*"
bash fhemcl.sh 8083 "set Sicherung CopyMagentaEnde"
else
bash fhemcl.sh 8083 "set Sicherung ERROR_S1"
fi
umount "$qpath"
umount "$dpath"
} >> $LOG 2>&1