Friday, May 23, 2008

Installing Torrentflux-b4rt on Ubuntu/Debian

Torrentflux is an excellent torrent creation, downloading, and seeding program that is used in Linux, and is especially helpful in a multi-user environment, as it maintains separate directories for everyone with an account. That being said, let's get started! In order to have a working install of torrentflux, you need a LAMP (Linux, Apache, MySQL, PHP) installation (I should note that lighttpd will work in place of Apache, but for this guide, we're going to use Apache). Let's start with that. (NOTE: if any commands come back with permission problems, simply add sudo to the front of the command, e.g. sudo apt-get rather than just apt-get).

Before doing anything, you should do this:


apt-get update
apt-get upgrade



This will bring your install up to date on all of the installed components (chances are, any box you've gotten from a provider is not up to date, so this is a necessary step).

Now, installing a LAMP.


apt-get install apache2 php5 php5-mysql mysql-server php5-cgi



Now that we've installed a LAMP, we need to set up MySQL. First, we create the root password for MySQL.


MYSQL_PWD=putapasswordhere (I strongly suggest not using your machine's root password)



To verify the entry of the password, we type:


echo "Your password for the root account of MySQL will be : '$MYSQL_PWD'."



What's echoed should be what you put in above. Next, we tell MySQL what password to use.


mysqladmin -u root password "$MYSQL_PWD"



Now that we have that all taken care of, we need to create a database for torrentflux to use. We do this by naming the database:


MYSQL_DB=putadatabasenamehere (I normally just use torrentflux as my database name, but you can choose whatever you want)



and then creating it:


echo "CREATE DATABASE IF NOT EXISTS $MYSQL_DB DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci" \
| mysql --user=root --password



The password that it will ask for above will be the root password you defined in the first step of setting up MySQL.

Now, we need to actually create a user (and their subsequent password) to use the database. We do this by:


MYSQL_USERNAME=putausernamehere (up to you what to use, but remember what you put here)
MYSQL_USERPWD=putapasswordhere (again, I strongly suggest a different password than what's already in use)



To make sure the information you've put in is what you want, we'll ask the system to echo it back to us:


echo "The user account allowed to manage the '$MYSQL_DB' database is '$MYSQL_USERNAME' with password '$MYSQL_USERPWD'."



Now that we've created a user and password, we have to create that user in your new database.


echo "GRANT ALL PRIVILEGES ON $MYSQL_DB.*
TO $MYSQL_USERNAME@localhost
IDENTIFIED BY '$MYSQL_USERPWD';" | mysql --user=root --password



This will again prompt for that password we created when we first started setting up MySQL. Now, our work with MySQL is pretty much done. Now we move on to installing torrentflux itself.

First, we start off with installing its dependencies:


apt-get install bzip2 php5-gd php5-cli unrar-free grep python \
net-tools mawk wget unzip cksfv vlc-nox uudeview python-psyco python-crypto \
libxml-simple-perl libxml-dom-perl libdbd-mysql-perl libdigest-sha1-perl \
bittorrent bittornado



Once that's done, we can get to the nitty gritty install. First, we want to download torrentflux-b4rt:


cd /tmp/
wget http://download.berlios.de/tf-b4rt/torrentflux-b4rt_1.0-beta2.tar.bz2



Now, we need to extract it:


tar -xjf torrentflux-b4rt_1.0-beta2.tar.bz2 (alternatively, you can type torrent and press tab, and it should autocomplete the whole name of the file for you, assuming you don't have any other files in the /tmp/ directory with similar names



Now, we need to move torrentflux to its home:


mv torrentflux-b4rt_1.0-beta2 /opt/torrentflux



Now, we want to create a symbolic link from it's home to a place where the web front-end is visible and available to the HTTP server:


ln -s /opt/torrentflux/html /var/www/torrentflux



Now we need to make the configuration file writable by the webserver:


chown -R www-data:www-data /var/www/torrentflux/inc/config/



Now we need to create the download folder for torrentflux. Some things should be considered before doing this:

1. Are you going to be running an FTP server on this box as well? If so, you should make the torrentflux download directory the root of that FTP server
2. Are you going to be using glftpd as your FTP server? If so, I strongly suggest using /glftpd/site/ as your download directory.

That being said, let's assume you're not using any FTP server at all.


mkdir /var/lib/torrentflux



Now, we need to make it writable by the HTTP server:


chown -R www-data:www-data /var/lib/torrentflux



Most of the work through PuTTY is done. Now, we need to go about configuring it.

Before we do that, we want to restart apache to make sure it has everything loaded that it needs to.


/etc/init.d/apache2 restart



Once that's done, go to your web browser and type:


http://ipofyourbox/torrentflux/



This should forward you directly to setup.php and you can begin there. If it doesn't, simply add setup.php at the end of the above url.

For the most part, the web interface is self explanatory:

When prompted for what type of database you're going to use, use MySQL.
When prompted for the database information for your MySQL database, remember what you named the database, the user you created for it, and the password you created for that user.
[1*]Uncheck the box for "Create new database"
When asked what the Download location will be, use the directory you specified above (this guide has /var/lib/torrentflux as that directory)
On the software dependencies screen, you may have an error for unrar. That's ok, as we'll just adjust that after torrentflux is running. On Debian, VLC may show an error as well..this is ok, as you likely won't be using VLC.
At the completion of the configuration, it will tell you that it could not delete setup.php. This is normal. We'll be doing that manually.

Now, we remove setup.php.


rm /var/www/torrentflux/setup.php



Then, we make it so that the HTTP server can no longer right to the config folder:


chown -R root:root /var/www/torrentflux/inc/config/



We're just about done! Go back to your browser and type:


http://ipofyourbox/torrentflux



This should autoforward to login.php. If it doesn't, simply put login.php at the end of the url.

The first account you'll create is the superadmin account. This account is the only one that has all the features in it. I suggest using admin as the username, and a strong password for the password.

Once logged in, there are a lot of things to play around with, and ultimately, it's up to you to adjust as you see fit. The first page you'll want to look at is the server page, and adjust the unrar dependency. Simply add -free to the end of it, and you'll be fine with that.

Secondly, you'll want to look at the transfer page, where you'll want to adjust the max bandwidth for your connection (e.g. 12500 for a 100Mb connection). Alternatively, you could just put 0 and let it use the max available bandwidth. The rest of the settings are really up to you (I also strongly suggest using bittornado as yoru default torrent client).

That pretty much sums up this guide for installing torrentflux-b4rt.

Thanks to Lone Wolf

Wednesday, May 21, 2008

Speed up downloads - increasing the half-open TCP limit in XP SP2 and Vista

Now if your new to BitTorrent, you might be new to downloading. If so you should know that Microsoft introducted a limit to stop many TCP connection attempts in XP SP2. This well-intentioned modification came as an attempt by Microsoft to limit the speed at which malicious worms (such as the infamous ‘Blaster’) could spread.

However, for software that relies on many connections such as bittorrent applications, this limit has the potential to cause slowdowns in certain situations. So what you want to do is change the half-open limit to a higher number.

For Windows XP SP2: http://www.lvllord.de/?lang=en&url=downloads
unzip it to your desktop and then run the .exe file. Follow the instructions and then change your limit to 75 or higher. Make sure you restart your computer immediately after it is finished--like it tells you.

For Windows Vista: http://www.yaronmaor.net/repair.htm
choose the right fix depending on your version of your tcpip.sys file.

There, now you will certainly increase your download speed, and possibly your upload speed as well.

Monday, May 19, 2008

The Future of Artificial Intelligence

Artificial Intelligence is a term that has suffered from a lot of inflation the past years, with too many companies gladly and freely using the term for marketing to describe their (most definately not "AI") products. That probably has put many off.

This must be very frustrating for researchers in cognitive engineering and neuroscience because really massive steps forward are being made in understanding how the brain works thanks to their hard work.

Understanding how consciousness is formed is of course not the same as simulating it on a computer.
Still, thanks to this understanding expect many steps forward with adaptive / learning / evolving algorithms. These will find their way in the near future into robots, neural prosthetics, UAV's, image recognition, automonous vehicles, your washing machine and much more.
Look on the site of DARPA (always a good indicator) and you'll see the importance the US Army is placing on "intelligent" technologies.

So yes it is the future. But more in terms of a strategic direction than actual products.

Saturday, May 17, 2008

Choosing a Content Management System


I have had direct experience with Mambo, Drupal, Apache Lenya, WordPress, Plone, and Zope on everything from small company websites to sites served to millions of users. Here are a couple angles that I keep in mind when selecting the right CMS for any given job:

* How do you want to use it? Many people get hung-up on features lists, pitting various CMSes against one another in a matrix of checks and X's, but this is almost always misleading. You don't seem to be heading down that particular rabbit's hole when you say you want to "edit/change/add/remove pages," but it can become tempting. Writing down some quick use case scenarios can be a good way to stay on track. For a basic CMS I would steer clear of Drupal (even though I'm quite fond of it ;) or Zope and prefer something like WordPress or MovableType.

* How do you foresee your site growing? Drupal and Zope provide a "everything and the kitchen sink" approach that gives you quite a bit of flexibility, but the trade-off is that they assume a certain technical sophistication. Correspondingly, WordPress or MovableType are excellent choices for small sites where workflows are simple or nonexistent, but if you have a need for complex workflows or integrations then they can become constraining. Thinking now about your future needs can save you the pain of a migration later on.

* How do you want to publish to the site? If you want to make changes instantly on the site and don't plan to stage your content, then WordPress, Drupal, or MovableType are good choices. On the other hand, if you need to stage it prior to deploying it to your production site then Apache Lenya would be a good fit, although its learning curve is steep. The trend these days is away from staging content, but sometimes performance considerations or an organization's culture demand it.

* What kind of support, if any, do you want for your CMS? Some CMSes have small consulting industries surrounding them, or are sponsored by a commercial entity that provides support. If it is important to you to be able to pick up the phone and call someone when things break then you should survey the field before selecting a CMS.

Learning curve for C programmers : C++ vs Java


All other things being equal ... actually, all other things are hardly ever equal, so it would be good to know more about your goals. (In particular, what performance goals do you have? Are you doing hard real time systems? Games? Web development? More rapid development is always better than less rapid development, but how much development speed might you willing to trade off for software execution speed? Put another way: If you got your software working, but slowly, what forces would be at play with new features vs. better performance? I'm not saying Java performance is bad, I'm just trying to characterize your goals.)

The Java language is easier to learn than the C++ language. The Java runtime libraries are much bigger (and provide a lot more functionality) than the C++ standard library; and thus, take more time to learn.

Software written in Java is not inherently slow; software written in C++ is not inherently fast.

Tool support is better for Java than C++. Yes, you can use Eclipse for either; but I think Eclipse's Java support is far more mature than its C++ support. I've used Visual Studio and C++, and I've used Eclipse and Java, and I'm far more impressed with the latter. Java compiles much faster than C++. Also, FindBugs is awesome.

The link below shows programming language book sales. Java is the big spike. Make of this what you want.

Friday, May 16, 2008

glftpd and zipscript install guide


So, you need an FTP server on your box, and you don't know which one you should use? I'll solve that dilemma for you. glftpd is easy to install and is a fully functional, fairly robust FTP server.


That being said, lets get started! (NOTE: if any command spits back a permissions error, simply put sudo in front of the command).


cd /tmp/
wget http://www.glftpd.com/files/glftpd-LNX_2.01.tgz
tar -xzf glftpd-LNX_2.01.tgz



Let's grab the dependencies we need to get glftpd to work properly


apt-get install xinetd zip unzip openssl tcpd



Now, we move into the glftpd directory


cd glftpd-LNX_2.01
sh installgl.sh


For the prompts, do:

Use tcpd? [Y]es [N]o: Y
Use a jailed environment? [Y]es [N]o: N
Please enter the directory to install glftpd to [/glftpd]: (press enter) - Installing into /glftpd is the best way to go, imo
Press for the default (glftpd)> (press enter)

The install will then compile (hopefully with no errors).


Enter the port you would like glftpd to listen on [1337]: (pick any port, I suggest something in the higher # range, 40000 plus)
Do you want to use [I]netd or [X]inetd? X
Do you wish to use European weeks? European weeks starts with a Monday.
This is for glftpd's 'reset' binary (see docs for more info) [Y/N]: Y
Please specify location, inside /glftpd, to install the cert (ftpd-dsa.pem) [/etc]: (press enter)
Please specify a generic name for this certificate. This can be any name but should say something about the ftp server like the name for it perhaps (press enter for glftpd): (you can put just about anything here...doesn't matter)


It will then create your certificate. Once that's done, glftpd is almost completely set up.

What you'll want to do next is set up your user account for the FTP. To do this, you:


ftp localhost port
user: glftpd
password: glftpd


This will get you logged in.

Once logged in, you want to create a user, set its flags, set its ratio, set its logins, set its ratio, etc.


site adduser user password ip [e.g., site adduser ronin hdwhore 127.0.0.1) And no, don't use localhost as your IP..was just using that as an example.
site change ronin ratio 0
site change ronin num_logins 0 (if you want unlimited logins to your FTP)
site change ronin flags +1ABCDEFGH


That takes care of the account. Now you're going to want to edit the glftpd.conf. 

To do so, you:

nano /etc/glftpd.conf


There's not much you NEED to edit here, so I'll just highlight what you should.


sitename_long MY[:space:]SITE[:space:]NAME (put whatever you feel like here)
sitename_short MSN (short version of the above
# TLS enforcements.
userrejectsecure !*
userrejectinsecure !* (remove the ! to enable Auth TLS requirements for login)
denydiruncrypted !*
denydatauncrypted !*



The rest doesn't need to be touched, unless you so choose to. CTRL+O, press ENTER, CTRL+X, and you're done editing the file. That completes the install for glftpd. Now, for zipscript.


cd /tmp/
wget http://se.pzs-ng.com/stable/project-zs-ng_r2414-v1.1.0a.tar.gz
tar -xzf http://se.pzs-ng.com/stable/project-zs-ng_r2414-v1.1.0a.tar.gz
cd http://se.pzs-ng.com/stable/project-zs-ng_r2414-v1.1.0a.tar.gz
./configure



When that's done, you need to edit zipscript/conf/zsconfig.h


nano zipscript/conf/zsconfig.h




I recommend changing the following folder listings below:


#define zip_dirs "/site/"
#define sfv_dirs "/site/test/ /site/incoming/mp3/ /site/incoming/games/ /site/incoming/apps/ /site/incoming/musicvideos/ /site/incoming/requests/"
#define audio_nocheck_dirs "/site/groups/ /site/incoming/requests/"
#define check_for_missing_nfo_dirs "/site/incoming/games/ /site/incoming/apps/"




If you don't do music, ignore the auto_nocheck variable

You'll also want to edit:


#define short_sitename "NG"


CTRL+O, PRESS ENTER, CTRL+X, and you're done editing zsconfig.h


make
make install
cd scripts/libcopy/
./libcopy.sh
chmod 666 /glftpd/ftp-data/logs/dupelog (this assumes you installed into /glftpd/)
nano /etc/crontab/
paste the below into your crontab
59 23 * * * chroot /glftpd /bin/cleanup >/dev/null 2>&1
29 4 * * * chroot /glftpd /bin/datacleaner >/dev/null 2>&1



Once that's done, you have 1 more step, and zipscript is complete.


nano /etc/glftpd.conf




Copy/paste this somewhere into your glftpd.conf


calc_crc *
post_check /bin/zipscript-c *
cscript DELE post /bin/postdel
cscript RMD post /bin/datacleaner
cscript SITE[:space:]NUKE post /bin/cleanup
cscript SITE[:space:]UNNUKE post /bin/postunnuke
cscript SITE[:space:]WIPE post /bin/cleanup

site_cmd RESCAN EXEC /bin/rescan
custom-rescan !8 *

cscript RETR post /bin/dl_speedtest

site_cmd AUDIOSORT EXEC /bin/audiosort
custom-audiosort !8 *



CTRL+O, PRESS ENTER, then CTRL+X.

You'll likely want to chmod the incoming (/glftpd/site/incoming) to 777, and any other directory you might dump into:


chmod -R 777 /glftp/site/*


Once that's done, you're done setting up your zipscript.

You now have a fully functioning FTP and file checker installed on your box, and it's ready to be used.

Wednesday, May 14, 2008

Bit VS Byte....The Broadband Saga

Let's put some light into the bits and bytes discussion.

A lot of people say.... Hey! My ISP said I have 4096/512 kbps speed. So how come, that my torrent client is showing 512/64 kB/s?

It is a simple answer.

Bit is a binary digit, taking a value of either 0 or 1. For example, the number 10010111 is 8 bits long, or in most cases, one modern PC byte. Binary digits are a basic unit of information storage and communication in digital computing and digital information theory.

So, as we see, the smart marketing people paid by ISPs are actually telling the truth. They are talking about bits. And they know, people love big numbers. So why should we say 512 kB/s download, when we can say 4 Mbps (4096 kbps). Huge numbers are better, a lot better for managers and salesmen.

So if you really want to know, what your speeds will be before you sign the next suped duper speed ISP contract, take a calculator, divide kbps by 8 and you will get the torrent client UL/DL speeds.

Here is also some more info about it http://www.t1shopper.com/tools/calculate/ and wikipedia http://en.wikipedia.org/wiki/Bit

Also google.com can help you just enter "4096 kb = ? kB" and change the 4096 with wanted conversion.

Hope this clears things a bit.