Skip to content

Commit 4a62962

Browse files
committed
Suppress various Avahi logic parts in docker entrypoint when Avahi is disabled
1 parent ddcff82 commit 4a62962

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
# MAIN CONFIGURATION
@@ -131,7 +131,7 @@ if [ ! -f "$INITALIZED" ]; then
131131
echo -e "$ACCOUNT_PASSWORD\n$ACCOUNT_PASSWORD" | passwd "$ACCOUNT_NAME"
132132
echo -e "$ACCOUNT_PASSWORD\n$ACCOUNT_PASSWORD" | smbpasswd "$ACCOUNT_NAME"
133133
fi
134-
134+
135135
smbpasswd -e "$ACCOUNT_NAME"
136136
done
137137

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

167-
if ! grep '<txt-record>model=' /etc/avahi/services/samba.service 2> /dev/null >/dev/null;
167+
if [ -f /etc/avahi/services/samba.service ] && ! grep '<txt-record>model=' /etc/avahi/services/samba.service 2> /dev/null >/dev/null;
168168
then
169169
# remove </service-group>
170170
sed -i '/<\/service-group>/d' /etc/avahi/services/samba.service
@@ -246,7 +246,7 @@ if [ ! -f "$INITALIZED" ]; then
246246
' >> /etc/samba/smb.conf
247247
fi
248248

249-
if echo "$VOL_PATH" | grep '%U$' 2>/dev/null >/dev/null;
249+
if echo "$VOL_PATH" | grep '%U$' 2>/dev/null >/dev/null;
250250
then
251251
VOL_PATH_BASE=$(echo "$VOL_PATH" | sed 's,/%U$,,g')
252252
echo " >> multiuser volume - $VOL_PATH"
@@ -260,17 +260,21 @@ if [ ! -f "$INITALIZED" ]; then
260260
[ ! -z ${AVAHI_NAME+x} ] && echo ">> ZEROCONF: custom avahi samba.service name: $AVAHI_NAME" && sed -i 's/%h/'"$AVAHI_NAME"'/g' /etc/avahi/services/samba.service
261261
[ ! -z ${AVAHI_NAME+x} ] && echo ">> ZEROCONF: custom avahi avahi-daemon.conf host-name: $AVAHI_NAME" && sed -i "s/#host-name=foo/host-name=${AVAHI_NAME}/" /etc/avahi/avahi-daemon.conf
262262

263-
echo ">> ZEROCONF: samba.service file"
264-
echo "############################### START ####################################"
265-
cat /etc/avahi/services/samba.service
266-
echo "################################ END #####################################"
263+
if [ -z ${AVAHI_DISABLE+x} ]
264+
then
265+
echo ">> ZEROCONF: samba.service file"
266+
echo "############################### START ####################################"
267+
cat /etc/avahi/services/samba.service
268+
echo "################################ END #####################################"
269+
else
270+
echo ">> AVAHI - DISABLED"
271+
rm -rf /container/config/runit/avahi
272+
fi
267273

268274
[ ! -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
269275

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

272-
[ ! -z ${AVAHI_DISABLE+x} ] && echo ">> AVAHI - DISABLED" && rm -rf /container/config/runit/avahi
273-
274278
[ ! -z ${NETBIOS_DISABLE+x} ] && echo ">> NETBIOS - DISABLED" && rm -rf /container/config/runit/nmbd
275279

276280
if [ -z ${AVAHI_DISABLE+x} ] && [ ! -f "/external/avahi/not-mounted" ]
@@ -283,7 +287,7 @@ if [ ! -f "$INITALIZED" ]; then
283287
echo ">> EXTERNAL AVAHI: list of services"
284288
ls -l /external/avahi/*.service
285289
fi
286-
290+
287291
echo ""
288292
echo ">> SAMBA: check smb.conf file using 'testparm -s'"
289293
echo "############################### START ####################################"

0 commit comments

Comments
 (0)