-
Notifications
You must be signed in to change notification settings - Fork 0
/
packit
executable file
·53 lines (42 loc) · 1.66 KB
/
packit
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
#!/bin/bash
# Locate self
BinDir=$(cd `dirname $0` >/dev/null 2>&1; pwd)
Pack="$BinDir/export2skoda"
# Source & destination base locations
Src="/srv/HACaMSfs/Media/Audio/Music"
Dst="/srv/HACaMSfs/Media/Portable"
# Purge existing destination, if any
rm -rf $Dst/Music
mkdir -p $Dst/Music
date >$Dst/.status
# Cleanup source
$BinDir/cleanup $Src >>$Dst/.status 2>&1
# Export into target directory with specified constraints
$Pack $Dst/Music/English $Src/Favourites/English >>$Dst/.status 2>&1
$Pack $Dst/Music/Foreign $Src/Favourites/Foreign >>$Dst/.status 2>&1
$Pack $Dst/Music/Hindi $Src/Favourites/Hindi >>$Dst/.status 2>&1
$Pack $Dst/Music/Mashup $Src/Collections/Hindi/Mashup >>$Dst/.status 2>&1
$Pack $Dst/Music/Retro $Src/Collections/Hindi/Retro >>$Dst/.status 2>&1
$Pack $Dst/Music/Bengali $Src/Favourites/Bengali >>$Dst/.status 2>&1
# Create category-wise & composite playlists
HomeDir="$PWD"
cd "$Dst/Music"
Cats="English Hindi Foreign Mashup Retro Bengali"
for category in $Cats; do
find $category -type f -iname \*.mp3 | shuf >$category.m3u
done
cat English.m3u Hindi.m3u | shuf >Favourites.m3u
cat Hindi.m3u Mashup.m3u Retro.m3u | shuf >AllHindi.m3u
cd "$HomeDir"
# Make destination fully permissive
chmod -R 777 $Dst
# Cleanup destination
$BinDir/cleanup $Dst/Music >>$Dst/.status 2>&1
# Summary
sz=`du -h $Dst | tail -1 | awk '{print $1}'`
cnt=`find $Dst -type f | wc -l`
echo "Total $cnt files (${sz}b)" >>$Dst/.status
date >>$Dst/.status
echo "Copied $cnt files occupying ${sz}b to $Dst"
# Push notify
/opt/HACaMS/bin/push-notify --sender "HACaMS" --action "portable media packed into" --result "$cnt files (${sz}b)"