-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscraper.sh
executable file
·73 lines (51 loc) · 2.12 KB
/
scraper.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Author: Daniel E. Krutz
# Description: Scrape newest repos from existing GIT Reop
# Script location. Must be placed near top of script
MainScriptLoc=`pwd`
# Location of directory to output repo files to
projectFiles=repos
### Database Location
db=$MainScriptLoc/db/AndrosecDatabase.sqlite
echo "Removing existing output files"
rm -rf $projectFiles
mkdir -p $projectFiles
### Logging
mkdir -p logs/
date1=$(date +"%s") ## Start date of the script
logLocation=logs/scraper.log
rm -f $logLocation ## Clear the log file if it exists
touch $logLocation
echo "Start Scraper: " `date` >> $logLocation
### Since this will attempt to download the newest versions of all repos, all should be initially set to be 0
echo "Set isRepoPulled = 0"
sqlite3 $db "update appdata set isRepoPulled = 0;"
OutputList=`sqlite3 $db "select appID, name, source_code from appData where source_code like '%.git'"`;
for ROW in $OutputList; do
appID=`echo $ROW | awk '{split($0,a,"|"); print a[1]}'`
appname=`echo $ROW | awk '{split($0,a,"|"); print a[2]}'`
source_code=`echo $ROW | awk '{split($0,a,"|"); print a[3]}'`
echo "***Clone Repo $appID $appname : " `date` >> $logLocation
if [ -n "$appname" ]; then
cd $projectFiles
echo "******Starting Clone $appID $appname : " `date` >> ../$logLocation
git clone $source_code $appname ## Clone into a folder named the same as the appName
echo "******Clone Complete $appID $appname : " `date` >> ../$logLocation
cd $MainScriptLoc
# update the DB with the pull information
### Set that it was updated
sqlite3 $db "update appdata set isRepoPulled = 1 where appID = $appID;"
## Update the date field
sqlite3 $db "update appdata set repopulldate = '`date`' where appID = $appID;"
else
echo $appID " " $appname
echo "******$appID $appname Not Found: " `date` >> $logLocation
fi
done
diff=$(($date2-$date1))
echo "Total Running Time $(($diff / 60)) minutes and $(($diff % 60)) seconds." >> $logLocation
echo "End:" `date` >> $logLocation
#### Todo
# Logging
# Fix running time
# Find other applications from the F-Droid repo