Marius van Witzenburg We fight for our survival, we fight!

30Jun/100

How to force your visitors to goto your website domain without www as a prefix with mod_rewrite in Apache

Posted by mariusvw

Actually this is quite simple, you need to create a .htaccess file into your public_html / httpdocs directory and add the following piece of code:

Force non-www

# Force non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^kitara.nl
RewriteRule (.*) http://kitara.nl/$1 [R=301,L]

Force www

# Force www
RewriteCond %{HTTP_HOST} !^www.kitara.nl
RewriteRule (.*) http://www.kitara.nl/$1 [R=301,L]

Of course you need to modify this to match your own domain name :-)

13Jun/100

How to install Transmission BitTorrent client on FreeBSD

Posted by mariusvw

Transmission is a fast, easy and free BitTorrent client.

This manual is for Transmission 2.00 and higher. Our plan is running it as a daemon with a web interface.

Installation
Install required ports:

cd /usr/ports/net-p2p/transmission-daemon ; make install clean

Login to unpriv account and start transmission-daemon.

su - mariusvw
 
transmission-daemon

Now transmission created the default configuration kill it.

# Get current pid:
ps aux |grep transmission
# Kill it:
kill <PID>

Edit the configuration to your needs:

vi .config/transmission-daemon/settings.json

You can view an example config here:

{
    "alt-speed-down": 1500,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 62,
    "alt-speed-time-enabled": true,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 100,
    "bind-address-ipv4": "",
    "bind-address-ipv6": "",
    "blocklist-enabled": true,
    "blocklist-url": "http://www.bluetack.co.uk/config/level1.gz",
    "cache-size-mb": 4,
    "dht-enabled": true,
    "download-dir": "/usr/home/mariusvw/Downloads",
    "encryption": 1,
    "idle-seeding-limit": 30,
    "idle-seeding-limit-enabled": false,
    "incomplete-dir": "/usr/home/mariusvw/Downloads",
    "incomplete-dir-enabled": false,
    "lazy-bitfield-enabled": true,
    "lpd-enabled": false,
    "message-level": 2,
    "open-file-limit": 32,
    "peer-congestion-algorithm": "",
    "peer-limit-global": 240,
    "peer-limit-per-torrent": 60,
    "peer-port": 53945,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": "default",
    "pex-enabled": true,
    "port-forwarding-enabled": true,
    "preallocation": 1,
    "prefetch-enabled": 1,
    "ratio-limit": 2,
    "ratio-limit-enabled": true,
    "rename-partial-files": true,
    "rpc-authentication-required": true,
    "rpc-bind-address": "192.168.1.2",
    "rpc-enabled": true,
    "rpc-password": "{2f9f20kco80wef8f02do20020488fc49626615IeDMuk3",
    "rpc-port": 9091,
    "rpc-url": "/transmission/",
    "rpc-username": "mariusvw",
    "rpc-whitelist": "127.0.0.1,192.168.1.40,2001:0000:0000::fe35:",
    "rpc-whitelist-enabled": true,
    "script-torrent-done-enabled": false,
    "script-torrent-done-filename": "",
    "speed-limit-down": 100,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 100,
    "speed-limit-up-enabled": false,
    "start-added-torrents": true,
    "trash-original-torrent-files": true,
    "umask": 18,
    "upload-slots-per-torrent": 14,
    "utp-enabled": true,
    "watch-dir": "/usr/home/mariusvw/Downloads/__WATCH",
    "watch-dir-enabled": true
}

Create download directories

mkdir /usr/home/mariusvw/Downloads
mkdir /usr/home/mariusvw/Downloads/__WATCH

Restart the daemon:

transmission-daemon

Surfto:

http://192.168.1.2:9091/transmission/web/

Have fun downloading! :-P

Optional and OLD scripts:
Dynamic Speed Script
Change maximum speeds on time period:

0 23 * * * /home/mariusvw/transmission-speed.sh fast &gt; /dev/null 2&gt;&amp;1
0 8 * * * /home/mariusvw/transmission-speed.sh slow &gt; /dev/null 2&gt;&amp;1

Create speed-change script: transmission-speed.sh

#!/bin/sh
action=$1
case $action
in
'slow')
/usr/local/bin/transmission-remote -n mariusvw:<yourpassword> -d 100 -u 10
;;
'fast')
/usr/local/bin/transmission-remote -n mariusvw:<yourpassword> -d 500 -u 50
;;
esac

Easy commands
You can use this to easily enter transmission-daemon commands without having to enter your username and password every time.

 #!/bin/sh
action=$1
if [ -n "$action" ]
then
/usr/local/bin/transmission-remote -n mariusvw:<yourpassword> $action
fi

I hope this is useful for the ones who like to work with Torrents and share easy without leaving on your desktop PC if you have a server available.

8Jun/100

How to upgrade Perl 5.8.x to 5.10.x on FreeBSD.

Posted by mariusvw

In the ports collection you can find /usr/ports/UPDATING. Here you can read how to upgrade Perl 5.8.x to the new release 5.10.x.

The description below is copied from the updating file.

Note: you might need to manually upgrade some ports after this. For example, I had to recompile APR, Apache and Subversion.

Portupgrade users:
0) Fix pkgdb.db (for safety):

pkgdb -Ff

1) Reinstall perl with new 5.10:

env DISABLE_CONFLICTS=1 portupgrade -o lang/perl5.10 -f perl-5.8.*

2) Reinstall everything that depends on Perl:

portupgrade -fr perl

Portmaster users:

env DISABLE_CONFLICTS=1 portmaster -o lang/perl5.10 lang/perl5.8
portmaster -r perl-

Note: If the "perl-" glob matches more than one port you will need to specify the name of the perl directory in /var/db/pkg explicitly.