Tuesday, October 13, 2009

Problem with updateblocklist.sh script

Problem with the updateblocklist.sh script

As indicatecd in my earlier update on 23rd September 2009, an anonymous poster had help in solving the schedule of the editcron.sh script.

By changing it to something like "/bin/echo "0 0 * * 2 /ffp/var...." so it only runs once every Tuesday instead many, many time on Tuesday.

Or,
"/bin/echo "15 3 * * 2 /ffp/var...." will mean the script to run on every Tuesday at 0315hrs.

Or, "/bin/echo "0 1 * * 3 /ffp/var...." will mean the script to run on every Wednesday at 0100hrs.

Hope the above two examples will help all to understand the settings for the schedule.

Now to the updateblocklist.sh script. The script execute with no errors when I run it in PuTTY.

However, when I let the script run as in the schedule, the log shows the folllowing error.

Starting transmission-daemon /ffp/start/transmission.sh: line 42: su: not found

On checking the transmission.sh script, line 42 is

run_rc_command "$1"

In the beginning of the script, it is able to stop transmission by the following command.

/ffp/start/transmission.sh stop

However, at the end of the updateblocklist.sh script, the error appears. Now I have to execute this script manually.

I hope someone will be able to help to solve this problem.

Original script from Mike site http://www.horto.ca/?p=10

#!/bin/sh
##############################################################################
# ---[ updateblocklist.sh ] ---
# script to look update blocklist, unzip and restart transmission
# w 17/11/08 cheongseeker
# w help from horto
# ref charles kerr, transmission developer
#ref http://forum.transmissionbt.com/viewtopic.php?p=26575#p26575
##############################################################################
# define variable WGET with an absolute path
# define variable GUNZIP with an absoulet path
# define variable BLOCKLIST with an absolute path
WGET=/ffp/bin/wget
GUNZIP=/ffp/bin/gunzip
BLOCKLIST=/mnt/HD_a2/.transmission-daemon/blocklists/level1
BLOCKLISTBIN=/mnt/HD_a2/.transmission-daemon/blocklists/level1.bin
#stop transmission
/ffp/start/transmission.sh stop
/ffp/start/transmission.sh stop

# check file level1.gz if exist then delete
if [ -f level1.gz ]; then
rm level1.gz
fi

# check variable BLOCKLIST if exist then delete
if [ -f $BLOCKLIST ]; then
rm $BLOCKLIST
fi

# check variable BLOCKLISTBIN if exist then delete
if [ -f $BLOCKLISTBIN ]; then
rm $BLOCKLISTBIN
fi

# download the blocklist level1.gz from htp://download.m0k.org/transmission/files/level1.gz
# and save to /mnt/HD_a2/.transmission-daemon/blocklists
$WGET http://download.m0k.org/transmission/files/level1.gz -P /mnt/HD_a2/.transmission-daemon/blocklists

#cd /mnt/HD_a2/.transmission-daemon/blocklists
cd /mnt/HD_a2/.transmission-daemon/blocklists

#unzip level1.gz with variable GUNZIP
$GUNZIP level1.gz

#restart transmission in order for transmission to recognize the new blocklists
/ffp/start/transmission.sh stop
/ffp/start/transmission.sh start
/ffp/start/transmission.sh start

Sunday, September 20, 2009

Next Step in Modding DNS-323

Transmission BT for DNS-323


Firstly, I need to apologise for taking so long on posting how to have transmission running on the DNS-323. I was just too lazy in getting to it. Sorry about it.

I have to say that all the information here are taken from a lot of other users of DNS-323 whom had worked very hard at getting the most out of it. Credits all goes to them for all these information. I'm putting all these here for my own record as well as to share it with everyone.

     Mike at http://www.horto.ca/?p=10
     Shadowandy at http://www.shadowandy.net/2009/01/transmission-142-for-dns-323.htm
     DSM-G600, DNS-323 and TS-I300 Hack Forum at http://forum.dsmg600.info/f3-DNS323-General-Discussion.html

However, a few good news to note. Over this long period, I'm happy to say that transmission latest version is very much improved. Now you are able to pick out individual files that are in one torrent which you want to download. It now supports DHT. All these via the web interface. Another important change, for those who are very into Internet Explorer, Transmission web interface now runs well on IE.

Now, lets get into getting transmission on your DNS-323.

1. Transmission

Transmission is a light-weight BitTorrent client that, fortunately, runs on the DNS-323 devices.

Features
     * Remote access via Web interface
     * download of multiple torrents at once
     * low memory imprint
     * low CPU usage
     * blocklist support
     * proxy support

Latest version: 1.92 (updated 21st April 2010)

2. Installation

IMPORTANT:
You need to install the latest version of ucLibc in order for Transmission to work correctly. You can find it at fonz' repository. You will require to reboot the DNS when all these are done.

Member KyleK in the DSM-G600, DNS-323 and TS-I300 Hack Forum is very helpful in compiling each latest update of transmissionbt to run on DNS-323. You can locate the latest version on this thread http://forum.dsmg600.info/viewtopic.php?id=2719&p=1[REL] Transmission 1.3 in the forum.

Download the following files

     curl-7.20.0-1.tgz from http://ffp.wolf-u.li/additional/net-misc/curl-7.20.0-1.tgz
     uclibc-0.9.29-7.tgz from http://www.inreto.de/dns323/fun-plug/0.5/packages/

The latest version of Transmission is 1.92 (updated 21st April 2010)

     Transmission-1.92-1.tgz from http://kylek.is-a-geek.org:31337/files/Transmission-1.92-1.tgz

Refer to http://cheongseeker.blogspot.com/2008/11/modding-my-dns-323.html to find out how you can obtain the WinSCP software.

Start up WinSCP and copy curl-7.20.0-1.tgz, uclibc-0.9.29-7.tgz and Transmission-1.92-1.tgz to "/mnt/HD_a2".

Next start up PuTTY from within the WinSCP software. As PuTTY is integrated, the root user name and password will be passed over to the PuTTY software. Thus, saving you the need to re-enter them again.

You will be in the user "root" home directory. You need to change directory to "/mnt/HD_a2" by typing the following

     root@YourDNS:~# cd /mnt/HD_a2

Install the curl package by doing the following

     root@YourDNS:/mnt/HD_a2# funpkg -i curl-7.20.0-1.tgz{do this only if you have not done it initially}

Install the uclibc package by doing the following

     root@YourDNS:/mnt/HD_a2# funpkg -i uclibc-0.9.29-7.tgz{do this only if you have not done it initially}

If you are upgrading from an old version to the latest then do the following. I make it a habit not to delete transmission tgz file that I had copied to "/mnt/HD_a2". This helps me to find out the actual package that I had last installed. So, if you had forgotten which transmission package you installed then run the "ls" command and it will list out the files in "/mnt/HD_a2" directory.

     root@YourDNS:/mnt/HD_a2# ls

Now key in the package name after "funpkg -r"

     root@YourDNS:/mnt/HD_a2# funpkg -r Transmission-1.22-ffp0.5.tgz

Then install the latest version

     root@YourDNS:/mnt/HD_a2# funpkg -i Transmission-1.92-1.tgz

Now you need to add transmission to be one of the packages that starts up automatically each time the DNS-323 starts up. Type the following

     root@YourDNS:/mnt/HD_a2# chmod a+x /ffp/start/transmission.sh;sh /ffp/start/transmission.sh start

You will see a message that state transmission is starting. Now we have to stop transmission again to continue with the rest of the set up. Type the following

     root@YourDNS:/mnt/HD_a2# sh /ffp/start/transmission.sh stop

You can check the status to see if transmission is still running. Type the following

     root@YourDNS:/mnt/HD_a2# sh /ffp/start/transmission.sh status

* * Before you proceed to the following steps you need to make sure that Transmission is not running as you will be editing the "settings.json" file.

3. Whitelisting and Unmasking

* * Note:
Whitelisting is to control unwanted access to your DNS. If you wish to access your DNS, to get to the transmission web interface from outside of your house via the internet, then you will need to turn on "rpc-authentication-required" to "true" and set the username and password. This will require you to key in username and password each time you access the transmission web interface, even from within your home. Then it will be better for you to turn off "rpc-whitelist-enabled", changing it from "true" to "false".

The following will detail how to set the whitelisting for those who are still interested. Now we need to edit the configuration file "settings.json" located at "/mnt/HD_a2/.transmission-daemon" directory

First is to add your local LAN IP range to the whitelist. Let's assume that your local LAN range is 192.168.x.x then we need to add 192.168.*.* to whitelist the whole range.

In PuTTY, type the following

     root@YourDNS:/mnt/HD_a2# vi /mnt/HD_a2/.transmission-daemon/settings.json

Move the cursor to the line "rpc-whitelist": "127.0.0.1",

Move the cursor the the end of "127.0.0.1". Make sure that your cursor is placed after the "1" character.

You will notice the bottom left hand corner of the window there is a "-" character. When you hit the "i" key, it will change from "-" to "I". When you hit the "i" key again, it changes back to "-". Now, ensure that the bottom left corner character is "I" then type "192.168.*.*". The line should shows like this.

     "rpc-whitelist": "127.0.0.1,192.168.*.*",

Now hit the "" key then ":" key. The bottom left hand character will change to ":". Then hit "w" key, follow immediately by "q" key then hit the "enter" key. This will save the file and return you to the prompt.

Alternatively if you use WinSCP, navigate your way to "/mnt/HD_a2/.transmission-daemon" and locate "settings.json". Double click on the file and script editor will open the file. You can edit the necessary change and click "Save" and then "Exit"

Unmasking

Edit: 21st April 2010

Next do the following as adviced by Isildur on the DSM-G600, DNS-323 and NSA-220 Hack Forum thread DNS-323/321 Discussion>>[REL] Transmission 1.3 post #984

Use WinSCP, navigate your way to "/mnt/HD_a2/.transmission-daemon" and locate "settings.json". Double click on the file and script editor will open the file.

Locate "unmask" and change the value from "18" to "0" then click "Save" and then "Exit".

4. Blocklist

Next is to turn on blocklist.

IP blocking/blocklisting is simply a technique used to restrict (block) traffic from any computer that is within a set list or parameters of any given IP range.

While IP Blocking hardly makes oneself anonymous, it can significantly reduce your chances of being tracked by bad groups interested in what you’re doing with your bandwidth. And by no means do blocklists offer 100% effectiveness for file sharing protection. However, when used in conjunction with a proxy server, it can reduce your odds of being caught down to nearly zero.

Transmission does have blocklisting and uses the list from bluetack. You have to manually download the blocklist file "level1" from Bluetack. You just need to do this once a week.

In PuTTY, type the following

     root@YourDNS:/mnt/HD_a2# vi /mnt/HD_a2/.transmission-daemon/settings.json

Move the cursor to the line "blocklist-enabled": false, change false to true

Now hit the "esc" key then ":" key. The bottom left hand character will change to ":". Then hit "w" key follow immediately by "q" key then hit "enter" key. This will save the file and return you to the prompt.

Alternatively if you use WinSCP, navigate your way to "/mnt/HD_a2/.transmission-daemon" and locate "settings.json". Double click on the file and script editor will open the file. You can edit the necessary change and click "Save" and then "Exit".

Lower down the post, I will show you a script which you can execute to do the downloading of the "level1" file.

5. Encryption

Encrypting your torrents will prevent throttling ISP’s from shaping your traffic. The RC4 encryption obfuscates not only the header but the entire stream. This means that it’s very hard for your ISP to detect that the traffic you are generating comes from BitTorrent.

Now to turn on encryption. In PuTTY type the following.

     root@YourDNS:/mnt/HD_a2# vi /mnt/HD_a2/.transmission-daemon/settings.json

Move the cursor to the line "encryption". Change the number to "2".

Now hit the "esc" key then ":" key. The bottom left hand character will change to ":". Then hit "w" key follow immediately by "q" key then hit "ente" key. This will save the file and return you to the prompt

Alternatively if you use WinSCP, navigate your way to "/mnt/HD_a2/.transmission-daemon" and locate "settings.json". Double click on the file and script editor will open the file. You can edit the necessary change and click "Save" and then "Exit"

6. Setting the downloading directory

Next is to set up the directory where your torrent files will be downloading to. The following will create a "incoming" directory under "/mnt/HD_a2".

In PuTTY, do the following.

     root@YourDNS:~# cd /mnt/HD_a2
     root@YourDNS:/mnt/HD_a2# mkdir incoming
     root@YourDNS:/mnt/HD_a2# chown nobody:777 incoming
     root@YourDNS:/mnt/HD_a2# chmod 777 /mnt/HD_a2/incoming
     root@YourDNS:/mnt/HD_a2# reboot


* * Note that chmod 777 allows all user to execute files in this directory. This is to help with those that has the "Permission Denied" problem.

The DNS-323 will reboot. After the DNS-323 blue light has stopped blinking, type the following in your web browser

     http://192.168.2.101:9091

Click on the little icon at the bottom left hand corner, then select "Preference". In the location "Download to:", key in "/mnt/HD_a2/incoming".

In the section "Encryption:", ensure that "Ignore unencrypted peers" is ticked.

In the section "Limit total bandwidth:", tick "Upload Rate:" and key in the value "22".

Then click "Save".

In PuTTY, do the following.

     root@YourDNS:~# /ffp/start/transmission.sh stop

You can check the status to see if transmission is still running. Type the following

     root@YourDNS:~# /ffp/start/transmission.sh status

* * Before you proceed to the following steps you need to make sure that Transmission is not running as you will be editing the "settings.json" file.

7. Moving completed torrents

There is a function in transmission that is not turn on by default.

In PuTTY, type the following

     root@YourDNS:/mnt/HD_a2# vi /mnt/HD_a2/.transmission-daemon/settings.json

Move the cursor to the line "incomplete-dir-enabled": false,

Change "false" to "true".

Now hit the "esc" key then ":" key. The bottom left hand character will change to ":". Then hit "w" key follow immediately by "q" key then hit "enter" key. This will save the file and return you to the prompt

Alternatively if you use WinSCP, navigate your way to "/mnt/HD_a2/.transmission-daemon" and locate "settings.json". Double click on the file and script editor will open the file. You can edit the necessary change and click "Save" and then "Exit".

One line above this is the folder set for "incomplete-dir". It is set to "/mnt/HD_a2/.transmission-daemon/Incomplete".

In PuTTY, do the following.

     root@YourDNS:~# cd /mnt/HD_a2/.transmission-daemon
     root@YourDNS:/mnt/HD_a2/.transmssion-daemon# mkdir Incomplete
     root@YourDNS:/mnt/HD_a2/.transmssion-daemon# chown nobody:777 Incomplete
     root@YourDNS:/mnt/HD_a2/.transmssion-daemon# chmod 777 /mnt/HD_a2/.transmission-daemon/Incomplete


By doing this, when you first upload a torrent file to Transmission, it will be stored at "/mnt/HD_a2/.transmission-daemon/Incomplete". During the full duration of downloading the file will continue to reside here.

Upon completion of download, Transmission will automatically move the file from "/mnt/HD_a2/.transmission-daemon/Incomplete" folder to the "Download to:" folder which you set in Step 6 above. In this above example it is "/mnt/HD_a2/incoming".

8. Login credentials for transmission web interface

To set up login credentials you need to start the transmission daemon at least once from the command-line.

Before doing this, you will need to stop transmission from running. Do the following via PuTTY.

     root@YourDNS:~# sh /ffp/start/transmission.sh stop

You can check the status to see if transmission is still running. Type the following

     root@YourDNS:/mnt/HD_a2# sh /ffp/start/transmission.sh status

Next do the following.{adviced by Kylek on the DSM-G600, DNS-323 and NSA-220 Hack Forum thread DNS-323/321 Discussion>>[REL] Transmission 1.3 post #1079

     root@YourDNS:~# su nobody -c "transmission-daemon -f -g /mnt/HD_a2/.transmission-daemon -t -u [username] -v [password] -a 127.0.0.1,192.168.*.*"

You should see some text about Transmission starting. If there are no error messages, you can quit Transmission by pressing Ctrl-C. You will need to reboot the DNS

     root@YourDNS:~# reboot

The DNS-323 will reboot. After the DNS-323 blue light has stopped blinking, type the following in your web browser

     http://192.168.2.101:9091

You will be prompted to key in the username and password.

9. Scripting

Now we are have to prepare a few scripts which will help with the running of transmission. All scripts below are the hard work of mike. His website is http://www.horto.ca/?p=10

He has helped me a lot with the setting up of transmission running on DNS-323 especially on the scripting.

     torrentwatchdog.sh - This script will scan "/mnt/HD_a2/torrents" directory for any new *.torrents files. When it finds it, the torrent file will be added and queue up.

The second part of the script scan all current downloading torrents, when it finds completed torrents that are seeding, it will stop it. For those that had enable login credentials, your usename and password will have to be in the script.

     updateblocklist.sh - This script will check for existing blocklist file and delete it. Then it will go fetch the latest level1 file, unzip and restart transmission again.

     editcron.sh - This script is to automate the above two scripts.

 

10. torrentwatchdog script

First we have to create the torrent directory which you will save all *.torrents files. Do the following via PuTTY.

     root@YourDNS:~# cd /mnt/HD_a2
     root@YourDNS:/mnt/HD_a2# mkdir torrents
     root@YourDNS:/mnt/HD_a2# chown nobody:777 torrents
     root@YourDNS:/mnt/HD_a2# chmod 777 /mnt/HD_a2/torrents

     root@YourDNS:/mnt/HD_a2# mkdir logs
     root@YourDNS:/mnt/HD_a2# chown nobody:777 logs
     root@YourDNS:/mnt/HD_a2# chmod 777 /mnt/HD_a2/logs


Next to create the scripts directory where all the scripts will be kept.

     root@YourDNS:/mnt/HD_a2# cd /ffp/var
     root@YourDNS:/mnt/HD_a2/ffp/var# mkdir scripts
     root@YourDNS:/mnt/HD_a2/ffp/var# chown nobody:777 scripts
     root@YourDNS:/mnt/HD_a2/ffp/var# chmod 777 /ffp/var/scripts


In the WinSCP software, on the right pane, navigate to "/ffp/var/scripts". Ensure that the right pane is selected, then hit "Shift" + "F4" together. In the dialog box that is asking for a new file name, enter "torrentwatchdog.sh" and hit "Ok".

The text editor window appear. Copy the following script and paste into the text editor window. Take note that you will need to replace and with your own login credentials.

#!/bin/sh
###########################################################################
# script to monitor a selection of directories for new .torrent files.
# if found, queue them up in transmission
# and when done downloading, pause the torrent
# w 10/20/08 horto
# u 10/29/08 horto - implmented "make transmission stop after seeding 1:1"
# u 10/29/08 horto - v2.0, do away with /torrents and /incoming dirs, and
# just monitor /media/movies, /media/TV and /media/mp3
# directories for torrents so I don't have to manually
# organize everything later!
# u 11/06/08 horto - fixed bug with awk not being found via cron
###########################################################################
TORRENTDIRS="/mnt/HD_a2/incoming"
LOG=/mnt/HD_a2/logs/torrentwd.log
TRANSMISSION_REMOTE="/ffp/bin/transmission-remote -n username:password"

# check each incoming TORRENTDIR for new .torrents
for DIR in $TORRENTDIRS; do
for FILE in $DIR/*.torrent; do

# set download dir to current working dir
$TRANSMISSION_REMOTE -w $DIR

# pick out .torrent files and queue them up
if [ "$FILE" != "$DIR/*.torrent" ]; then
echo [`date`] "$FILE" added to queue. >> $LOG
$TRANSMISSION_REMOTE -a "$FILE"
rm "$FILE"
echo [`date`] "$FILE" deleted. >> $LOG
sleep 1
fi
done
done

# stop completed downloads
for i in `/ffp/bin/transmission-remote -l -n username:password | grep Done | grep Seeding | grep -v Ratio | /ffp/bin/awk '{print $1}'"`; do
echo [`date`] stopping torrent id $i >> $LOG
$TRANSMISSION_REMOTE -t $i -S
done

exit 0


Click on the "Save" icon and then click on the "Close Editor" icon.

     root@YourDNS:~# cd /ffp/var/scripts

Edit: 05th November 2009

     root@YourDNS:/mnt/HD_a2/ffp/var/scripts# chmod a+x /ffp/var/scripts/torrentwatchdog.sh;sh /ffp/var/scripts/torrentwatchdog.sh

In the WinSCP software, on the right pane, navigate to "/mnt/HD_a2/logs". Ensure that the right pane is selected, then hit "Shift" + "F4" together. In the dialog box that is asking for a new file name, enter ".torrentwd.log" and hit "Ok".

The text editor window appear.

I do not find watching the torrents directory that useful. The reason is that I had set up my DNS to be accessible from outside my home via the internet. In this manner, I'm able to start any *.torrent file at any time, any where. However, the second part of the script is very useful as it will stop the torrent that has finished downloading.

Thus, I still keep this script running. Later on you will find out how to schedule to run this script at a scheduled interval. I have set it to run every hour.

11. Updating of Blocklist file

As mentioned earlier, blocklist is simply a technique used to restrict (block) traffic from any computer that is within a set list or parameters of any given IP range.

While IP Blocking hardly makes oneself anonymous, it can significantly reduce your chances of being tracked by bad groups interested in what you’re doing with your bandwidth. And by no means do blocklists offer 100% effectiveness for file sharing protection. However, when used in conjunction with a proxy server, it can reduce your odds of being caught down to nearly zero.

In the WinSCP software, on the right pane, navigate to "/ffp/var/scripts". Ensure that the right pane is selected, then hit "Shift" + "F4" together. In the dialog box that is asking for a new file name, enter "updateblocklist.sh" and hit "Ok".

The text editor window appear. Copy the following script and paste into the text editor window.

Original script from Mike site http://www.horto.ca/?p=10


#!/bin/sh
##############################################################################
# ---[ updateblocklist.sh ] ---
# script to look update blocklist, unzip and restart transmission
# w 17/11/08 cheongseeker
# w help from horto
# ref charles kerr, transmission developer
#ref http://forum.transmissionbt.com/viewtopic.php?p=26575#p26575
##############################################################################
# define variable WGET with an absolute path
# define variable GUNZIP with an absoulet path
# define variable BLOCKLIST with an absolute path
WGET=/ffp/bin/wget
GUNZIP=/ffp/bin/gunzip
BLOCKLIST=/mnt/HD_a2/.transmission-daemon/blocklists/level1

# check variable BLOCKLIST
if [ -f $BLOCKLIST ]; then
mv $BLOCKLIST $BLOCKLIST.bak
fi

# download the blocklist level1.gz from htp://download.m0k.org/transmission/files/level1.gz
# and save to /mnt/HD_a2/.transmission-daemon/blocklists
$WGET http://download.m0k.org/transmission/files/level1.gz -P /mnt/HD_a2/.transmission-daemon/blocklists

#cd /mnt/HD_a2/.transmission-daemon/blocklists
cd /mnt/HD_a2/.transmission-daemon/blocklists

#unzip level1.gz with variable GUNZIP
$GUNZIP level1.gz

#restart transmission in order for transmission to recognize the new blocklists
/ffp/start/transmission.sh stop
/ffp/start/transmission.sh start


Click on the "Save" icon and then click on the "Close Editor" icon.

     root@YourDNS:~# cd /ffp/var/scripts {can skip this}
     root@YourDNS:/mnt/HD_a2/ffp/var/scripts# chmod +x updateblocklist.sh {can skip this}


This script will first check for existing "level1" and "level1.bin" files in the "/mnt/HD_a2/.transmission-daemon/blocklists" directory. If both files exists, they are deleted. Transmission is then stopped.

Next it goes to "http://download.m0k.org/transmission/files/level1.gz" and download "level1.gz" to "/mnt/HD_a2/.transmission-daemon/blocklists" directory. After download, it will unzip the "level1.gz" file.

Lastly, transmission is restarted.

Edit - 22/09/2009 : I encountered some problem with this script. When executed locally via PuTTY, the script runs without any problem. However, when it is set to run on a schedule of every Tuesday, it does not execute properly

12. Automate scripts

Having finish both scripts, now is to have both scripts run at certain interval.

In the WinSCP software, on the right pane, navigate to "/ffp/start". Ensure that the right pane is selected, then hit "Shift" + "F4" together. In the dialog box that is asking for a new file name, enter "editcron.sh" and hit "Ok".

The text editor window appear. Copy the following script and paste into the text editor window.

Original script from Mike site http://www.horto.ca/?p=10


#!/bin/sh
##############################################################################
# ----[ editcron.sh ]----
# script to keep cronjobs persistent (e.g. after reboot)
# NOTE: put this in /mnt/HD_a2/ffp/start/ and make it executable.
# w 22/10/08 horto
# ref/credit: http://tinyurl.com/5m2349 - thanks chumby!
#############################################################################
FFP=/mnt/HD_a2/ffp
CRONTXT=$FFP/etc/crontab.txt

# start with existing crontab
# note: on a fresh reboot, this will always have been reset to standard
/bin/crontab -l > $CRONTXT

# add cronjobs here preceeded by /bin/echo.
# don't forget to enclose them in double quotes.
/bin/echo "0 * * * * /ffp/var/scripts/torrentwatchdog.sh >> /mnt/HD_a2/logs/torrentwd.log 2>&1" >> $CRONTXT
/bin/echo "30 3 * * * /ffp/var/scripts/unpacker.sh >> /mnt/HD_a2/logs/unpack.log 2>&1" >> $CRONTXT

# install the new crontab
/bin/crontab $CRONTXT

# clean up
/bin/rm $CRONTXT


Note: The following explain how to set the interval. Feel free to change it.

* * * * * - means minutes, hours, day, month, weekday
Thus, "0 * * * *" means it runs every hour at the top of the hour

Go back to the PuTTY window and add editcron.sh to the list of packages that will start each time the DNS starts up.

Edit: 23rd September 2009 - An anonymous poster put up an comment on this blog. This person commented on the following.

For "/bin/echo "* * * * 2 /ffp/var/scripts/updateblocklist.sh >> /mnt/HD_a2/logs/updateblocklist.log 2>&1" >> $CRONTXT"

You may want to change it to something like "/bin/echo "0 0 * * 2 /ffp/var...." so it only runs once every Tuesday instead many, many time on Tuesday.

I found this site which explains the scheduling in detail. http://www.developerspot.com/print/php/unix-webserver-crontab-basics/

     root@YourDNS:~# cd /ffp/start
     root@YourDNS:/ffp/start# chmod a+x editcron.sh

Now you need to test it.

     root@YourDNS:/ffp/start# crontab -l {This should list existing crontab, without torrentwatchdog.sh and updateblocklist.sh}

     root@YourDNS:/ffp/start# ./editcron.sh

     root@YourDNS:/ffp/start# crontab -l {This should now list crontab with torrentwatchdog.sh and updateblocklist.sh}

 
13. Making DNS available outside of your home

Most router nowadays has the DDNS option built in. All you need to do is to enable this function in your router. Subscribe to the DDNS service. Next, most importantly, you need to open port 9091 on your router. From outside of your home, activate your broswer and point to your DDNS address.

Example: http://outsideyourhome.dyndns.org:9091

Now you are able to access your transmission from anywhere.

14. Conclusion

Finally, after doing all of the above you should have your DNS running Transmission bit torrent client which requires you to input your username and password. You will be able to access your transmission web interface from anywhere, as long as you have an internet connection. This allows you to check up on the progress of your torrents downloading and to start new torrent as you are able to upload the torrent filt via the transmission web interface. Your transmission is enable with encryption and blocklisting which helps in the bittorent performance.

Lastly, the updateblocklist script will update the blocklist automatically each first day of the week. The torrentwatchdog script will check for finished torrents and stop it. This script runs once every hour.

Enjoy your DNS.


Wednesday, November 12, 2008

Modding my DNS-323




Since having bought the DNS-323 I have reading all information that I can find on how to mod the DNS-323.

I found much information from http://forum.dsmg600.info/f3-DNS-323-General-Discussion.html forum. This forum is dedicated on modding of the DNS-323.

I also found another blogger that has posted a very good guide on modding of the DNS-323. His blog can be found at http://www.horto.ca/?p=10

I'm putting up my version of the guide as a reference for myself should I need to re-do my NAS again. I'm a newbie when it comes to unix thus the need to document all this down.

1. First step is to install Fonz fun-plug0.5

The first thing that you need to do is to download Fonz fun-plug0.5 from http://www.inreto.de/dns323/fun-plug/0.5/

The files to download are
  1. fun_plug
  2. fun_plug.tgz
After having downloaded the two files, open "My Network Places" and access the DNS-323 Volume_1 by typing the following

\\(IP address of the DNS-323)\Volume_1

If you do not know how to find out the IP address of your DNS-323, Dlink does provide a software call "Easy Search Utility". If you cannot find the original disc that came with your NAS, you can download the software by going to Dlink website.


Copy
  1. fun_plug
  2. fun_plug.tgz
to
\\(IP address of the DNS-323)\Volume_1

Reboot the DNS-323 and wait for it to come online. Fonz fun-plug should auto-install itself.

Once the fun-plug has been installed, you will be able to Telnet to your NAS.

2. Setting up Telnet on the DNS-323

Click on "Start", "run" and type in "cmd". The command prompt window will open. In the command prompt window type "telnet (IP address of the DNS-323)"

You will see a "/# " prompt. It mean you have successfully telnet to the device.

The firmware comes with a disabled root account that cannot login the normal way. This is the reason funplug starts an open telnet server that circumvent the normal login procedure to provide a root shell directly.

To fix this , you should run pwconv to update /etc/shadow, set a password and change the shell.

/# pwconv
/# passwd
/# usermod -s /ffp/bin/sh root

If you omit the usermod command, login will start the shell configured for user 'root' in /etc/passwd. Before saving your changes, you should run additional checks on the password and group files. Some firmware versions duplicate the ftp user and now is a good time to fix this.

/# pwck
/# grpck

You may ignore the warnings about missing home directories and invalid group names.

If you are asked to remove a duplicate user, say 'yes' to remove one of them. Rerun the commands to check that it is fixed.

Test the changes with the login program by typing

/#login

type in 'root' then the password that you had created.

If you are successful in logging in then you will need to save the password files to the flash memory by typing the following

root@example:~# store-passwd.sh
Copying files to mtd1…
Copying files to mtd2…
Done.

3. Disable telnet and enable ssh for better secure communication.

Having successfully enable login with user 'root' and password, you will want to enable ssh for better secure communication.

Enable ssh permanently with the following steps via telnet

First telnet to your DNS-323. After successful login, do the following.

/# cd /ffp/start
/ffp/start/# chmod a-x telnetd.sh {this command disable telnet and stops it from starting}
/ffp/start/# chmod a+x sshd.sh {this command enable ssh to start automatically and able to execute manually}

I use PuTTY for connecting via ssh to the DNS-323. It is a freeware and you can download it at http://www.putty.org/

Alternatively, another popular option is to use WinSCP. WinSCP is an open source free SFTP client and FTP client for Windows. Legacy SCP protocol is also supported. Its main function is safe copying of files between a local and a remote computer. It has PuTTY integrated which makes it convenient to use it when you need it.

WinSCP is very easy to use and let you copy files from your computer to the DNS-323 easily.

You can download a portable version from http://portableapps.com/apps/internet/winscp_portable

Next will be installing Transmission, a free and easy bittorrent client. You can find out more at http://www.transmissionbt.com/

Labels: , ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]