Создадим скрипт для запуска и остановки службы Samba.

touch /etc/init.d/samba4
chmod +x /etc/init.d/samba4

Добавим в него следующее содержимое.

#!/bin/sh

 ### BEGIN INIT INFO
 # Provides:          samba
 # Required-Start:    $network $local_fs $remote_fs
 # Required-Stop:     $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Should-Start:      slapd
 # Should-Stop:       slapd
 # Short-Description: start Samba daemon (samba)
 ### END INIT INFO

 PIDDIR=/usr/local/samba/var/run
 SAMBADPID=$PIDDIR/samba.pid

 # clear conflicting settings from the environment
 unset TMPDIR

 # See if the daemons are there
 test -x /usr/local/samba/sbin/samba || exit 0

 # Starting init-fuctions for Debian -shell script
 . /lib/lsb/init-functions

 case "$1" in
        start)
                log_daemon_msg "Starting Samba daemon"
                # Make sure we have our PIDDIR, even if it's on a tmpfs
                install -o root -g root -m 755 -d $PIDDIR

                SAMBA_DISABLED=`testparm -s --parameter-name='disable netbios' 2>/dev/null`
                if [ "$SAMBA_DISABLED" != 'Yes' ]; then
                        log_progress_msg "samba"
                        if ! start-stop-daemon --start --quiet --oknodo --exec /usr/local/samba/sbin/samba -- -D
                        then
                                log_end_msg 1
                                exit 1
                        fi
                fi

                log_end_msg 0
                ;;
        stop)
                log_daemon_msg "Stopping Samba daemon"
                log_progress_msg "samba"

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

                log_end_msg 0

                ;;
        reload)
        log_daemon_msg "Reloading /usr/local/samba/etc/smb.conf "
                start-stop-daemon --stop --signal HUP --pidfile $SAMBADPID
                log_end_msg 0
                ;;
        restart|force-reload)
                $0 stop
                sleep 1
                $0 start
                ;;
        *)
                echo "Usage: /etc/init.d/samba4 {start|stop|reload|restart|force-reload}"
                exit 1
                ;;
 esac

 exit 0

Попробуем запустить Samba.

# /etc/init.d/samba4 start
 * Starting Samba daemon                                                 [ OK ] 

Добавим службу в автозагрузку.

# update-rc.d samba4 defaults
update-rc.d: warning: /etc/init.d/samba4 missing LSB information
update-rc.d: see 
 Adding system startup for /etc/init.d/samba4 ...
   /etc/rc0.d/K20samba4 -> ../init.d/samba4
   /etc/rc1.d/K20samba4 -> ../init.d/samba4
   /etc/rc6.d/K20samba4 -> ../init.d/samba4
   /etc/rc2.d/S20samba4 -> ../init.d/samba4
   /etc/rc3.d/S20samba4 -> ../init.d/samba4
   /etc/rc4.d/S20samba4 -> ../init.d/samba4
   /etc/rc5.d/S20samba4 -> ../init.d/samba4

Перезагрузим сервер.

# reboot

Проверим, запустилась ли Samba.

# ps ax | grep samba
  467 ?        S      0:00 avahi-daemon: running [samba.local]
 1135 ?        Ss     0:01 /usr/local/samba/sbin/samba -D
 1207 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1208 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1209 ?        Ss     0:01 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground
 1210 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1211 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1212 ?        S      0:02 /usr/local/samba/sbin/samba -D
 1213 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1214 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1215 ?        S      0:01 /usr/local/samba/sbin/samba -D
 1216 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1217 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1218 ?        S      0:01 /usr/local/samba/sbin/samba -D
 1219 ?        S      0:00 /usr/local/samba/sbin/samba -D
 1222 ?        S      0:00 /usr/local/samba/sbin/smbd -D --option=server role check:inhibit=yes --foreground
 1599 pts/0    S+     0:00 grep --color=auto samba