Skip to content

Commit 4f0b0ac

Browse files
committed
Fix, though not pretty, for TravelMapping#540
1 parent f9ba8e0 commit 4f0b0ac

2 files changed

Lines changed: 66 additions & 9 deletions

File tree

ArchiveGraphs/archive_graphs.sh

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,69 @@ set -e
99
install=1
1010
pull=1
1111
execdir=`pwd`
12-
tmbase=$HOME/travelmapping
13-
tmwebbase=/fast/www/tm
1412
datestr=`date '+%Y-%m-%d'`
15-
graphdir=$HOME/temp/graphdata
16-
graphdir=$tmwebbase/graphdata
1713
# check for required command line args:
1814
#
1915
if [ "$#" -ne 2 ]; then
2016
echo "Usage: $0 archivename description"
2117
exit 1
2218
fi
23-
export HIGHWAY_DATA=$tmbase/HighwayData
19+
20+
# check default locations of TM repositories
21+
tmbasedir=$HOME
22+
if [[ -d $HOME/TravelMapping ]]; then
23+
tmbasedir=$HOME/TravelMapping
24+
elif [[ -d $HOME/travelmapping ]]; then
25+
tmbasedir=$HOME/travelmapping
26+
elif [[ -d $HOME/tm ]]; then
27+
tmbasedir=$HOME/tm
28+
fi
29+
30+
# check default locations of TM web server files
31+
tmwebdir=/fast/www/tm
32+
if [[ -d /var/www/html ]]; then
33+
tmwebdir=/var/www/html
34+
elif [[ -d /opt/local/www/apache2/html ]]; then
35+
tmwebdir=/opt/local/www/apache2/html
36+
fi
37+
38+
# make sure we have a valid location for tmbasedir and it has the two
39+
# needed repositories, and that they appear to be valid repositories
40+
if [[ ! -d $tmbasedir ]]; then
41+
echo "TravelMapping repository base directory $tmbasedir not found"
42+
exit 1
43+
else
44+
if [[ ! -d $tmbasedir/HighwayData ]]; then
45+
echo "TravelMapping/HighwayData repository not found in $tmbasedir"
46+
exit 1
47+
elif [[ ! -d $tmbasedir/HighwayData/.git ]]; then
48+
echo "TravelMapping/HighwayData in $tmbasedir does not appear to be a git repository"
49+
exit 1
50+
fi
51+
if [[ ! -d $tmbasedir/UserData ]]; then
52+
echo "TravelMapping/UserData repository not found in $tmbasedir"
53+
exit 1
54+
elif [[ ! -d $tmbasedir/UserData/.git ]]; then
55+
echo "TravelMapping/UserData in $tmbasedir does not appear to be a git repository"
56+
exit 1
57+
fi
58+
fi
59+
60+
if [[ ! -d $tmwebdir ]]; then
61+
echo "Web directory $tmwebdir does not exist"
62+
exit 1
63+
fi
64+
if [[ ! -f $tmwebdir/participate.php ]]; then
65+
echo "Web directory $tmwebdir does not appear to contain a TM web instance"
66+
exit 1
67+
fi
68+
69+
graphdir=$tmwebdir/graphdata
70+
71+
export HIGHWAY_DATA=$tmbasedir/HighwayData
2472
echo "Creating graph archive set with date stamp $datestr"
2573
echo "Archive name $1, description: $2"
26-
archivedir=$tmwebbase/grapharchives/$1
74+
archivedir=$tmwebdir/grapharchives/$1
2775
if [ -d $archivedir ]; then
2876
echo "Archive directory $archivedir exists, exiting"
2977
exit 1
@@ -34,8 +82,8 @@ echo "Copying existing graphs from $graphdir to $archivedir"
3482
cp $graphdir/*.tmg $archivedir
3583

3684
echo "Gathering repo head info"
37-
hwydatavers=`(cd $tmbase/HighwayData; git show -s | head -n 1 | cut -f2 -d' ')`
38-
userdatavers=`(cd $tmbase/UserData; git show -s | head -n 1 | cut -f2 -d' ')`
85+
hwydatavers=`(cd $tmbasedir/HighwayData; git show -s | head -n 1 | cut -f2 -d' ')`
86+
userdatavers=`(cd $tmbasedir/UserData; git show -s | head -n 1 | cut -f2 -d' ')`
3987
dataprocvers=`git show -s | head -n 1 | cut -f2 -d' '`
4088
echo "Highway Data: $hwydatavers"
4189
echo "User Data: $userdatavers"

ArchiveGraphs/archivegraphs.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ int main(int argc, char *argv[]) {
215215
/* check for required command-line parameters:
216216
217217
argv[1]: name of archive
218-
argv[2]: longer description of the archive set
218+
argv[2]: longer description of the archive set, must be in double quotes
219219
argv[3]: SQL-format date string YYYY-MM-DD
220220
argv[4]: TravelMapping/HighwayData repository version
221221
argv[5]: TravelMapping/UserData repository version
@@ -229,8 +229,17 @@ int main(int argc, char *argv[]) {
229229
usage(argv[0]);
230230
}
231231

232+
if (argv[2][0] != '"') {
233+
fprintf(stderr, "Error: description must be specified in double quotes.\n");
234+
usage(argv[0]);
235+
}
236+
232237
char *archive_name = argv[1];
233238
char *description = argv[2];
239+
// strip off double quotes from description
240+
description++;
241+
description[strlen(description)-1] = '\0';
242+
234243
/* should check here for a proper date format */
235244
char *datestamp = argv[3];
236245
char *hwy_vers = argv[4];

0 commit comments

Comments
 (0)