From 3cf91a23ce3abe17dafae4395240df6ad3f200bf Mon Sep 17 00:00:00 2001 From: Sergei Date: Thu, 16 Mar 2017 13:36:50 +0300 Subject: [PATCH] DMRIDs data from database of the BM network get the data from database of the BrandMeister network --- cron/updateDMRIDsBM.sh | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 cron/updateDMRIDsBM.sh diff --git a/cron/updateDMRIDsBM.sh b/cron/updateDMRIDsBM.sh new file mode 100644 index 0000000..a5a0384 --- /dev/null +++ b/cron/updateDMRIDsBM.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# +############################################################################### +# +# updateDMRIDs.sh +# +# Copyright (C) 2017 by Florian Wolters DF2ET +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +############################################################################### +# +# 18/1/17 - This script is a "derivative work" of GPL version 2 code Copyright +# by Tony Corbett G0WFV and is reproduced in this CC0 Universal licensed +# project with the original authors' express consent. +# +############################################################################### +# +#Edit by R2AJV +# + + +# Full path to DMR ID file +DMRIDFILE=/var/www/html/DMRIds.dat + +# How many DMR ID files do you want backed up (0 = do not keep backups) +DMRFILEBACKUP=1 + +# Create backup of old file +if [ ${DMRFILEBACKUP} -ne 0 ] +then + cp ${DMRIDFILE} ${DMRIDFILE}.$(date +%d%m%y) +fi + +# Prune backups +BACKUPCOUNT=$(ls ${DMRIDFILE}.* | wc -l) +BACKUPSTODELETE=$(expr ${BACKUPCOUNT} - ${DMRFILEBACKUP}) + +if [ ${BACKUPCOUNT} -gt ${DMRFILEBACKUP} ] +then + for f in $(ls -tr ${DMRIDFILE}.* | head -${BACKUPSTODELETE}) + do + rm $f + done +fi + +# Uncomment it if you want to get the data from a database of the DMR-MARC network +#curl 'http://www.dmr-marc.net/cgi-bin/trbo-database/datadump.cgi?table=users&format=csv&header=0' 2>/dev/null | sed -e 's/\t//g' | awk -F"," '/,/{gsub(/ /, "", $2); printf "%s\t%s\t%s\n", $1, $2,$ +#mv /tmp/DMRIds.dat.$(date +%d%m%y) ${DMRIDFILE} +#rm -f /tmp/DMRIds.dat.$(date +%d%m%y) + +# Uncomment it if you want to get the data from database of the BrandMeister network +wget http://registry.dstar.su/dmr/DMRIds.php -O DMRIds-temp1.dat +cat DMRIds-temp1.dat | sed -e 's/ /\t\t/g' > DMRIds-temp2.dat +cat DMRIds-temp2.dat | sed -e 's/\t/ /g' > DMRIds-temp3.dat +cat DMRIds-temp3.dat | sed -e 's/ / /g' > ${DMRIDFILE} +rm -f DMRIds-temp1.dat +rm -f DMRIds-temp2.dat +rm -f DMRIds-temp3.dat