<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=1718&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / init.d: process ID samba]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=1718</link>
		<description><![CDATA[The most recent posts in init.d: process ID samba.]]></description>
		<lastBuildDate>Mon, 13 Nov 2017 20:02:53 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: init.d: process ID samba]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6202#p6202</link>
			<description><![CDATA[<p>Resolved ;-)</p><div class="codebox"><pre class="vscroll"><code>#!/bin/sh

### BEGIN INIT INFO
# Provides:          samba
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start Samba daemons for the AD DC
### END INIT INFO

#
# Start/stops the Samba daemon (samba).
# Adapted from the Samba 3 packages.
#

# clear conflicting settings from the environment
unset TMPDIR

# See if the daemon and the config file are there
test -x /opt/samba/sbin/samba -a -r /opt/samba/etc/smb.conf || exit 0

. /lib/lsb/init-functions

case &quot;$1&quot; in
        start)
                SERVER_ROLE=`/opt/samba/bin/samba-tool testparm --parameter-name=&quot;server role&quot;  2&gt;/dev/null | tail -1`
                if [ &quot;$SERVER_ROLE&quot; != &quot;active directory domain controller&quot; ]; then
                    exit 0
                fi

                if init_is_upstart; then
                        exit 1
                fi

                # CVE-2013-4475
                KEYFILE=/opt/samba/private/tls/key.pem
                if [ -e $KEYFILE ]
                then
                                KEYPERMS=`stat -c %a $KEYFILE`
                                if [ &quot;$KEYPERMS&quot; != &quot;600&quot; ]
                                then
                                                echo &quot;wrong permission on $KEYFILE, must be 600&quot;
                                                echo &quot;samba will not start (CVE-2013-4475)&quot;
                                                echo &quot;Removing all tls .pem files will cause an auto-regeneration with the correct permissions.&quot;
                                                exit 1
                                fi
                fi

                log_daemon_msg &quot;Starting Samba AD DC daemon&quot; &quot;samba&quot;

                if ! start-stop-daemon --start --quiet --oknodo --exec /opt/samba/sbin/samba -- -D; then
                        log_end_msg 1
                        exit 1
                fi
                log_end_msg 0
                ;;
        stop)
                if init_is_upstart; then
                        exit 0
                fi
                log_daemon_msg &quot;Stopping Samba AD DC daemon&quot; &quot;samba&quot;

                start-stop-daemon --stop --quiet --pidfile /opt/samba/var/run/samba.pid

                log_end_msg 0

                ;;
        restart|force-reload)
                if init_is_upstart; then
                        exit 1
                fi
                $0 stop
                sleep 1
                $0 start
                ;;
        status)
                status_of_proc -p /opt/samba/var/run/samba.pid /opt/samba/sbin/samba samba
                exit $?
                ;;
        *)
                echo &quot;Usage: /etc/init.d/samba {start|stop|restart|force-reload|status}&quot;
                exit 1
                ;;
esac

exit 0</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (bouke)]]></author>
			<pubDate>Mon, 13 Nov 2017 20:02:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6202#p6202</guid>
		</item>
		<item>
			<title><![CDATA[init.d: process ID samba]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6193#p6193</link>
			<description><![CDATA[<p>Hello,</p><p>I managed to compile and install samba 4 on Devuan. I am not that good with bash/sh scripts - I am hoping someone could help.</p><p>The problem is that the PID written to the PID file is 1 digit lower than expected. For some reason I have to increase the PID with 1.</p><p>I have found a init.d file which did not work. I had to change some bits and commented some chunks out. The problematic part is the following.</p><div class="codebox"><pre><code>                if ! start-stop-daemon --start --quiet --pidfile $SAMBAPID --make-pidfile --oknodo --exec /opt/samba/sbin/samba -- -D; then
                        log_end_msg 1
                        exit 1
                fi
                log_end_msg 0
                ;;</code></pre></div><p>The pidfile is created but when I run &quot;ps ax | grep samba&quot; the first process ID does not represent the number found in the pidfile. This means that the &quot;status&quot;, &quot;stop&quot; and &quot;restart&quot; functions do not work.</p><p>However, when I increment the process ID in the pidfile with 1, I am able to print the status and stop Samba (somewhat) gracefully. </p><p>I would like to know how I could fix this issue. Should I just increment the number found in the pidfile (and how) or should I choose for a different approach?</p><p>I have copied the full init.d file below. </p><p>Many thanks for your help.</p><div class="codebox"><pre class="vscroll"><code>#!/bin/sh

### BEGIN INIT INFO
# Provides:          samba
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start Samba daemons for the AD DC
### END INIT INFO

#
# Start/stops the Samba daemon (samba).
# Adapted from the Samba 3 packages.
#

PIDDIR=/var/run/samba
SAMBAPID=$PIDDIR/samba.pid

# clear conflicting settings from the environment
unset TMPDIR

# See if the daemon and the config file are there
test -x /opt/samba/sbin/samba -a -r /opt/samba/etc/smb.conf || exit 0

. /lib/lsb/init-functions

case &quot;$1&quot; in
        start)
#               SERVER_ROLE=`samba-tool testparm --parameter-name=&quot;server role&quot;  2&gt;/dev/null | tail -1`
#               if [ &quot;$SERVER_ROLE&quot; != &quot;active directory domain controller&quot; ]; then
#                   exit 0
#               fi
#
#               if init_is_upstart; then
#                       exit 1
#               fi

#               # CVE-2013-4475
#               KEYFILE=/opt/samba/private/tls/key.pem
#               if [ -e $KEYFILE ]
#               then
#                               KEYPERMS=`stat -c %a $KEYFILE`
#                               if [ &quot;$KEYPERMS&quot; != &quot;600&quot; ]
#                               then
#                                               echo &quot;wrong permission on $KEYFILE, must be 600&quot;
#                                               echo &quot;samba will not start (CVE-2013-4475)&quot;
#                                               echo &quot;Removing all tls .pem files will cause an auto-regeneration with the correct permissions.&quot;
#                                               exit 1
#                               fi
#               fi

                log_daemon_msg &quot;Starting Samba AD DC daemon&quot; &quot;samba&quot;
                # Make sure we have our PIDDIR, even if it&#039;s on a tmpfs
                install -o root -g root -m 755 -d $PIDDIR

                if ! start-stop-daemon --start --quiet --pidfile $SAMBAPID --make-pidfile --oknodo --exec /opt/samba/sbin/samba -- -D; then
                        log_end_msg 1
                        exit 1
                fi
                log_end_msg 0
                ;;
        stop)
                if init_is_upstart; then
                        exit 0
                fi
                log_daemon_msg &quot;Stopping Samba AD DC daemon&quot; &quot;samba&quot;

                start-stop-daemon --stop --quiet --pidfile $SAMBAPID
                #sometimes samba does not stop...
                 sleep 3
                 pkill samba
                # Wait a little and remove stale PID file
                sleep 1
                if [ -f $SAMBAPID ] &amp;&amp; ! ps h `cat $SAMBAPID` &gt; /dev/null
                then
                        # Stale PID file (samba was succesfully stopped),
                        # remove it (should be removed by samba itself IMHO.)
                        rm -f $SAMBAPID
                fi

                log_end_msg 0

                ;;
        restart|force-reload)
                if init_is_upstart; then
                        exit 1
                fi
                $0 stop
                sleep 1
                $0 start
                ;;
        status)
                status_of_proc -p $SAMBAPID /opt/samba/sbin/samba samba
                exit $?
                ;;
        *)
                echo &quot;Usage: /etc/init.d/samba {start|stop|restart|force-reload|status}&quot;
                exit 1
                ;;
esac

exit 0</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (bouke)]]></author>
			<pubDate>Sun, 12 Nov 2017 22:07:32 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6193#p6193</guid>
		</item>
	</channel>
</rss>
