WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: samba3.tcz init.d script wrong permissions and no exit codes  (Read 1732 times)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
TC-7.2 x86

/usr/local/etc/init.d/samba  currently has permissions 754 (needs 755) thus Samba cannot be started via  services  tool if that wasn't started with root privileges.
Furthermore, the  status()  function of  /usr/local/etc/init.d/samba  isn't using exit codes so  services  tool doesn't know about it's actual status.

This is the init.d script I'm currently using.
Code: [Select]
#!/bin/sh

start() {
if [ ! -d /var/lib/samba ]; then
mkdir -p /var/lib/samba
fi
if [ ! -d /usr/local/etc/samba/private ]; then
mkdir -p /usr/local/etc/samba/private
fi
if [ ! -e /var/run/nmbd.pid ]; then
/usr/local/sbin/nmbd -D
fi
if [ ! -e /var/run/smbd.pid ]; then
/usr/local/sbin/smbd -D
fi
}

stop() {
killall nmbd 2>/dev/null
if [ -e /var/run/nmbd.pid ]; then
rm /var/run/nmbd.pid 2>/dev/null
fi
killall smbd 2>/dev/null
if [ -e /var/run/smbd.pid ]; then
rm /var/run/smbd.pid 2>/dev/null
fi
}

status() {
if [ -e /var/run/smbd.pid ]; then
echo -e "\nsmbd is running.\n"
else
echo -e "\nsmbd is not running.\n"
exit 1
fi
if [ -e /var/run/nmbd.pid ]; then
echo -e "\nnmbd is running.\n"
else
echo -e "\nnmbd is not running.\n"
exit 1
fi
exit 0
}

case $1 in
start) start
;;
stop) stop
;;
status) status
;;
restart) stop; start
;;
*) echo -e "\n$0 [start|stop|restart|status]\n"
;;
esac


Note: It also deletes  /var/run/smbd.pid  in addition to  /var/run/nmbd.pid .
Not sure if needed.
Download a copy and keep it handy: Core book ;)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: samba3.tcz init.d script wrong permissions and no exit codes
« Reply #1 on: July 27, 2016, 08:52:03 AM »
samba3 extension updated and your suggestions added - thanks