-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsynodlna-reindex.sh
executable file
·80 lines (65 loc) · 1.72 KB
/
synodlna-reindex.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
#!/opt/bin/bash
##
# author : Didier BONNEFOI <[email protected]>
# inspired by http://forum.synology.com/enu/viewtopic.php?f=37&t=30242
##
DEBUG=0
ARRAY_DEBUG=0
#### LIBS STUFF ####
# to override VOLUME_ROOT variable
[ -f config.sh ] && . ./config.sh
. ./lib/common/arraymap.lib.sh
. ./lib/synodlna/synodlna-shares.lib.sh
. ./lib/synodlna/synodlna-synoindex.lib.sh
[ $? -ne 0 ] && echo "error on includes..." && exit 1
#### MAIN ####
count_synoindexd=$(pidof synoindexd | wc -w)
[ $count_synoindexd -gt 1 ] && echo "stop, synoindexd always running..." && exit 1
cmd=$1
short_path=$2
case "$cmd" in
start)
# get all DLNA directories from database
dlnashares_extract
case "$short_path" in
all)
# we get all existing DLNA shares
dlna_path=$(dlnashares_get_all_path)
;;
*)
[ "$short_path" == "" ] && echo "directory not defined" >&2 && exit 1
# we extract the path to analyze
dlna_path=$(dlnashares_get_all_path | egrep "^[0-9]+:/$short_path$")
;;
esac
[ "$dlna_path" == "" ] && echo "bad directory !" >&2 && exit 1
# we start reindex for each share
for dp in $(echo $dlna_path)
do
dlna_id=$(echo $dp | cut -d':' -f1)
dlna_synoindex $dlna_id
echo
done
;;
stop|restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
list)
echo "here are valid DLNA shares:"
# get all DLNA directories from database
dlnashares_extract
# list all valid shares
dlnashares_get_all_path | cut -d':' -f2 | sed 's/\// - /g'
;;
*)
cat <<EOF
Usage:
------
$0 list : list all valid DLNA shares
$0 start a_dlna_share_without_slash
$0 start all
EOF
exit 3
;;
esac