Tiny Core Linux

Tiny Core Extensions => TCE Bugs => Topic started by: Misalf on July 27, 2016, 03:51:26 AM

Title: samba3.tcz init.d script wrong permissions and no exit codes
Post by: Misalf on July 27, 2016, 03:51:26 AM
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.
Title: Re: samba3.tcz init.d script wrong permissions and no exit codes
Post by: Juanito on July 27, 2016, 05:52:03 AM
samba3 extension updated and your suggestions added - thanks