Vim (Vi IMproved) in an “embedded” FreeNAS

gimpe » 03 August 2009 » In FreeNAS, bash »

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:

#!/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

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!

Tags: ,

Trackback URL

3 Comments on "Vim (Vi IMproved) in an “embedded” FreeNAS"

  1. gimpe
    gimpe
    03/08/2009 at 22:08 Permalink

    You can to the same thing for “wget”:

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

    Add this to the “hooks.sh” script:

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

  2. gimpe
    gimpe
    03/08/2009 at 22:40 Permalink

    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

Trackbacks

  1. [...] hype-o-thetic?com » VIM in “embedded” FreeNAS [...]

Hi Stranger, leave a comment:

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to Comments