init III
This commit is contained in:
46
Garmin Exporter/download.sh
Normal file
46
Garmin Exporter/download.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
/usr/bin/python3 /mnt/daten1tb/1_USER/andre/garmin/bpt/git/garmin-connect-export/gcexport.py \
|
||||
--username andregeissler@posteo.de \
|
||||
--password f7m8g36Ph4gDCy4 \
|
||||
-c 10 \
|
||||
-f json \
|
||||
-d /mnt/daten1tb/1_USER/andre/garmin/bpt/input
|
||||
|
||||
/usr/bin/python3 /mnt/daten1tb/1_USER/andre/garmin/bpt/git/garmin-connect-export/gcexport.py \
|
||||
--username andregeissler@posteo.de \
|
||||
--password f7m8g36Ph4gDCy4 \
|
||||
-c 10 \
|
||||
-f original \
|
||||
-d /mnt/daten1tb/1_USER/andre/garmin/bpt/input
|
||||
|
||||
/usr/bin/python3 /mnt/daten1tb/1_USER/andre/garmin/bpt/git/garmin-connect-export/gcexport.py \
|
||||
--username andregeissler@posteo.de \
|
||||
--password f7m8g36Ph4gDCy4 \
|
||||
-c 10 \
|
||||
-f tcx \
|
||||
-d /mnt/daten1tb/1_USER/andre/garmin/bpt/input
|
||||
|
||||
/usr/bin/python3 /mnt/daten1tb/1_USER/andre/garmin/bpt/git/garmin-connect-export/gcexport.py \
|
||||
--username andregeissler@posteo.de \
|
||||
--password f7m8g36Ph4gDCy4 \
|
||||
-c 10 \
|
||||
-f gpx \
|
||||
-d /mnt/daten1tb/1_USER/andre/garmin/bpt/input
|
||||
|
||||
cd /mnt/daten1tb/1_USER/andre/garmin/bpt/input
|
||||
|
||||
#for I in `ls activity_*_summary.json`
|
||||
#do
|
||||
# echo $I
|
||||
# zip $I.zip $I
|
||||
#done
|
||||
|
||||
for I in `ls -1 act* | grep -v zip | awk -F'_' '{print $2}' | awk -F'.' '{print $1}' | uniq`
|
||||
do
|
||||
echo $I
|
||||
DAT=`ls -1 *$I* | head -n1 | awk -F'+' '{print $1}'`
|
||||
zip -u $DAT-$I.zip *$I*
|
||||
done
|
||||
|
||||
#shopt -s extglob
|
||||
#$(rm -v !(*.zip))
|
||||
#find /mnt/daten1tb/1_USER/andre/garmin/bpt/input -type f -not -name '*.zip' -delete
|
||||
110
Garmin Exporter/get_all.sh
Normal file
110
Garmin Exporter/get_all.sh
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/bin/bash
|
||||
|
||||
# python modul garmin export
|
||||
# programmpfad /home/andre/.local/lib/python3.6/site-packages/garminexport
|
||||
# dateien nicht auffindbar: /mnt/daten1tb/1_USER/andre/.tmp/.not_found
|
||||
# dateien erledigt: /mnt/daten1tb/1_USER/andre/.tmp/.backed
|
||||
|
||||
# /home/andre/.local/lib/python3.8/site-packages/garminexport/backup.py
|
||||
#
|
||||
# backed_up = os.listdir(backup_dir) + _not_found_activities(backup_dir) + _backed_activities(backup_dir)
|
||||
# ...
|
||||
# def _backed_activities(backup_dir):
|
||||
# # consider all entries in <backup_dir>/.backed as backed up
|
||||
# backed_activities = []
|
||||
# _backed = os.path.join(backup_dir, backed_file)
|
||||
# if os.path.isfile(_backed):
|
||||
# with open(_backed, mode="r") as f:
|
||||
# backed_activities = [line.strip() for line in f.readlines()]
|
||||
# log.debug("%d already backed activities in %s", len(backed_activities), _backed)
|
||||
# return backed_activities
|
||||
|
||||
|
||||
|
||||
GRMNUSR=andregeissler@posteo.de
|
||||
GRMNPWD=f7m8g36Ph4gDCy4
|
||||
BCKDIR=/mnt/daten1tb/1_USER/andre/.tmp
|
||||
ARCHDIR=/mnt/daten1tb/1_USER/andre/garmin/activities
|
||||
DAYS=5
|
||||
STD=`date '+%H'`
|
||||
ALL=$1
|
||||
|
||||
holedateityp () {
|
||||
typ=$1
|
||||
echo
|
||||
echo hole alle $typ
|
||||
python3 /home/andre/.local/bin/garmin-backup -f $typ -E --backup-dir=$BCKDIR/ --password $GRMNPWD $GRMNUSR
|
||||
}
|
||||
|
||||
echo
|
||||
echo "\$BCKDIR : $BCKDIR"
|
||||
echo "\$ARCHDIR : $ARCHDIR"
|
||||
echo "\$DAYS : $DAYS"
|
||||
|
||||
echo
|
||||
echo Löschen der Dateien der letzten $DAYS Tage
|
||||
# hierdurch wird erzwungen diese Dateien neu zu holen, da Änderungen hier noch möglich sind
|
||||
for d in `seq 0 $DAYS`
|
||||
do
|
||||
files=$(date +"%Y-%m-%d" -d "-$d day")
|
||||
find $BCKDIR -name "$files*" -exec rm {} \;
|
||||
done
|
||||
|
||||
echo
|
||||
echo Dateien älter als $DAYS in .backed aufnehmen und löschen
|
||||
cd $BCKDIR
|
||||
d=$(expr $DAYS + 1)
|
||||
files=$(date +"%Y-%m-%d" -d "-$d day")
|
||||
ls -1R $files* >> .backed
|
||||
rm $files*
|
||||
|
||||
echo
|
||||
echo Download der Daten ins \$BCKDIR Verzeichnis
|
||||
|
||||
if [ "$ALL" == "fit" ] || [ "$ALL" == "all" ]; then holedateityp fit ; fi
|
||||
if [ "$ALL" == "gpx" ] || [ "$ALL" == "all" ]; then holedateityp gpx ; fi
|
||||
if [ "$ALL" == "tcx" ] || [ "$ALL" == "all" ]; then holedateityp tcx ; fi
|
||||
if [ "$ALL" == "summary" ] || [ "$ALL" == "all" ]; then holedateityp json_summary ; fi
|
||||
if [ "$ALL" == "details" ] || [ "$ALL" == "all" ]; then holedateityp json_details ; fi
|
||||
|
||||
echo
|
||||
echo Dateien die jünger als \$DAYS Tage sind nach \$ARCHDIR kopieren
|
||||
for I in `find $BCKDIR/* -mtime -$DAYS`
|
||||
do
|
||||
cp -a $I $ARCHDIR/
|
||||
done
|
||||
|
||||
echo
|
||||
echo Wechsel nach \$ARCHDIR
|
||||
cd $ARCHDIR/
|
||||
|
||||
echo
|
||||
echo Dateien der selben Aktivität zusammenfassen
|
||||
|
||||
for I in `ls -1 | grep -v zip | awk -F'_' '{print $2}' | awk -F'.' '{print $1}' | uniq`
|
||||
do
|
||||
DAT=`ls -1 *$I* | head -n1 | awk -F'+' '{print $1}'`
|
||||
zip -u $DAT-$I.zip *$I*
|
||||
done
|
||||
rm *.tcx
|
||||
rm *.gpx
|
||||
rm *.fit
|
||||
rm *.json
|
||||
|
||||
echo
|
||||
echo Wenn Dateien mit Name JJJJ-MM - von 1930 bis 2070 - vorhanden sind, diese zippen
|
||||
|
||||
for I in `seq 1900 2070`
|
||||
do
|
||||
ls $I-??-* > /dev/null 2>&1
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo
|
||||
echo Zip $I'-??-*' nach $I.zip
|
||||
zip -u $I.zip $I-??-*
|
||||
echo
|
||||
echo Dateien älter als \$DAYS Tage aus \$ARCHDIR löschen
|
||||
find $ARCHDIR/ -name "$I-??-*" -daystart -mtime +$DAYS | xargs rm -f
|
||||
fi
|
||||
done
|
||||
|
||||
21
Garmin Exporter/runall.sh
Normal file
21
Garmin Exporter/runall.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
d=$(date +"%Y-%m-%d_%H")
|
||||
a=$(echo "log/1_$d")
|
||||
x=$(echo "log/f_$d")
|
||||
z=$(echo "log/2_$d")
|
||||
|
||||
bash /mnt/daten1tb/1_USER/andre/garmin/bpt/get_all.sh summary
|
||||
|
||||
cd /mnt/daten1tb/1_USER/andre/garmin/bpt
|
||||
echo "select * from overview" | mysql -u andregeissler_bikeparts -p'K01v1kk0!' -D andregeissler_bikeparts -h vesta.agserver.de -t > $a.log
|
||||
|
||||
find ../activities/ -name "????-*.zip" > $x.log
|
||||
find ../activities/ -name "????-*.zip" -exec cp {} ./input \;
|
||||
|
||||
perl ./bptar.pl
|
||||
|
||||
echo "select * from overview" | mysql -u andregeissler_bikeparts -p'K01v1kk0!' -D andregeissler_bikeparts -h vesta.agserver.de -t > $z.log
|
||||
|
||||
cd /mnt/daten1tb/1_USER/andre/garmin/bpt/input
|
||||
rm -f *.zip
|
||||
|
||||
Reference in New Issue
Block a user