FreeNAS CIFS/Samba changing Guest Account ‘FTP’ not working

Using FreeNAS 0.7 Khasadar (revision 4919) with CIFS/SMB Authentication Anonymous, I changed the Guest account for but it is not actually applying it to the configuration, it is a trivial bug and here’s a small dirty workaround.

1 – Create an excutable file containing this:

[bash]
#!/bin/sh

# find and replace ‘ftp’ by ‘transmission’
sed -i. ‘s/ftp/transmission/g’ /etc/rc.d/samba

# restart samba to use the new config
/etc/rc.d/samba restart
[/bash]

2 – Go in System|Advanced|Command scripts and add an entry for your script in “PostInit”

For those who are interested, I am doing this because my network is not accessible from the outside and I didn’t want to bother with user privileges. I am using my FreeNAS box to share media files downloaded using Transmission and I wanted everybody to be able to access/modify/delete them, so I change the guest account to be “transmission” 🙂

Tip: use rsync to convert filenames from/to UTF-8 latin-1/ISO-8859-1

This will copy files with UTF-8 encoded characters filenames to new files with a ISO-8859-1 encoded filenames and, when everything is completed, will delete the old (UTF-8) files.

BE CAREFUL THIS IS NOT FOOL PROOF 🙂 YOU MUST KNOW WHAT YOU ARE DOING TO NOT DOUBLE ENCODE THE CHARACTERS FILENAMES.

rsync SOURCE SAMEFORDESTINATION --recursive --human-readable --stats --times --progress --iconv=utf8,iso88591 --delete-after

To do the opposite change the iconv switch to: --iconv=iso88591,utf8

Note: If you run rsync as root, you can use --owner --group to keep the same user.group for the copied files.

FreeNAS (embedded) iconv command

To install iconv on a “data” parition:

export PKG_TMPDIR=/mnt/usb-data/temp
pkg_add -r iconv -P /mnt/usb-data/pkg

And execute this at boot time:

ln -s /mnt/usb-data/pkg/bin/iconv /bin/iconv

Useful tools in an “embedded” FreeNAS: wget and bash

wget

To install wget on a “data” parition:

export PKG_TMPDIR=/mnt/usb-data/temp
pkg_add -r wget -P /mnt/usb-data/pkg

Now we need a script to create the symlinks to the wget binaries in the “pkg” directory:

nano /mnt/usb-data/hooks.sh

Here’s the content:

#!/bin/sh

ln -s /mnt/usb-data/pkg/bin/wget /bin/wget

Now make it run at boot time, go in System —> Advanced —> Command scripts and enter:

/mnt/usb-data/hooks.sh

Select PostInit and that’s it! Everytime you reboot your FreeNAS server the symlinks will be re-created!

bash

For bash, add this in the “hooks.sh” script:

# .bashrc for root
ln -s /mnt/usb-data/bashrc /root/.bashrc

# .bashrc for regular user
ln -s /mnt/usb-data/bashrc /mnt/.bashrc

# automatically load bash for root on login (not clean but works)
echo "bash --init-file /mnt/usb-data/bashrc" >> /root/.cshrc

# automatically load bash for regular user on login (not clean but works)
echo "bash --init-file /mnt/usb-data/bashrc" >> /mnt/.cshrc

Vim (Vi IMproved) in an “embedded” FreeNAS

You need an embedded install with a data partition. My FreeNAS server runs from a 1GB usb stick and the data partition is mounted as “/mnt/usb-data”. To install Vim on the usb stick:

# using csh
setenv PKG_TMPDIR /mnt/usb-data/temp

# install package
pkg_add -r vim-lite -P /mnt/usb-data/pkg

Now we need a script to create the symlinks to the Vim binaries in the “pkg” directory:

nano /mnt/usb-data/hooks.sh

Here’s the content:

[bash]#!/bin/sh

# Vim symlinks to binaries
ln -s /mnt/usb-data/pkg/bin/vim /bin/vi
ln -s /mnt/usb-data/pkg/bin/vim /bin/vim

# .vimrc for root
ln -s /mnt/usb-data/pkg/share/vim/vim72/vimrc_example.vim /root/.vimrc
# .vimrc for regular user
ln -s /mnt/usb-data/pkg/share/vim/vim72/vimrc_example.vim /mnt/.vimrc

# syntax file
mkdir /usr/local/share/vim/
mkdir /usr/local/share/vim/syntax/
ln -s /mnt/usb-data/pkg/share/vim/vim72/syntax/syntax.vim /usr/local/share/vim/syntax/syntax.vim[/bash]

Now make it run at boot time, go in System —> Advanced —> Command scripts and enter:

/mnt/usb-data/hooks.sh

Select PostInit and that’s it! Everytime you reboot your FreeNAS server the symlinks will be re-created!