<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Weird rocketry &#187; transmission</title>
	<atom:link href="http://webapp.org.ua/tag/transmission/feed" rel="self" type="application/rss+xml" />
	<link>https://webapp.org.ua</link>
	<description>Flights to outer code</description>
	<lastBuildDate>Sat, 16 Jul 2016 11:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Installing optware on Dune HD-TV 102</title>
		<link>https://webapp.org.ua/hardware/installing-optware-on-dune-hd-tv-102/</link>
		<comments>https://webapp.org.ua/hardware/installing-optware-on-dune-hd-tv-102/#comments</comments>
		<pubDate>Sun, 03 Nov 2013 22:36:18 +0000</pubDate>
		<dc:creator>bananos</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[102w]]></category>
		<category><![CDATA[dune]]></category>
		<category><![CDATA[entware]]></category>
		<category><![CDATA[hacking dune]]></category>
		<category><![CDATA[hd-tv 102]]></category>
		<category><![CDATA[optware]]></category>
		<category><![CDATA[root access]]></category>
		<category><![CDATA[transmission]]></category>

		<guid isPermaLink="false">http://webapp.org.ua/?p=362</guid>
		<description><![CDATA[Dune company has given us a miryad of excellent media players, especially by producing high quality software. In this article I&#8217;ll give you step-by-step instructions on how to convert your media player into full-fledged NAS with ability to download torrents and perform any task a generic linux box could do. Root access First off, you [...]]]></description>
			<content:encoded><![CDATA[<div class="markdown-content">
<p><img src="http://webapp.org.ua/wp-content/uploads/2013/11/TV_102w.png" alt="" title="Dune HD TV-102w" width="486" height="259" class="alignleft size-full wp-image-380" /></p>
<p>Dune company has given us a miryad of excellent media players, especially by producing high quality software. In this article I&#8217;ll give you step-by-step instructions on how to convert your media player into  full-fledged NAS with ability to download torrents and perform any task a generic linux box could do.</p>
</div>
<p><br style="clear:both"/><br />
<span id="more-362"></span></p>
<div class="markdown-content">
<h2>Root access</h2>
<p>First off, you need to obtain a retail model Dune HD-TV 102w (with &#8216;w&#8217; postfix), this is the only model which  has appropriate firmware for getting root access.</p>
<p>Download <a href="http://files.dune-hd.com/partners/sdk/dune_service_telnetd.dsf">dune_service_telnetd.dsf</a>, copy it to usb-flash drive and insert into Dune. Power on device, go to <code>Sources</code>, find that file and press <code>OK</code> to execute it. Once this is done, <code>telnetd</code> service will be available until next reboot. To make it permanent, run the following:</p>
<pre><code class="bash" title="">telnet root@dune_ip
login: root
password: &lt;empty&gt;

tangox[~] touch /config/telnetd
tangox[~] sync

</code></pre>
<h2>HDD Partition</h2>
<p>Connect USB-HDD disk drive to Dune to be able to install Optware and store torrents media. We&#8217;re going to re-format the disk and create 3 partitions. Here&#8217;s a sample list:</p>
<pre><code class="bash" title="">tangox[~] fdisk -l /dev/sda

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1         499     4008186  83 Linux
/dev/sda2             500         624     1004062+ 82 Linux swap
/dev/sda3             625       19457   151276072+ 83 Linux

</code></pre>
<p>As you can see we&#8217;re going to use <code>sda1</code> to store Optware, <code>sda2</code> for swap and <code>sda3</code> for video content.<br />
To do that you may use <code>fdisk</code>, <code>mkfs.ext3</code> and <code>mkswap</code> commands like this:</p>
<pre><code class="bash" title=""># after fdisk partitioning
tangox[~] mkswap /dev/sda2
tangox[~] mkfs.ext3 /dev/sda1
tangox[~] mkfs.ext3 /dev/sda3
</code></pre>
<h3 id="post-362-md-4">Initialize swap</h3>
<p>Dune a has special mechanism to autostart some services during initial boot. We&#8217;re going to put some preliminary startup work there.<br />
Create file <code>/mnt/config/boot/bootstrap.sh</code> and put following contents inside:</p>
<pre><code class="bash" title="">#!/bin/sh
# Turn on swap partition
swapon /dev/sda2
</code></pre>
<p>Then, make sure that file is executable:</p>
<pre><code class="bash" title="">tangox[~] chmod +x /mnt/config/boot/bootstrap.sh
</code></pre>
<h3 id="post-362-md-5">Give nice names to HDD partitions</h3>
<p>In order for HDD partitions to look nice in Dune GUI (sources menu section), will do some more tuning.<br />
First off, issue <code>df</code> command:</p>
<pre><code class="bash" title="">tangox[~] df
Filesystem                Size      Used Available Use% Mounted on
tmpfs                    92.7M      3.1M     89.6M   3% /tmp
/dev/sda3               142.0G     57.8G     77.0G  43% /D
/dev/mtdblock4          105.2M     75.6M     29.5M  72% /app
/dev/loop0              262.3M    262.3M         0 100% /tango3
/dev/mtdblock5          100.0M      8.1M     91.9M   8% /mnt
/dev/sda1                 3.8G    132.3M      3.4G   4% /tmp/mnt/storage/34611c58-ba35-4256-b546-8038078575ab
/dev/sda3               142.0G     57.8G     77.0G  43% /tmp/mnt/storage/566c9eb8-8239-4af5-9ea5-609ddc035e6f

</code></pre>
<p>You&#8217;ll see those ugly long directory names, which we want to change. Go to <code>/tmp/mnt/storage/34611c58-ba35-4256-b546-8038078575ab</code> and create the file <code>dune_folder.txt</code> with the following contents:</p>
<pre><code class="bash" title="">storage_name=opt
system_files=*
</code></pre>
<p>Because this is a system partition for our Optware we&#8217;re going to hide every file from being visible by end-user. Go to next directory and create similar file:</p>
<pre><code class="bash" title="">tangox[~] cd /tmp/mnt/storage/566c9eb8-8239-4af5-9ea5-609ddc035e6f
tangox[~] echo "storage_name=media" &gt;&gt; dune_folder.txt
tangox[~] echo "system_files=*.part" &gt;&gt; dune_folder.txt
</code></pre>
<p>This set of folder settings will make uncompleted torrent files hidden from Dune menus. Once you&#8217;re done, reboot, telnet again and run <code>df</code> command one more time:</p>
<pre><code class="bash" title="">tangox[~] df
Filesystem                Size      Used Available Use% Mounted on
tmpfs                    92.7M      3.1M     89.6M   3% /tmp
/dev/sda3               142.0G     57.8G     77.0G  43% /D
/dev/mtdblock4          105.2M     75.6M     29.5M  72% /app
/dev/loop0              262.3M    262.3M         0 100% /tango3
/dev/mtdblock5          100.0M      8.1M     91.9M   8% /mnt
/dev/sda1                 3.8G    132.3M      3.4G   4% /tmp/mnt/storage/opt
/dev/sda3               142.0G     57.8G     77.0G  43% /tmp/mnt/storage/media
</code></pre>
<p>Things will look more nicer! Now, let&#8217;s make aliases for <code>opt</code> and <code>media</code> folders by symlinking them to root.  Make sure your system don&#8217;t have any important data at <code>/opt</code> as we&#8217;re going to delete it. Now, open <code>/mnt/config/boot/bootstrap.sh</code> file and modify it to look as following:</p>
<pre><code class="bash" title="">#!/bin/sh
# Turn on swap partition
swapon /dev/sda2

# symlink optware and media folders
rm -rf /opt
ln -s /tmp/mnt/storage/opt /opt
ln -s /tmp/mnt/storage/media /media

</code></pre>
<p>Now reboot, and ensure that there are valid <code>/opt</code> and <code>/media</code> symlinks at root path.</p>
<h2>Optware installation</h2>
<p>Finally we&#8217;re ready to install additional software. Create optware installation script at <code>/opt/install.sh</code>:</p>
<pre><code class="bash" title="">#!/bin/sh
# Source code: http://www.nslu2-linux.org/wiki/Optware/HomePage
feed=http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/unstable/
# install ipkg
ipk_name=`wget -qO- $feed/Packages | awk '/^Filename: ipkg-opt/ {print $2}'`
/usr/bin/wget "$feed/$ipk_name"
/bin/tar -xOvzf $ipk_name ./data.tar.gz | tar -C / -xzvf -
mkdir -p /opt/etc/ipkg
echo "src cross $feed" &gt; /opt/etc/ipkg/feeds.conf

# install uc-libC
ipk_name=`wget -qO- $feed/Packages | awk '/^Filename: uclibc-opt/ {print $2}'`
/usr/bin/wget "$feed/$ipk_name"
/bin/tar -xOvzf $ipk_name ./data.tar.gz | tar -C / -xzvf -

</code></pre>
<p>To do that you may should use <code>vi</code> editor which is available by default. Ensure that the file is executable and run it:</p>
<pre><code class="bash" title="">tangox[~] chmod +x /opt/install.sh
# run it
tangox[opt] ./install.sh

Connecting to ipkg.nslu2-linux.org (140.211.169.161:80)
ipkg-opt_0.99.163-10 100% |*************************************************************************************************************| 75831  00:00:00 ETA
./
./opt/
./opt/bin/
./opt/bin/ipkg
./opt/bin/ipkg-opt
./opt/bin/update-alternatives
./opt/etc/
./opt/etc/ipkg.conf

.....................................

Connecting to ipkg.nslu2-linux.org (140.211.169.161:80)
uclibc-opt_0.9.28-13 100% |*************************************************************************************************************|   832k 00:00:00 ETA
./
./opt/
./opt/etc/
./opt/lib/
./opt/lib/ld-uClibc-0.9.28.so
./opt/lib/ld-uClibc.so.0
./opt/lib/libc.so

......................................................

</code></pre>
<p>If you&#8217;ve been observing messages above chances are high that you now have a working skeleton of optware system.<br />
Let&#8217;s check this by typing:</p>
<pre><code class="bash" title="">tangox[opt] /opt/bin/ipkg --version
ipkg version 0.99.163

</code></pre>
<p>This means that package management system has been installed and works fine. From this time on you have the ability to install tons of additional linux software precompiled for MIPS architecture!  You may get the list of available software by typing <code>ipkg --list</code>, and we&#8217;ll continue our tuning process.</p>
<h3 id="post-362-md-6">Fix PATH variable</h3>
<p>Let&#8217;s make using optware more convenient, open <code>/mnt/config/boot/bootstrap.sh</code> and add following lines:</p>
<pre><code class="bash" title=""># fix PATH for new packages
echo "export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/bin/X11:/usr/local/bin" &gt;&gt; /root/.bashrc
echo "export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/bin/X11:/usr/local/bin" &gt;&gt; /etc/profile
</code></pre>
<h2>Optware autostart hack</h2>
<p>In order to autostart all neccessary services we&#8217;re going to do some additional hacking. At first, it seems that adding call of autostart script to <code>/mnt/config/boot/bootstrap.sh</code> will do the trick, but after numeruos attempts  to do just that things didn&#8217;t work. My guess is that at <code>/mnt/config/boot/</code> stage external storage is not mounted yet, so everything under <code>/opt</code> is not available.</p>
<p>To overcome that, I&#8217;ve managed to create a bit ugly, but working solution, i.e. to autostart services using crond,  which is available by default on device. The idea is simple: start optware only once, and if it is started already just do nothing. Let&#8217;s write some scripts to achieve that.</p>
<p>Create <code>/opt/etc/rc.optware</code> file with following contents:</p>
<pre><code class="bash" title="">#!/bin/sh
# Start all init scripts in /opt/etc/init.d
# executing them in numerical order.
for i in /opt/etc/init.d/* ;do

    # Ignore dangling symlinks (if any).
    [ ! -f "$i" ] &amp;&amp; continue

    case "$i" in
       *.sh)
        # Source shell script for speed.
        (
            trap - INT QUIT TSTP
            set start
            . $i
        )
        ;;
       *)
        # No sh extension, so fork subprocess.
        $i start
        ;;
    esac
done
</code></pre>
<p>Create <code>/opt/etc/optware-cron.sh</code> with following contents:</p>
<pre><code class="bash" title="">#!/bin/sh
# After reboot this file will be absent!
FLAG_FILE=/var/run/optware.started

# if file not found, run optware
if [ ! -f $FLAG_FILE ]; then
 touch $FLAG_FILE
 /opt/etc/rc.optware
fi
</code></pre>
<p>Make sure both files are executable:</p>
<pre><code class="bash" title="">tangox[opt] chmod +x optware-cron.sh rc.optware
</code></pre>
<p>Open our <code>/mnt/config/boot/bootstrap.sh</code> file and add following lines:</p>
<pre><code class="bash" title="">killall crond
echo "*/1 * * * * /opt/etc/optware-cron.sh" &gt;&gt; /tmp/cron/crontabs/root
/usr/sbin/crond
</code></pre>
<p>This will modify crond config during startup and will make sure that <code>optware-cron.sh</code> file will be launched once per every minute.</p>
<p>Reboot your dune and ensure that everything works fine. Next, we&#8217;re going to add some useful software like transmission!</p>
<h2>Install transmission</h2>
<p><img src="http://webapp.org.ua/wp-content/uploads/2013/11/transmission-bittorrent1.png" alt="" title="transmission-bittorrent" width="300" height="300" class="aligncenter size-full wp-image-383" /></p>
<pre><code class="bash" title="">tangox[opt] ipkg install transmission
</code></pre>
<p>Let&#8217;s create startup script for Transmission daemon, open <code>/opt/etc/init.d/S60transmission</code> and type in:</p>
<pre><code class="bash" title="">#!/bin/sh
# Exit if the package is not installed
test -f /opt/bin/transmission-daemon || exit 0

function start_daemon() {
    /sbin/start-stop-daemon --start --quiet --exec /opt/bin/transmission-daemon  --auth --config-dir=/opt/etc/transmission/ --username="your_username" --password="your_password" --download-dir=/media/ --allowed=* --logfile=/opt/var/log/transmissiond.log
}

case "$1" in
  start)
    echo  "Starting transmission-daemon"
    start_daemon
    ;;
  stop)
    echo  "Stopping transmission-daemon"
    /sbin/start-stop-daemon --stop --quiet --exec /opt/bin/transmission-daemon
    ;;
  restart)
    echo -n "Stopping transmission-daemon"
    /sbin/start-stop-daemon --stop --quiet --exec /opt/bin/transmission-daemon
    for i in 1 2 3 ;
    do
        sleep 1
        echo -n "."
    done
    echo  "Restarting transmission-daemon"
    start_daemon
    ;;
  *)
    echo "Usage: /opt/etc/init.d/S60transmission {start|stop|restart}"
    exit 1
esac

exit 0

</code></pre>
<p>Don&#8217;t forget to make this script executable and make sure you provide valid <code>your_username</code> and <code>your_password</code>. Verify that transmission daemon works by typing in the terminal:</p>
<pre><code class="bash" title="">tangox[opt] /opt/etc/init.d/S60transmission start
tangox[opt] ps -Af | grep trans
 1500 root       0:04 /opt/bin/transmission-daemon --auth --config-dir=/opt/etc/transmission/ --username="your_username" --password="your_password" --download-dir=/media/ --allowed=* --logfile=/opt/var/log/transmissiond.log 

</code></pre>
<p>If everything went fine the last command should output transmission process running in the background, you might also observe it by running <code>top</code> command.</p>
<p>Reboot your dune once again, open your favorite web browser and point it to <code>http://dune_ip:9091</code> you should see basic auth dialog from your Transmission web interface. From this point you&#8217;re free to download any torrent media which will be instantly accessible for playback once completed.</p>
<h2>Some useful tips</h2>
<p>1) I would highly recommend desktop client for transmission called <a href="https://code.google.com/p/transmisson-remote-gui/">Transmission Remote GUI</a> it has more control and features than default web interface.</p>
<p>2) Find out <code>power management</code> section in main dune menu and set <code>sleep mode</code> to <code>never</code>. You need your device to be online 7&#215;24 don&#8217;t you?</p>
<p>3) Install <code>openssh</code> tools, setup <a href="http://www.cyberciti.biz/tips/ssh-public-key-based-authentication-how-to.html">public key based authentication</a> and turn off passwordless telnet to increase security</p>
<h2>Links</h2>
<ul>
<li><a href="http://files.dune-hd.com/partners/sdk/dune_devel_info.txt">http://files.dune-hd.com/partners/sdk/dune_devel_info.txt</a></li>
<li><a href="http://files.dune-hd.com/partners/sdk/dune_service_telnetd.dsf">http://files.dune-hd.com/partners/sdk/dune_service_telnetd.dsf</a></li>
<li><a href="http://dune-hd.com/support/misc/dune_folder_howto.txt">http://dune-hd.com/support/misc/dune_folder_howto.txt</a></li>
<li><a href="http://files.dune-hd.com/partners/sdk/dune_boot_process.txt">http://files.dune-hd.com/partners/sdk/dune_boot_process.txt</a></li>
<li><a href="https://code.google.com/p/transmisson-remote-gui/">https://code.google.com/p/transmisson-remote-gui/</a></li>
<li><a href="http://www.cyberciti.biz/tips/ssh-public-key-based-authentication-how-to.html">http://www.cyberciti.biz/tips/ssh-public-key-based-authentication-how-to.html</a></li>
</ul>
</div>
<p></empty></p>
]]></content:encoded>
			<wfw:commentRss>https://webapp.org.ua/hardware/installing-optware-on-dune-hd-tv-102/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
