forked from mytracks/readymedia
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstart.sh
executable file
·182 lines (139 loc) · 4.29 KB
/
start.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/sh
INITIAL_CONF="/etc/minidlna.conf"
PERSISTENT_CONF="/cache/minidlna.conf"
TEMP_CONF="/tmp/minidlna.conf"
PID_FILE="/run/minidlna.pid"
## Copying initial config file to persistent storage
if [[ ! -f "$PERSISTENT_CONF" ]]; then
cat "$INITIAL_CONF" > "$PERSISTENT_CONF"
fi
## Copying persisten config file to the temp config file.
cat "$PERSISTENT_CONF" > "$TEMP_CONF"
## Updating temp config file with parameters from Docker ENV.
echo "port=${TCP_PORT}" >> "$TEMP_CONF"
echo "friendly_name=${FRIENDLY_NAME}" >> "$TEMP_CONF"
echo "serial=${SERIAL}" >> "$TEMP_CONF"
# All media dirs
if [[ ! -z "${ALL_MEDIA_DIR1}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR1}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR2}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR2}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR3}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR3}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR4}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR4}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR5}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR5}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR6}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR6}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR7}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR7}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR8}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR8}" >> "$TEMP_CONF"
fi
if [[ ! -z "${ALL_MEDIA_DIR9}" ]]; then
echo "media_dir=${ALL_MEDIA_DIR9}" >> "$TEMP_CONF"
fi
# Video
if [[ ! -z "${VIDEO_DIR1}" ]]; then
echo "media_dir=V,${VIDEO_DIR1}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR2}" ]]; then
echo "media_dir=V,${VIDEO_DIR2}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR3}" ]]; then
echo "media_dir=V,${VIDEO_DIR3}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR4}" ]]; then
echo "media_dir=V,${VIDEO_DIR4}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR5}" ]]; then
echo "media_dir=V,${VIDEO_DIR5}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR6}" ]]; then
echo "media_dir=V,${VIDEO_DIR6}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR7}" ]]; then
echo "media_dir=V,${VIDEO_DIR7}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR8}" ]]; then
echo "media_dir=V,${VIDEO_DIR8}" >> "$TEMP_CONF"
fi
if [[ ! -z "${VIDEO_DIR9}" ]]; then
echo "media_dir=V,${VIDEO_DIR9}" >> "$TEMP_CONF"
fi
# Audio
if [[ ! -z "${AUDIO_DIR1}" ]]; then
echo "media_dir=A,${AUDIO_DIR1}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR2}" ]]; then
echo "media_dir=A,${AUDIO_DIR2}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR3}" ]]; then
echo "media_dir=A,${AUDIO_DIR3}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR4}" ]]; then
echo "media_dir=A,${AUDIO_DIR4}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR5}" ]]; then
echo "media_dir=A,${AUDIO_DIR5}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR6}" ]]; then
echo "media_dir=A,${AUDIO_DIR6}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR7}" ]]; then
echo "media_dir=A,${AUDIO_DIR7}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR8}" ]]; then
echo "media_dir=A,${AUDIO_DIR8}" >> "$TEMP_CONF"
fi
if [[ ! -z "${AUDIO_DIR9}" ]]; then
echo "media_dir=A,${AUDIO_DIR9}" >> "$TEMP_CONF"
fi
# Pictures
if [[ ! -z "${PICTURES_DIR1}" ]]; then
echo "media_dir=P,${PICTURES_DIR1}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR2}" ]]; then
echo "media_dir=P,${PICTURES_DIR2}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR3}" ]]; then
echo "media_dir=P,${PICTURES_DIR3}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR4}" ]]; then
echo "media_dir=P,${PICTURES_DIR4}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR5}" ]]; then
echo "media_dir=P,${PICTURES_DIR5}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR6}" ]]; then
echo "media_dir=P,${PICTURES_DIR6}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR7}" ]]; then
echo "media_dir=P,${PICTURES_DIR7}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR8}" ]]; then
echo "media_dir=P,${PICTURES_DIR8}" >> "$TEMP_CONF"
fi
if [[ ! -z "${PICTURES_DIR9}" ]]; then
echo "media_dir=P,${PICTURES_DIR9}" >> "$TEMP_CONF"
fi
## Sometimes PID file can exist after restart. Cleaning.
if [[ -f "$PID_FILE" ]]; then
pid=$(cat "$PID_FILE")
if [[ -n "$(ps -p $pid -o pid=)" ]]; then
echo "Another MiniDLNA instance is running: $pid. Exiting..."
exit 1
else
echo "Removing uncleaned pid file: $PID_FILE"
rm -f "$PID_FILE"
fi
fi
exec /usr/sbin/minidlnad -P "$PID_FILE" -f "$TEMP_CONF" -S -r