#!/bin/sh DAEMON=samba DAEMON_LOMG_NAME=Samba DAEMON_CONFIG=/mod/etc/samba/smb.conf . /etc/init.d/modlibrc do_smbd() { /etc/init.d/rc.smbd $1 } do_nmbd() { [ -x "$(which nmbd)" -o -L "$(which nmbd)" ] && /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 ;; 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