1
1
Fork 0

Add WSDD / support files

This commit is contained in:
Michael Höß 2020-11-07 19:27:46 +01:00
parent f98cf62610
commit 4bdf03a09c
4 changed files with 1802 additions and 0 deletions

26
gentoo/wsdd/README.md Normal file
View File

@ -0,0 +1,26 @@
My configs/init-script for WSDD.
Original source see https://github.com/christgau/wsdd
Install:
Check if newer wsdd.py is available at source!
```
cp wsdd.py /opt/wsdd/wsdd.py
chown -R daemon.daemon /opt/wsdd/wsdd.py
cp wsdd.init /etc/init.d/wsdd
cp wsdd.conf /etc/conf.d/wsdd
```
# Running:
- Be sure to update /etc/conf.d/wsdd!
- If using single instance all fields of /etc/conf.d/wsdd should be commented out!
- If using multiple instances (wsdd.INSTANCE...) be sure to set all fields in /etc/conf.d/wsdd in ALL instances!
- UUIDs can be generated with `uuidgen -N test.mh3000.net -n @dns -s`

7
gentoo/wsdd/wsdd.conf Normal file
View File

@ -0,0 +1,7 @@
# !! If adding instance (wsdd.INSTANCE) be aware that all fields are inherited from this file,
# !! and therefore must be redefined
WSDD_INTERFACE="192.168.61.1"
WSDD_HOST="ZEUS"
# Generate with uuidgen -N [FQDN] -n @dns -s
WSDD_UUID="9044b09f-1dd5-5309-b453-1e3408673d56"

81
gentoo/wsdd/wsdd.init Executable file
View File

@ -0,0 +1,81 @@
#!/sbin/openrc-run
# Copyright 2017 Steffen Christgau
# Distributed under the terms of the MIT licence
depend() {
need net
need samba
}
SMB_CONFIG_FILE="/etc/samba/smb.conf"
LOG_FILE="${WSDD_LOG_FILE:-/var/log/wsdd.log}"
WSDD_EXEC="/opt/wsdd/wsdd.py"
RUN_AS_USER="${WSDD_USER:-daemon:daemon}"
SVCPREFIX="${SVCNAME%.*}"
INSTNAME="${SVCNAME:${#SVCPREFIX}+1}"
start() {
ebegin "Starting ${RC_SVCNAME} daemon"
OPTS="${WSDD_OPTS}"
if [ -z "$WSDD_WORKGROUP" ]; then
# try to extract workgroup with Samba's testparm
if which testparm >/dev/null 2>/dev/null; then
GROUP="$(testparm -s --parameter-name workgroup 2>/dev/null)"
fi
# fallback to poor man's approach if testparm is unavailable or failed for some reason
if [ -z "$GROUP" ] && [ -r "${SMB_CONFIG_FILE}" ]; then
GROUP=`grep -i '^\s*workgroup\s*=' ${SMB_CONFIG_FILE} | cut -f2 -d= | tr -d '[:blank:]'`
fi
if [ -n "${GROUP}" ]; then
OPTS="-w ${GROUP} ${OPTS}"
fi
else
OPTS="-w ${WSDD_WORKGROUP} ${OPTS}"
fi
if [ -z "${WSDD_HOST}" ]; then
WSDD_HOST="${INSTNAME}"
fi
if [ -n "${WSDD_HOST}" ]; then
OPTS="-n ${WSDD_HOST} ${OPTS}"
fi
if [ -n "${WSDD_INTERFACE}" ]; then
OPTS="-i ${WSDD_INTERFACE} ${OPTS}"
fi
if [ -n "${WSDD_UUID}" ]; then
OPTS="-U ${WSDD_UUID} ${OPTS}"
fi
if [ -n "${INSTNAME}" ]; then
if ! [[ "${OPTS}" =~ -i ]] && ! [[ "${OPTS}" =~ --interface ]]; then
ewarn "If running multiple service-instances set WSDD_INTERFACE or parameter -i"
fi
if ! [[ "${OPTS}" =~ -U ]] && ! [[ "${OPTS}" =~ --uuid ]]; then
ewarn "If running multiple service-instances set WSDD_UUID or parameter -u"
fi
fi
if [ ! -r "${LOG_FILE}" ]; then
touch "${LOG_FILE}"
fi
chown ${RUN_AS_USER} "${LOG_FILE}"
start-stop-daemon --start --background --user ${RUN_AS_USER} --make-pidfile --pidfile /var/run/${RC_SVCNAME}.pid --stdout "${LOG_FILE}" --stderr "${LOG_FILE}" --exec ${WSDD_EXEC} -- ${OPTS}
eend $?
}
stop() {
ebegin "Stopping ${RC_SVCNAME} daemon"
start-stop-daemon --stop --retry 2 --pidfile /var/run/${RC_SVCNAME}.pid --exec ${WSDD_EXEC}
eend $?
}

1688
gentoo/wsdd/wsdd.py Executable file

File diff suppressed because it is too large Load Diff