Skip to content

Commit b810b86

Browse files
committed
Suppress various Avahi logic parts in docker entrypoint when Avahi is disabled
1 parent 2c97e41 commit b810b86

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

scripts/entrypoint.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if [ ! -f "$INITALIZED" ]; then
3030
echo ">> CONTAINER: starting initialisation"
3131

3232
cp /container/config/samba/smb.conf /etc/samba/smb.conf
33-
cp /container/config/avahi/samba.service /etc/avahi/services/samba.service
33+
[ ! -z ${AVAHI_DISABLE+x} ] || cp /container/config/avahi/samba.service /etc/avahi/services/samba.service
3434

3535
##
3636
# FRUIT DISABLE
@@ -149,7 +149,7 @@ if [ ! -f "$INITALIZED" ]; then
149149
echo -e "$ACCOUNT_PASSWORD\n$ACCOUNT_PASSWORD" | passwd "$ACCOUNT_NAME"
150150
echo -e "$ACCOUNT_PASSWORD\n$ACCOUNT_PASSWORD" | smbpasswd "$ACCOUNT_NAME"
151151
fi
152-
152+
153153
smbpasswd -e "$ACCOUNT_NAME"
154154
done
155155

@@ -182,7 +182,7 @@ if [ ! -f "$INITALIZED" ]; then
182182
[ -z ${MODEL+x} ] && MODEL="TimeCapsule"
183183
sed -i 's/TimeCapsule/'"$MODEL"'/g' /etc/samba/smb.conf
184184

185-
if ! grep '<txt-record>model=' /etc/avahi/services/samba.service 2> /dev/null >/dev/null;
185+
if [ -f /etc/avahi/services/samba.service ] && ! grep '<txt-record>model=' /etc/avahi/services/samba.service 2> /dev/null >/dev/null;
186186
then
187187
# remove </service-group>
188188
sed -i '/<\/service-group>/d' /etc/avahi/services/samba.service
@@ -262,7 +262,7 @@ if [ ! -f "$INITALIZED" ]; then
262262
' >> /etc/samba/smb.conf
263263
fi
264264

265-
if echo "$VOL_PATH" | grep '%U$' 2>/dev/null >/dev/null;
265+
if echo "$VOL_PATH" | grep '%U$' 2>/dev/null >/dev/null;
266266
then
267267
VOL_PATH_BASE=$(echo "$VOL_PATH" | sed 's,/%U$,,g')
268268
echo " >> multiuser volume - $VOL_PATH"
@@ -277,17 +277,21 @@ if [ ! -f "$INITALIZED" ]; then
277277
[ ! -z ${AVAHI_NAME+x} ] && echo ">> ZEROCONF: custom avahi avahi-daemon.conf host-name: $AVAHI_NAME" && sed -i "s/#host-name=.*/host-name=${AVAHI_NAME}/" /etc/avahi/avahi-daemon.conf
278278
[ ! -z ${AVAHI_INTERFACES+x} ] && echo ">> ZEROCONF: custom avahi avahi-daemon.conf allow-interfaces: $AVAHI_INTERFACES" && sed -i "s/#allow-interfaces=.*/allow-interfaces=${AVAHI_INTERFACES}/" /etc/avahi/avahi-daemon.conf
279279

280-
echo ">> ZEROCONF: samba.service file"
281-
echo "############################### START ####################################"
282-
cat /etc/avahi/services/samba.service
283-
echo "################################ END #####################################"
280+
if [ -z ${AVAHI_DISABLE+x} ]
281+
then
282+
echo ">> ZEROCONF: samba.service file"
283+
echo "############################### START ####################################"
284+
cat /etc/avahi/services/samba.service
285+
echo "################################ END #####################################"
286+
else
287+
echo ">> AVAHI - DISABLED"
288+
rm -rf /container/config/runit/avahi
289+
fi
284290

285291
[ ! -z ${WSDD2_PARAMETERS+x} ] && echo ">> WSDD2: custom parameters for wsdd2 daemon: wsdd2 $WSDD2_PARAMETERS" && sed -i 's/wsdd2/wsdd2 '"$WSDD2_PARAMETERS"'/g' /container/config/runit/wsdd2/run
286292

287293
[ ! -z ${WSDD2_DISABLE+x} ] && echo ">> WSDD2 - DISABLED" && rm -rf /container/config/runit/wsdd2
288294

289-
[ ! -z ${AVAHI_DISABLE+x} ] && echo ">> AVAHI - DISABLED" && rm -rf /container/config/runit/avahi
290-
291295
[ ! -z ${NETBIOS_DISABLE+x} ] && echo ">> NETBIOS - DISABLED" && rm -rf /container/config/runit/nmbd
292296

293297
if [ -z ${AVAHI_DISABLE+x} ] && [ ! -f "/external/avahi/not-mounted" ]
@@ -300,7 +304,7 @@ if [ ! -f "$INITALIZED" ]; then
300304
echo ">> EXTERNAL AVAHI: list of services"
301305
ls -l /external/avahi/*.service
302306
fi
303-
307+
304308
echo ""
305309
echo ">> SAMBA: check smb.conf file using 'testparm -s'"
306310
echo "############################### START ####################################"

0 commit comments

Comments
 (0)