mirror of
https://git.freebsd.org/ports.git
synced 2026-06-02 11:08:52 +00:00
net/py-wsdd: fix rc script to report status
PR: 292051 Reported by: Igor Pavlov <igor.arabesc.pavlov@gmail.com> Author: Hiroo Ono <hiroo.ono+freebsd@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
PORTNAME= wsdd
|
||||
DISTVERSIONPREFIX= v
|
||||
DISTVERSION= 0.9
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net python
|
||||
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
||||
|
||||
@@ -24,9 +25,13 @@ GROUPS= _wsdd
|
||||
PLIST_FILES= bin/${PORTNAME} \
|
||||
etc/rc.d/${PORTNAME} \
|
||||
share/man/man8/${PORTNAME}.8.gz
|
||||
SUB_FILES= pkg-message
|
||||
|
||||
post-patch:
|
||||
${REINPLACE_CMD} 's|PYTHON|${PYTHON_CMD}|' ${WRKSRC}/etc/rc.d/${PORTNAME}.freebsd
|
||||
${REINPLACE_CMD} \
|
||||
-e 's|%%PYTHON_CMD%%|${PYTHON_CMD}|' \
|
||||
-e 's|%%LOCALBASE%%|${LOCALBASE}|' \
|
||||
${WRKSRC}/etc/rc.d/${PORTNAME}.freebsd
|
||||
|
||||
do-install:
|
||||
${INSTALL_SCRIPT} ${WRKSRC}/src/${PORTNAME}.py \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- etc/rc.d/wsdd.freebsd.orig 2020-06-28 19:10:44 UTC
|
||||
--- etc/rc.d/wsdd.freebsd.orig 2025-06-01 20:58:08 UTC
|
||||
+++ etc/rc.d/wsdd.freebsd
|
||||
@@ -2,28 +2,64 @@
|
||||
@@ -2,28 +2,69 @@
|
||||
|
||||
# PROVIDE: wsdd
|
||||
# REQUIRE: DAEMON samba_server
|
||||
@@ -13,18 +13,22 @@
|
||||
+# wsdd_enable="YES"
|
||||
+# wsdd_flags="<set as needed>"
|
||||
+# wsdd_domain="<set if your host is an AD member>"
|
||||
+# wsdd_group="<set if you want to set the workgroup manually>"
|
||||
+# wsdd_workgroup="<set if you want to set the workgroup manually>"
|
||||
+#
|
||||
+# The wsdd_domain option will override the wsdd_workgroup option.
|
||||
+#
|
||||
+# Do not specify -d DOMAIN or -w WORKGROUP in wsdd_flags. Instead, set
|
||||
+# wsdd_domain="DOMAIN" or wsdd_group="WORKGROUP", otherwise it will be
|
||||
+# overridden by automatically detected workgroup.
|
||||
+# wsdd_domain="DOMAIN" or wsdd_workgroup="WORKGROUP", otherwise it
|
||||
+# will be overridden by automatically detected workgroup.
|
||||
+#
|
||||
+
|
||||
. /etc/rc.subr
|
||||
|
||||
name=wsdd
|
||||
rcvar=wsdd_enable
|
||||
-name=wsdd
|
||||
-rcvar=wsdd_enable
|
||||
-wsdd_group=$(/usr/local/bin/testparm -s --parameter-name workgroup 2>/dev/null)
|
||||
+name="wsdd"
|
||||
+rcvar="wsdd_enable"
|
||||
|
||||
-: ${wsdd_smb_config_file="/usr/local/etc/smb4.conf"}
|
||||
+load_rc_config ${name}
|
||||
@@ -35,44 +39,46 @@
|
||||
+: ${wsdd_enable:="NO"}
|
||||
+: ${wsdd_flags:=""}
|
||||
+: ${wsdd_domain:=""}
|
||||
+: ${wsdd_group:=""}
|
||||
+: ${wsdd_smb_config_file:="/usr/local/etc/smb4.conf"}
|
||||
+: ${wsdd_workgroup:=""}
|
||||
+: ${wsdd_smb_config_file:="%%LOCALBASE%%/etc/smb4.conf"}
|
||||
+
|
||||
+if [ -z "${wsdd_group}" ]; then
|
||||
+ # automatic detection of workgroup
|
||||
+ wsdd_group=$(/usr/local/bin/testparm -s --parameter-name workgroup 2>/dev/null)
|
||||
+
|
||||
+ # try to manually extract workgroup from samba configuration if testparm failed
|
||||
+ if [ -z "$wsdd_group" ] && [ -r $wsdd_smb_config_file ]; then
|
||||
+ wsdd_group="$(grep -i '^[[:space:]]*workgroup[[:space:]]*=' $wsdd_smb_config_file | cut -f2 -d= | tr -d '[:blank:]')"
|
||||
+ fi
|
||||
+if [ -n "${wsdd_group}" ]; then
|
||||
+ warn "wsdd_group is replaced by wsdd_workgroup, check your configuration."
|
||||
+ wsdd_workgroup="${wsdd_workgroup:-$wsdd_group}"
|
||||
+ wsdd_group=""
|
||||
fi
|
||||
|
||||
-if [ -n "$wsdd_group" ]; then
|
||||
- wsdd_opts="-w ${wsdd_group}"
|
||||
+if [ -z "${wsdd_workgroup}" ]; then
|
||||
+ # automatic detection of workgroup
|
||||
+ wsdd_workgroup=$(/usr/local/bin/testparm -s --parameter-name workgroup 2>/dev/null)
|
||||
+
|
||||
+ # try to manually extract workgroup from samba configuration if testparm failed
|
||||
+ if [ -z "$wsdd_workgroup" ] && [ -r $wsdd_smb_config_file ]; then
|
||||
+ wsdd_workgroup="$(grep -i '^[[:space:]]*workgroup[[:space:]]*=' $wsdd_smb_config_file | cut -f2 -d= | tr -d '[:blank:]')"
|
||||
+ fi
|
||||
fi
|
||||
|
||||
+wsdd_opts=""
|
||||
+if [ -n "${wsdd_flags}" ]; then
|
||||
+ wsdd_opts="${wsdd_flags}"
|
||||
fi
|
||||
+ # wsdd_flags is added just after ${command}, so clear it.
|
||||
+ wsdd_flags=""
|
||||
+fi
|
||||
+if [ -n "$wsdd_domain" ]; then
|
||||
+ wsdd_opts="${wsdd_opts} -d ${wsdd_domain}"
|
||||
+elif [ -n "$wsdd_group" ]; then
|
||||
+ wsdd_opts="${wsdd_opts} -w ${wsdd_group}"
|
||||
+elif [ -n "$wsdd_workgroup" ]; then
|
||||
+ wsdd_opts="${wsdd_opts} -w ${wsdd_workgroup}"
|
||||
+fi
|
||||
|
||||
-command="/usr/sbin/daemon"
|
||||
-command_args="-u daemon -S /usr/local/bin/wsdd $wsdd_opts"
|
||||
+command="/usr/local/bin/wsdd"
|
||||
+procname="PYTHON"
|
||||
+
|
||||
+procname="%%LOCALBASE%%/bin/wsdd"
|
||||
+pidfile="/var/run/${name}.pid"
|
||||
command="/usr/sbin/daemon"
|
||||
-command_args="-u daemon -S /usr/local/bin/wsdd $wsdd_opts"
|
||||
+command_interpreter="%%PYTHON_CMD%%"
|
||||
+command_args="-u _wsdd -S -p ${pidfile} -- ${procname} ${wsdd_opts}"
|
||||
|
||||
-load_rc_config $name
|
||||
+start_cmd="${name}_start"
|
||||
+
|
||||
+wsdd_start()
|
||||
+{
|
||||
+ echo "Starting ${name}."
|
||||
+ /usr/sbin/daemon -u _wsdd -S -p ${pidfile} ${command} ${wsdd_opts}
|
||||
+}
|
||||
+
|
||||
run_rc_command "$1"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
The rc variable for the workgroup name in /etc/rc.conf has changed from
|
||||
wsdd_group to wsdd_workgroup. Do not forget to change the variable name.
|
||||
|
||||
EOM
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user