
===============================================================================
 raydon's Media and File Server Bundle for the Humax FoxsatHDR - Release v4.1.3
===============================================================================

This rar archive contains everything necessary to set up the Humax Foxsat HDR as a fully functioning Media and File Server.
There are some major changes and additions to the earlier v3.0  releases, so please read this document carefully before starting.
(it maybe worthwhile printing it out for reference) 

New Features in v4.0.x 
----------------------
(1) A fully functioning web interface for the Foxsat HDR.

(2) A package management system with web based repository for the downloading and updating of applications.
    This can be accessed both from the web interface and from the command line.

(3) A service management system to display status of custom applications, start or stop them, and disable/enable boot-time autostart. 
    Again, this is accessible from the web interface and the command line.


The file named 'FOXSAT-HDR_upgrade.hdf' is the firmware upgrade which provides the platform on which custom application software
packages can then be installed. It also provides the means to start these custom applications automatically at boot time. 

NOTE:
This firmware is based on Humax's v1.00.21 release and is a complete standalone replacement for it.
This means that a reflash with the latest Humax firmware before flashing with this one is NOT necessary.
It will upgrade any earlier version of installed firmware, either standard or modified, to v1.00.21 custom.

This release maintains the custom directory structure on the hd4 partition, as per the earlier versions.
However, several applications in this latest release have dependencies on others in order to function correctly.
This is all taken care of by the package management system, which also tracks which applications are installed, and what is available
to be installed or upgraded. For this reason v4.x.x is NOT backwards compatible with any of the earlier releases.


Firmware installation.
----------------------
Note
----
Please be aware that not all USB sticks are compatible with the HDR when used to flash the firmware.
Experience has proven that the smaller sizes, formatted as single partition FAT32 work best.   

Copy the 'FOXSAT-HDR_upgrade.hdf' file to the root directory of a USB stick.
Turn on your TV and set the video source to the HDR.
Put the HDR into standby then insert the USB stick into the front USB port.
Press, and continue to hold down the standby button on the HDR's front panel, NOT the standby button on the remote control.
The front panel display will initially show 'BOOT' followed by an incrementing series of numbers preceded by 'P', at which time the TV
will display the upgrade progress bar. You can now safely release the standby button.
Once the upgrade is completed the front panel display will show 'END' and you will be prompted to press the standby button.
Press the standby button. 

Note:There should be no need to power cycle the HDR via the rear rocker switch, but some users have reported needing to do this.

After approximately 30 seconds the 'END' message will disappear and the box will power down by itself.
At this point you can press the standby button once more to boot up the HDR normally.
Now, on each startup just after the word 'BOOT' appears in the front panel display, a message stating the custom firmware version will be shown.
This will confirm that you are running the custom firware. 

The directory structure created on the HDR under /mnt/hd4 looks like this:

Existing folders
----------------
/mnt/hd4/Music
/mnt/hd4/Photos

New Folders
-----------
/mnt/hd4/opt/bin
/mnt/hd4/opt/sbin
/mnt/hd4/opt/etc/init.d
/mnt/hd4/opt/var/opkg
/mnt/hd4/opt/tmp

directory "/mnt/hd4/opt" is mounted at boot-time as "/opt" and so can be accessed directly. i.e. "cd /opt"

These custom folders cannot be seen at all from the HDR, and can only be accessed via Telnet or FTP, or Samba.
This prevents inadvertent erasure of essential files and folders by other family members.

The "/opt" is root directory in which all custom applications are placed.

The "/opt/etc" directory is where configuration files are stored.

The "/opt/etc/init.d" directory contains scripts to auto start custom applications.
 
The "/opt/bin" and "opt/sbin" are directories where application binaries are placed,
or binaries to extend the functionality of the OS.
These folders are included in the $PATH environment variable.
Anything placed in them can be executed directly, without the need to specify a path. 

The "/opt/var/opkg" is where the opkg package management stores it's configuration files.
Don't modify or delete anything in here ! 

The "/opt/tmp" directory is a temporary storage directory used by opkg-tools.

Software Package Installation
=============================
Install from Web Interface
--------------------------
This is the simplest way to manage your custom applications on the HDR.
Once you have installed the full web interface it's simply the matter of a few mouse clicks to  install/upgrade or uninstall
your custom applications directly from your favourite web browser. 
The firmware comes with a tiny web server pre-installed. In order to access this server you must first 
determine the IP address of your HDR from the HDR's Menu/System/Network screen. (It will look something like 192.168.0.8)
Enter this IP address into the address bar of your browser and you should be greeted by the HDR's initial web page.
From there you have the option to install the full web interface from which you can complete your application software installs.
A reboot of the HDR will be required to initialise the full web interface once it has installed. 
IMPORTANT: Refresh your browser when connecting to the full web interface for the first time, and ensure the address is set
to the HDR's IP address (without any page name appended)

Install from command line
-------------------------
As an alternative, you can install packages from the command line via a telnet session. 
To do this you must first install the telnet application included in the .rar archive using the USB install method outlined below.
Once telnet is installed, ensure you are connected to the internet, then from the command line enter:

'opkg update'		This will download the latest list of available packages from the repository.
'opkg list'		This will list all available packages.
'opkg install vsftpd'	This will install the 'Very-Secure-FTP-Daemon' package.
'opkg remove vsftpd'	This will remove it again.
   
Install from USB
----------------
The USB port is hot pluggable, so you can initiate an install while the HDR is powered up simply by plugging in a USB stick
containing one or more .opk package files in the root directory.
Once installed, the application will be available for use immediately. No reboot is necessary.
Just wait for the USB stick activity LED to stop (providing it has one). Otherwise just wait a few minutes before
unplugging the stick. When the install has completed the *.opk file will have been renamed to *.opk.done and a log file
named *.opk.install.log created, for each package on the USB stick. 
 

CUSTOM APPLICATIONS
===================

Pre-installed (i.e. embedded in firmware)
=========================================

Maintenance Mode - 'fix-disk' check and repair utility
------------------------------------------------------
Maintenance Mode was introduced in v4.0.9 release of the firmware. In this mode the HDR is booted with bare minimum processes running. i.e. No set top box functionality.
This provides maximum memory resources to the partition check utility and allows hard disk partitions normally in use to be unmounted for checking.
Partition check and repair is facilitated by a suite of binary tools, plus a helper script to do the hard work for you. 

This version contains a recompiled linux kernel which has swap file support enabled.
Thus providing the additional virtual memory resources required when checking the larger disk partitions.
 
Also, the embedded busybox multi-call binary has been recompiled to provide applets for the mkswap, swapon, swapoff, tune2fs, and e2fsck utilities.
Standalone versions of debugfs, dumpe2fs, and badblocks are also included.
It is outwith the remit of this document to explain the function of each of these utilities.
If you require additional information I suggest you Google for 'linux' followed by the name of utility.
 
To enable maintenance mode it is simply a matter of opening a telnet session and entering the 'fix-disk' command.
The HDR will then display some information about the utility, after which a reboot into maintenance mode will be initiated.
Once rebooted, re-open a telnet session and enter the 'fix-disk' command once again. Then sit back for an hour or so while it does it's magic.
A log file of e2fsck partition checking operations will be created at /mnt/hd1/fix-disk.log. This can safely be be deleted.

Linux gurus can initiate maintenance mode manually by entering the command 'touch /usr/data/.MAINTENANCE_MODE' then rebooting.
All of the above mentioned utilities are then available to you should you wish to perform partition checking without the aid of the 'fix-disk' script.    
A second reboot restores the HDR to normal set top box operation.  
 
opkg
----
This is the package management system for managing your custom applications.
Entering 'opkg' from the command line without any command arguments will display a list of valid opkg commands.

httpd
-----
This is a very basic web server daemon embedded in the firmware to provide initial access to your HDR from a web browser on the local network.
This provides the platform from which to install the full web interface via the web-based repository. 

pass-disable
------------
Replaces the now deprecated 'pass-reset' opkg installable package.
Just enter 'pass-disable' from telnet to restore unsecured access to the web interface in the event of a forgotten username or password.

Installable from the online repository
======================================

Web Interface
-------------
A feature-rich package which uses a web server to manage the HDR's services and features from a web browser. 
Comes complete with now/next and 7 day EPG, plus remote scheduling facility.
Additional functions can be provided by installing optional plug-ins.
Comprehensive documentation is provided in the web interface, and additionally for each installed plug-in.
The web interface can be accessed from the local network, or from the web using the 'inadyn' plug-in.
 
service utility (installs with web interface)
--------------------------------------------
This allows users to easily manage all custom services on the HDR. It is available from the full web interface
on the 'Service Management' page, or from the command line using telnet.
Entering 'service' from the command line will list the current status of all services, and usage information.

! WARNING ! When using service-manager from the command line it is possible to stop and disable auto-start of ALL services !.
The web interface does not allow you to stop or disable auto-starting of the web server service. However, you can still disable it from the command line. 
So, always ensure you have a least one essential service with auto-start enabled or you will find yourself completely locked out.

TinyFTP
-------
The default login name and password is "HumaxFTP" and "0000" respectively. 
Login credentials can be changed by editing the file "tinyftp.conf" which can be found in "/opt/etc"

vsFTPd
-------
If you install vsftpd instead of tinyftp then system accounts are used for login.
There are two accounts available and you can login with either.
Please note that names and passwords are case sensitive.

The first account mirrors that of TinyFTP.
User name: 'HumaxFTP' Password '0000'
Logging in with these credentials will drop you directly into the /media folder.

More experienced users may want to login using the root account.
User name 'root' Password 'root'
This opens in the systems root folder, so you will need to navigate to /media to access your recordings. 

Passwords for these two system accounts can be changed by issuing a 'passwd' command via a telnet session.
i.e. enter 'passwd HumaxFTP' or 'passwd root' and follow the prompts.

Note:
Installing vsFTPd will stop any previous installed TinyFTP's process, and disable its auto-start, and vice-versa.
This is because you can only run one FTP server at once. However, it does not remove the application.
Users should then manage the running ftp server via the service utility. 

Telnet
------
Telnet does not require any login credentials. Should you wish to disable telnet then simply disable auto-start or uninstall it.

Dropbear SSH Server
-------------------
A secure alternative to telnet.
Dropbear uses the system accounts so login is as per vsftpd.
During installation RSA and DSS host keys have to be generated, so don't be alarmed if the install seems to take longer than usual.

SFTP Server
-----------
A secure shell ftp server which can be used as an alternative to TinyFTP or vsFTPd. (Requires dropbear to be installed).

TwonkyMedia DLNA Server
-----------------------
Two versions of this software is available, v4.4.18 and v5.1.6. The latter is known to work better with the Western Digital TV Live client.
However, with this version, the trial period expires in 30 days after which a license is required, Install whichever one suits your needs.
Once you install TwonkyMedia DLNA Server a link will appear in the web interface index, providing access to the TwonkyMedia configuration page.
If you haven't installed the full web interface just point your browser to http://Foxsat-HDR:9000 (or 9001 for v5) for configuration.

MediaTomb uPnP Server
---------------------
MediaTomb is a freeware uPnP server that can be installed as an alternative to TwonkyMedia.
(Thanks to mogie for sourcing the precompiled binaries for this package).
Once you install MediaTomb uPnP Server a link will appear in the web interface index, providing access to the MediaTomb configuration page.
If you haven't installed the full web interface just point your browser to http://Foxsat-HDR:49152 for configuration.

Note:
I don't recommend running two media servers at once but it's O.K. to have both installed. 
You can then stop, start, enable or disable auto-start, on either server using the service management utility provided.
(During testing I had both servers running concurrently without any noticable problems.)  

Samba
-----
A Samba share named 'Media' has been defined to give read/write access to the three sub-folders Video, Music, and Photo.
Any attached USB drive will be listed here also. In addition, four individual Samba shares named 'Video', 'Music', 'Photos', and 'USB' are defined, allowing users to choose whichever best suits their needs. No password is required to access these folders.

The Netbios name is now automatically set to the hostname defined in file "/opt/etc/hostname".
The default hostname is "Foxsat-HDR" but can be changed by editing this file, or via the web interface "Settings" page. 
There is no longer any need for the user to edit the smb.conf file in order to change the Netbios name.
The workgroup name which was previously 'HOME' is now set to the Windows 7 default of 'WORKGROUP'.
This should be fine for most users, but it can be changed by editing the file '/opt/etc/smb.conf', or via the web interface "Settings" page.
Note:
Editing any file on the HDR should only be undertaken using a text editor that doesn't insert CR/LF.(Carriage Return/Line Feed)
at the end of every line. This probably excludes every text editor bundled with Windows.
Linux and Unix systems expect lines to be terminated with a LineFeed only.
If you are running Windows then Google for a freeware named 'Notepad++'.
This editor can read and write files in UNIX/LINUX format using LF as the line terminator.
  
Correct syntax of an edited "smb.conf" can be checked prior to execution by entering "testparm" from the command line.
Any changes to "smb.conf" will not be reflected until Samba is stopped and restarted. 

The Samba password is currently set to null, but if you require a password to access HDR folders then you can set it
by entering 'smbpsswd' from the command line, but be aware that you will also have to correctly configure "smb.conf". 

After installation of Samba it may take a few minutes for Windows to see the HDR's netbios broadcasts so be patient.
You can map a network drive using unicode paths i.e. "\\Foxsat-HDR\Media"

opkg-tools
----------
This package contains two tools, opkg-pack and opkg-unpack, enabling users to create their own .opk packages, or unpack existing ones.
See the wiki page at http://wiki.hummy.tv/wiki/Create_Packages for details on package format and how to create them.
  

Well, that's about it. I sincerely hope that this bundle makes your Foxsat HDR experience more enjoyable.


My regards to all at AV Forums, (the main support site) hummy.tv, and Digital Spy.
And a special mention for my friends on "My Humax Forum" at http://myhumax.org/forum/
The admins there are all names you will recognise from the old hummy.org.uk
and are the people who made the old hummy.org.uk site what it was.  Check it out! 

raydon


Credits
-------
Thanks to mogie for being the first to mod the HDR firmware. His initial firmware release, with FTP and Telnet services,
provided the foundation on which everything else has been built. Also for his Channel Editor, another great addition to the HDR.

And a thank-you to Duddits, and other members of the development team at the Humax iCord forum in Germany.
Their 'MiniRootFS' has been a great source of inspiration and reference when putting the original package together.

And a really massive thank-you must go to af123, the sole author of the web interface and underlying applications and scripts
which provide so much additional functionality on the Humax HD(R) Fox T2. He has kindly allowed us to use his original ideas and
sources as the basis for the web interface and support applications you find released here in v4.x.x.
Also, he is hosting the opkg repository for the Foxsat HDR on his website, hummypkg.org.uk, so once again af123 thank you !     

Another massive thank you for the continuing development and upgrades to the web interface, plus additional plug-ins, provided by by adrianf36.
Thanks to REPASSAC for his support with scripting, html validation, and beta testing.
Also thanks to Partridge for the epg.dat analysis and beta testing, and more recently the original research which led to the development
of the 'display' utility which enables custom messages to be written to the front panel display.
Also deserving a credit is David500 for his work in preparing the documentation pages contained within the web interface.

Many thanks for your hard work guys. Much appreciated ! 

And finally, thanks to Humax, for the box.


Disclaimer
----------
By using this package you agree that the author cannot be held responsible for any possible damage that may occur to your Foxsat HDR
by installing it. Having said that, it is extremely unlikely, and in the event, a re-install of the Humax official firware should put
everything right.

History
-------
v4.0.0: 21st Sept 2011
Initial release
v4.0.1: 21st Sept 2011
Resolved a problem whereby connected USB drives were not being mounted.
v4.0.2: 3rd Oct 2011
Resolved a problem whereby if mongoose suffered a crash, it could possibly restart and display the basic web interface index
even though the full web interface index was installed.
v4.0.3: 7th Oct 2011
Resolved a problem whereby mongoose did not account for the one hour time difference between DST/GMT.
v4.0.4: 10th Oct 2011
New version necessitated by the release of Humax v1.00.17 firmware.
v4.0.5: 13th Dec 2011
Small change to the mongoose web server with regard to cache control.
v4.0.6: 16th Dec 2011
Resolved a problem whereby certain installs via USB could fail due to undefined custom environment variables.
v4.0.7: 12th April 2012
New version necessitated by the release of Humax v1.00.20 firmware.
Also a new function has been added to display the custom firmware version number on the front panel during each boot.
v4.0.8: 30th July 2012
New version necessitated by the release of Humax v1.00.21 firmware.
v4.0.9 : 15th Oct 2012
Resolved a problem whereby it was possible to have an incorrect IP address recorded in the 'hosts' file when using a static IP address.
Recompiled kernel with swap file support added.
Recompiled busybox with additional applets for swapfile creation and partition checking.
Additional embedded binaries added for partition check/repair support.
Maintenance mode introduced.
v4.1.0 : 28th Jan 2013
Some changes to facilitate the new NAS mount plug-in, which utilises a virtual USB device to mount network-attached shares.
v4.1.1 : 10th Feb 2013
Resolved a problem whereby the HDR would hang on reboot following the scheduling of a recording from the web interface.
This This problem would only affected users of the NASMount plug-in.
v4.1.2 : 10th Aug 2013
Code modifications to the embedded mongoose web server. This is a workaround to Chrome browser's 304 response bug, which was causing CSS not render correctly on page refreshes. 
The fix-disk utility now uses a standalone version of e2fsck rather than the busybox version, which had proved to be problematic.
v4.1.3 : 17th June 2014
The embedded mongoose web server has been removed and replaced by a small httpd bootstrap server.
The main web server, lighttpd, now installs from the repository, facilitating server updates without needing to reflash firmware.

Improvements to initial bootstrap web interface.
	1. Added a 'repository reachable' check, using ping, which will display an appropriate error message rather than allowing opkg to repeatedly fail, with associated error messages that only serve to confuse users.
	2. Added checks for the existence of previously installed essential packages, and in this case it does an 'opkg install --force-reinstall' instead. This may aid recovery in the event of corruption of essential packages.
	3. Telnet will now be installed/re-installed by default in order to provide another avenue for access in the case of a recovery, or for manual package installation.

A web interface UAC password removal script 'pass-disable' is now included in the build.
This replaces the now deprecated 'pass-reset' opkg installable package.