moved ftp-config to ftpconfig.xml

master
agp8x 2015-08-24 15:13:37 +02:00
parent 2fbe788774
commit ed136d3ea9
4 changed files with 30 additions and 20 deletions

View File

@ -96,4 +96,3 @@ class SensorSetup(object):
obj = self.genericSensorSetup(name, sensor)
connected.append(obj)
return connected

38
ftp.sh
View File

@ -1,25 +1,33 @@
#!/bin/bash
DIR="/home/USER/weather"
SFTPPASS="PASS OR REPLACE WITH KEY"
SFTPUSER="USER@DOMAIN.TLD"
URL="DOMAIN.TLD/PATH/FILE.EXT"
CONFIG="ftpconfig.xml"
FTP_COMMAND="mput temp*
mput humi*
mput ambi*
mput baro*
quit
"
cd $DIR
if [ ! -f $CONFIG ]; then
echo "configuration file not found, exiting! (see ftpconfig.sample.xml)"
exit 1;
fi
read DIR SFTPUSER URL SFTPPASS < <(xmlstarlet sel -t -v "//dir" -o $'\t' -v "//sftpuser" -o $'\t' -v "//url" -o $'\t' -v "//sftppass" $CONFIG)
cd $DIR || exit 1
cp records/humi* ftp/
cp records/ambi* ftp/
cp records/temp* ftp/
cp records/baro* ftp/
cd ftp
# Using a plain password here is evil, but in my context sadly needed
# better use key-authentication, and switch the commented lines
#sftp -oBatchMode=no -b - $SFTPUSER <<EOF
sshpass -p $SFTPPASS sftp -oBatchMode=no -b - $SFTPUSER <<EOF
mput temp*
mput humi*
mput ambi*
mput baro*
quit
EOF
if [ -z $SFTPPASS ]; then
#sftp-key-auth
sftp -oBatchMode=no -b - $SFTPUSER "$FTP_COMMAND"
else
#sftp-pass-auth
sshpass -p $SFTPPASS sftp -oBatchMode=no -b - $SFTPUSER "$FTP_COMMAND"
fi
rm humi* ambi* temp* baro*
cd ..
wget $URL -O logs/wget_recent -q

6
ftpconfig.sample.xml Normal file
View File

@ -0,0 +1,6 @@
<ftpconfig>
<dir>/home/USER/weather</dir>
<sftpuser>USER@DOMAIN.TLD</sftpuser>
<sftppass></sftppass><!--leave empty for key-auth-->
<url>PROTO://DOMAIN.TLD/PATH/FILE.EXT</url>
</ftpconfig>

View File

@ -1,7 +1,4 @@
#!/bin/bash
#mv records/humi* arch/
#mv records/ambi* arch/
#mv records/temp* arch/
cd records
#echo $1
for f in {temp,humi,ambi,baro}*
@ -11,7 +8,7 @@ do
if [ "$day" == "$1" ]; then
echo "$f today"
else
# echo "$f old, -->move"
echo "$f old, -->move"
mv $f ../arch
fi
done