#!/bin/sh DAEMON=samba DAEMON_LOMG_NAME=Samba DAEMON_CONFIG=/mod/etc/samba/smb.conf . /etc/init.d/modlibrc create_rc() { #creates /mod/etc/init.d/rc.(smbd|nmbd) if [ "$(modconf value MOD_EXTERNAL_BEHAVIOUR mod)" != "copy" ]; then #link local link="$(readlink /mod/etc/init.d/rc.samba)" if [ "$link" != "$(readlink /mod/etc/init.d/rc.$1)" ]; then rm -rf /mod/etc/init.d/rc.$1 2>/dev/null ln -s ${link%samba}$1 /mod/etc/init.d/rc.$1 fi else #copy if [ ! -f /mod/etc/init.d/rc.$1 ]; then rm -rf /mod/etc/init.d/rc.$1 2>/dev/null cp /mod/external/etc/init.d/rc.$1 /mod/etc/init.d/rc.$1 fi fi } do_smbd() { create_rc smbd /mod/etc/init.d/rc.smbd $1 } do_nmbd() { create_rc nmbd [ -x "$(which nmbd)" -o -L "$(which nmbd)" ] && /mod/etc/init.d/rc.nmbd $1 } config() { mkdir -p /mod/etc/samba modlib_config # create users.map, if needed local USERS_MAP=/mod/etc/samba/users.map if [ -z "$SAMBA_USER" -o "$SAMBA_SYSTEMUSER" == "$SAMBA_USER" ]; then echo > $USERS_MAP else echo "$SAMBA_SYSTEMUSER = \"$SAMBA_USER\"" > $USERS_MAP fi # encrypt password local PASS_FILE=/mod/etc/samba/smbpasswd rm -rf $PASS_FILE 2>/dev/null if which smbpasswd >/dev/null; then if [ -s /tmp/flash/samba/smbpasswd ]; then cat /tmp/flash/samba/smbpasswd > $PASS_FILE elif [ -n "$SAMBA_PASS" ]; then local CLEAR_FILE=/var/tmp/smbpasswd.cleartext local SAMBA_UID="$(id -u $SAMBA_SYSTEMUSER)" echo "$SAMBA_SYSTEMUSER:$SAMBA_UID:$SAMBA_PASS:[UX ]:LCT-00000001:" > $CLEAR_FILE smbpasswd 2>/dev/null rm $CLEAR_FILE # make sure a password is set if [ ! -r $PASS_FILE ]; then echo "can not encrypt password, failed." exit 1 fi else # samba complains if the file does not exist touch $PASS_FILE fi fi return } case $1 in ""|load) mkdir -p /tmp/flash/samba mkdir -p /var/locks modlib_addgroup users modlib_adduser ftpuser -G users -D -S -h "/var/media/ftp" -g "ftpuser" modreg cgi samba "Samba" modreg file samba shares '$(lang de:"Freigaben" en:"Shares")' 1 "shares" modreg file samba sharesx '$(lang de:"Erweitert" en:"Options")' 1 "sharesx" modreg daemon --hide samba do_nmbd do_smbd ;; unload) modunreg daemon $DAEMON modunreg file samba modunreg cgi samba do_smbd unload do_nmbd unload rm -rf /mod/etc/init.d/rc.smbd /mod/etc/init.d/rc.nmbd 2>/dev/null ;; start) do_nmbd start do_smbd start ;; stop) do_smbd stop do_nmbd stop ;; restart) do_smbd stop do_nmbd stop do_nmbd start do_smbd start ;; reload) do_nmbd reload do_smbd reload ;; status) echo "unavailable" exit 1 ;; status_smbd) do_smbd status ;; config) config ;; *) echo "Usage: $0 [load|unload|start|stop|restart|reload|status|config]" 1>&2 exit 1 ;; esac exit 0