fun_plug

fun_plug is the name of a script that will run after the DNS323 has booted (see fun_plug).

The fonz fun_plug (ffp) is a fun_plug script plus a collection of applications compiled and packaged by fonz. The system uses the DNS-323 fun_plug capability to hook your own start procedures to the startup.

To get started, read the README for current information.

Homepage: http://www.inreto.de/dns323/fun-plug/

There are also a number of blogs with helpful articles on the DNS-323 and fun_plug (listed in no particular order):

Version 0.5

Links

Homepage: http://www.inreto.de/dns323/fun-plug/0.5

README: http://www.inreto.de/dns323/fun-plug/0.5/README.txt

ChangeLog: http://www.inreto.de/dns323/fun-plug/0.5/ChangeLog.txt

Packages: http://www.inreto.de/dns323/fun-plug/0.5/packages

Sources:

  • Check out source tree from subversion:
svn co svn://inreto.de/svn/dns323/funplug/trunk funplug
  • See funplug/sources/README.txt for instructions

Installation

To install:

  • download the fun_plug (if called fun_plug.sh rename fun_plug)
  • download fun_plug.tgz files to Volume 1 (this may appear as a symbolic link). Do not unpack.
  • chmod fun_plug.sh 777 (or at least 744)
  • reboot (Configuation > Tools > System > Restart)

If successful, the fun_plug.tgz file is unpacked (ffp directory) and deleted. A telnet server is started automatically.

If you have only one disk in your DNS-323 or CH3SNAS, it should be in the right slot.

First Access

The first access to the unit's Linux prompt, after ffp has been installed, is done via telnet without any username or password. This gets you logged in as root. You may choose to install SSH and set a root password after this initial access, and should probably do so immediately if you're not on a secured network. A telnet client utility is available by default in Windows XP and in most Linux workstations, but it's missing from Windows Vista and notably not available in Cygwin at all. Windows Vista has a telnet client which is disabled by default but can be enabled easily in Control Panel → Programs → Programs And Features → Turn Windows features on or off → Telnet Client.

Upgrading from 0.3/0.4

The recommend upgrade method is to reinstall. Except for the fun_plug script, 0.5 will not overwrite any files of your 0.3/0.4 funplug. After successful installation of 0.5, you can cleanup your 0.3/0.4 files:

cd /mnt/HD_a2
rm -rf fun_plug.d

Upgrading packages

If you want to upgrade packages, use

cd /path/to/new/packages
funpkg -u package-file.tgz

This will install the new version and remove any now obsolete files from the old version.

WARNING: Any configuration files, start scripts, etc will be overwritten with the versions in the new package. If you want to keep your changes, you need to backup your custom files and restore them after the upgrade. A simple way to create backups of your config files and start scripts is:

cd /ffp
mkdir my-etc my-start
cp -ar etc/* my-etc
cp -ar start/* my-start

If you want to restore one or more files, e.g. the ssh config files:

cd /ffp
cp -ar my-etc/ssh etc

The root user

'root' is the system administrator on Linux. A lot of tasks require root permissions, it's essential to have a working root account.

The firmware comes with a disabled root account that cannot login the 'normal' way. For this reason, the funplug starts an open telnet server that circumvents the normal login procedure to provide a root shell directly.

To fix the root account, set a password and test login:

passwd
login

If that worked, save the password to flash memory:

store-passwd.sh

To enable login for telnet, edit the telnetd.sh start script and remove the '-l /ffp/bin/sh' option. You can do this from the command line like this:

cd /ffp/start
sed -i '/flags/ s@^@#@' telnetd.sh

Restarting telnet while logged in via telnet requires special care (the telnet session will be aborted!):

cd /tmp
nohup sh /ffp/start/telnetd.sh restart

Alternatively, you can disable telnet and start the SSH server instead. First, test ssh login:

cd /ffp/start
sh sshd.sh start

Login from a remote host now (as root, of course). If it works, disable telnet and enable sshd permanently:

cd /ffp/start
chmod a-x telnetd.sh
chmod a+x sshd.sh

root without password. If you want to use the normal login to benefit from the better environment, but don't want to set a real password for root, you can remove root's password (login won't even ask for a password, then):

usermod -p '' root

This can easily be added to a start script. WARNING: ssh does not allow root to login without a password.


Help, Howtos, Guides, Discussions

Lighttpd Web Server

Before starting lighttpd, you need to create a config file. To get started, just copy the example config and create the essential directories:

cd /ffp/etc
cp examples/lighttpd.conf .
cd /mnt/HD_a2
mkdir -p www/logs www/pages
sh /ffp/start/lighttpd.sh start

For detail regarding server security see http://forum.dsmg600.info/t793-Request-secure-setup-info-lighttpd.html

This will start the web server on port 8080. Copy your web files to the www/pages directory. Log files are written to www/logs.

PHP

To enable PHP, you need to install the php package and use the lighttpd.conf-with-php example config:

funpkg -i /path/to/php-xxxxx.tgz
cd /ffp/etc
cp examples/lighttpd.conf-with-php lighttpd.conf
sh /ffp/start/lighttpd.sh restart
Port 80

The example config files start lighttpd on port 8080, because the default HTTP port 80 is used by the administration interface (goahead web server). Using a little trick, you can move goahead to port 81 and run lighttpd on port 80: http://forum.dsmg600.info/t246-Change-http-port.html

To setup your lighttpd for port 80, disable the server.port directive in lighttpd.conf, and activate the kickwebs.sh and lighttpd.sh start scripts:

cd /ffp/etc
sed -i '/server.port/ s/^/#/' lighttpd.conf
cd /ffp/start
chmod a+x kickwebs.sh lighttpd.sh

After reboot, lighttpd should run on port 80. To manually activate the changes, run (in quick succession):

cd /ffp/start
sh kickwebs.sh start
sh lighttpd.sh restart

Note that the above will kill the goahead web server process. It will restart automatically, but this may take a few minutes.


OpenSSH Secure Shell Server

To start openssh, just run:

sh /ffp/start/sshd.sh start

On the first start, it will create the essential key files (may take a minute or two).

SSH sessions will start into the shell configured for the user in /etc/passwd. This defaults to the firmware's busybox shell /bin/sh (enter 5784468 to get a shell prompt).

The funplug includes tools to automatically change /etc/passwd and /etc/shadow:

  • start/passwd.sh can replace /bin/sh with /ffp/bin/sh for all users at startup.
  • start/pwconv.sh will add missing users to /etc/shadow
  • start/shells.sh will add /ffp/bin/sh and /ffp/bin/bash to /etc/shells

As root, you can manually change the login shell for user bob:

chsh -s /ffp/bin/bash bob

If you receive

WARNING: Your password has expired. You must change your password now and login again!

messages on login, try if running 'pwconv' (as root) fixes it. See also: http://forum.dsmg600.info/p13142-2008-04-08-12%3A59%3A43.html#p13142

To make your changes permanent, you can store the updated passwd and shadow files to flash memory (TEST YOUR CHANGES BEFORE DOING THIS!!):

store-passwd.sh

Alternatively, you can store your modified passwd and shadow files in /ffp/etc/ and copy them to /etc on every startup. There's not start script included for this, yet.


NTP Network Time Protocol

Before starting ntpd, you need to create a config file. To get started, just copy and edit the example config:

cd /ffp/etc
cp examples/ntp.conf .
vi ntp.conf

Unless you live in Germany, you should change the four server entries. If in doubt, remove '.de' from each line:

server 0.pool.ntp.org iburst
...

See also: http://www.pool.ntp.org/use.html

On my DNS-323, the clock drift is too large for ntpd and needs additional changes. The start/adjtimex.sh script is included to fix clock drift by adjusting the ticks value.

cd /ffp/start
chmod a+x adjtimex.sh ntpd.sh
sh adjtimex.sh start
sh ntpd.sh start

Check synchronization status with

ntpq -p

ntpd will write a drift file /ffp/etc/ntp.drift (may take a few hours until it's written the first time). If it contains 500 or -500, your clock drift is still too large for ntpd.


Mediatomb UPnP Media Server

The included mediatomb server will search media files in /mnt/HD_a2/home/media. If you have you files in a different location, edit /ffp/start/mediatomb.sh and change the media_dir variable.

Start mediatomb with:

sh /ffp/start/mediatomb.sh start

To make it automatically start after reboot:

cd /ffp/start
chmod a+x mediatomb.sh

The mediatomb configuration web interface starts on port 49152: http://bob:49152/ The mediatomb config.xml is in /ffp/var/mediatomb/


NFS Network File System

Two NFS servers are included:

  • UNFS3 is a user-space NFS server that does not require kernel support
  • NFS-utils contains required utilities to activate a kernel NFS server (Kernel-level NFS support is available on the CH3SNAS, and not on the DNS-323 unless you install your own kernel). More information can be found in the Linux NFS-HOWTO at http://nfs.sourceforge.net/nfs-howto/

To start unfs3, run:

sh /ffp/start/unfsd.sh start

To start the kernel-level NFS server:

sh /ffp/start/nfsd.sh start

On the first start, a default exports file is created in /ffp/etc (and a symlink in /etc).

Note that the exports file differs slightly between unfsd and nfsd. Before switching NFS servers, you should remove the exports file.


Versions 0.3/0.4

Help, Howtos, Guides, Discussions

There's a lot of useful information in the forum and in various blogs. If you find a good guide, please add it to the list.

Backup:

Bittorrent:

Cleanboot (Proper shutdown): cleanboot 1.0 for DNS-323 / CH3SNAS by pof

DynDNS: Utilities for D-link DNS-323 NAS

File System Checks: Modified fun_plug for disk maintenance by skydreamer

FUSE (File System in User Space): Fuse packages for fonz fun_plug by pof

Lighttpd (Web Server): Turning on authentication in lighttpd by shadowandy

Llink (Media Streamer): Compiled & working: llink, media streamer for Syabas based mp's by hps

MediaTomb (UPnP A/V Server) Compiled & working: Mediatomb! by HaydnH

Midnight commander MP (File Manager) Midnight commander by jules

MySQL: MySQL on DNS-323 by petter

Ncurses (Terminal library): http://www.bitmuse.com/funplug/

NFS (Network File System): Full instruction s on how to install NFS on my DNS-323 by moquilok

OpenVPN (Virtual Private Networks): Compiled & Working: OpenVPN by HaydnH

SSH:

Subversion:

timezone.sh: DNS-323 Time Sync with funplug-0.3 timezone.sh

UnRAR: unrar for the DNS-323

USB Storage: Attaching USB Storage to the DNS-323 for Linux Newbies & Dummies by DNS323-Talker


Navigation

Personal Tools