Skip to content

Commit

Permalink
Add mdnsd daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Sep 20, 2024
1 parent 136587d commit 36da7ad
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mdnsd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore the install dir
_install/
mdnsd-0.12/
10 changes: 10 additions & 0 deletions src/mdnsd/cleanup.mdnsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

source config.mdnsd

rm -rf "${BUILD_FOLDER}"

make clean
13 changes: 13 additions & 0 deletions src/mdnsd/compile.mdnsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

source config.mdnsd

cd "${BUILD_FOLDER}"

make || exit 1
make install || exit 1

arm-openwrt-linux-strip ../_install/sbin/* || exit 1
7 changes: 7 additions & 0 deletions src/mdnsd/config.mdnsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

VERSION="0.12"
MAIN_URL="https://github.com/troglobit/mdnsd/releases/download/v${VERSION}/mdnsd-${VERSION}.tar.gz"
PACKAGE="mdnsd-${VERSION}"
ARCHIVE="${PACKAGE}.tar.gz"
BUILD_FOLDER="mdnsd-${VERSION}"
26 changes: 26 additions & 0 deletions src/mdnsd/init.mdnsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

source config.mdnsd

rm -rf ./_install

if [ ! -f ${ARCHIVE} ]; then
wget "${MAIN_URL}" || exit 1
fi
tar zxvf "${ARCHIVE}" || exit 1
cd "${BUILD_FOLDER}" || exit 1

./configure CC=arm-openwrt-linux-gcc \
--prefix=$SCRIPT_DIR/_install \
CFLAGS="-Os -mcpu=cortex-a7 -mfpu=neon-vfpv4 -I/opt/yi/toolchain-sunxi-musl/toolchain/include -L/opt/yi/toolchain-sunxi-musl/toolchain/lib" \
AR=arm-openwrt-linux-ar \
RANLIB=arm-openwrt-linux-ranlib \
--host=arm \
--disable-shared \
--disable-doc \
--without-mquery \
--without-systemd \
|| exit 1
8 changes: 8 additions & 0 deletions src/mdnsd/install.mdnsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

mkdir -p ../../build/yi-hack/sbin/

rsync -a ./_install/sbin/mdnsd ../../build/yi-hack/sbin/
15 changes: 15 additions & 0 deletions src/static/static/yi-hack/script/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,21 @@ if [[ $(get_config ONVIF) == "yes" ]] ; then
fi
fi

MDNSD_ENABLED=0
if [[ $(get_config HTTPD) == "yes" ]] ; then
mkdir -p /tmp/mdns.d
echo -e "type _http._tcp\nport $HTTPD_PORT\n" > /tmp/mdns.d/http.service
MDNSD_ENABLED=1
fi
if [[ $(get_config SSHD) == "yes" ]] ; then
mkdir -p /tmp/mdns.d
echo -e "type _ssh._tcp\nport 22\n" > /tmp/mdns.d/ssh.service
MDNSD_ENABLED=1
fi
if [[ "$MDNSD_ENABLED" == "1" ]] ; then
/tmp/sd/yi-hack/sbin/mdnsd /tmp/mdns.d
fi

if [[ $(get_config TIME_OSD) == "yes" ]] ; then
log "Enable time osd"
# Enable time osd
Expand Down

0 comments on commit 36da7ad

Please sign in to comment.