-
-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathdaily.sh
executable file
·93 lines (69 loc) · 1.86 KB
/
daily.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
set -u
if [[ -t 1 ]]
then
exec 2>&1 | ts '%X %Z'
fi
export PATH=/usr/local/bin:$PATH
MB_SERVER_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)
cd "$MB_SERVER_ROOT"
source admin/config.sh
# Only run one "daily.sh" at a time
if [ "${1:-}" != "gotlock" ]
then
true ${LOCKFILE:=/tmp/daily.sh.lock}
$MB_SERVER_ROOT/bin/runexclusive -f "$LOCKFILE" --no-wait \
$MB_SERVER_ROOT/admin/cron/daily.sh gotlock
if [ $? = 100 ]
then
echo "Aborted - there is already another daily.sh running"
fi
exit
fi
# We have the lock - on with the show.
. ./admin/functions.sh
make_temp_dir
# Collect stats
echo Collecting statistics
./admin/CollectStats.pl
DATETIME=`date +'%Y%m%d-%H%M%S'`
echo Removing unused artists
./admin/cleanup/RemoveEmpty artist
echo Removing unused events
./admin/cleanup/RemoveEmpty event
echo Removing unused labels
./admin/cleanup/RemoveEmpty label
echo Removing unused places
./admin/cleanup/RemoveEmpty place
echo Removing unused release groups
./admin/cleanup/RemoveEmpty release_group
echo Removing unused series
./admin/cleanup/RemoveEmpty series
echo Removing unused urls
./admin/cleanup/RemoveEmpty url
echo Removing unused works
./admin/cleanup/RemoveEmpty work
echo Removing unreferenced rows
./admin/cleanup/RemoveUnreferencedRows
# Dump all the data
# Only do this on the nominated days 3=Wed and 6=Sat (for reference 0=Sun)
if date +%w | grep -qw '[36]'
then
FULL=1
fi
./admin/RunExport ${FULL:-}
# Create the reports
echo Running reports
nice ./admin/RunReports.pl
# Add missing track lengths
./admin/cleanup/FixTrackLength.pl
# Process subscriptions
echo Processing subscriptions
if date +%w | grep -qw '[6]'
then
WEEKLY="--weekly"
fi
./admin/ProcessSubscriptions ${WEEKLY:-}
# Updating language frequencies
./admin/SetLanguageFrequencies
echo `date`" : Nightly jobs complete!"