-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScriptA1.ps1
49 lines (47 loc) · 1.06 KB
/
ScriptA1.ps1
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
function ScriptA1 {
#!/bin/bash
# this script sync the cloud content to the archive server
# Read the foldernames from Arguments
# needs fhemcl.sh in the actual path (not the script path)
# logging is done in the actual path too
param(
$dest,
$qpath,
$dpath
)
$exe='ssh'
$script=@"
qpath=$qpath
dpath=$dpath
"@
$script+=@'
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"
# S* will copy all files and folders with S, folders will be created in $dpath if not exist
# set Status in FHEM
# use more rsync lines for different folders
if rsync -a --delete ${qpath}/S* ${dpath}
then
echo "set Sicherung SyncEnde"|./fhemcl.sh 8083
else
echo "set Sicherung ERROR_A1"|./fhemcl.sh 8083
fi
umount "$qpath"
umount "$dpath"
} >> $LOG 2>&1
'@
& $exe $dest $script.replace("`r`n","`n")
}