Showing posts with label guide. Show all posts
Showing posts with label guide. Show all posts

Saturday, January 10, 2009

Sending email using either ISP or Gmail account


If you want to be able to send e-mails without having to set up a full-fledged MTA like sendmail or exim by just using an isp email account or gmail account follow this tutorial. By the way I only need this to receive log messages to my e-mail regularly, it is not for checking your mails form the slug... I found this tutorial on the net and it was mainly built for ubuntu. I changed and simplified some of the steps to make it easier to use.

Install the needed programs
apt-get install msmtp
apt-get install nail


Install Thawte certificate for Gmail.(This is necessary for Gmail. I tried and without this it is not working ;) )
mkdir -p ~/etc/.certs
chmod 0700 ~/etc/.certs
cd ~/etc/.certs
wget https://www.verisign.com/support/thawte-roots.zip --no-check-certificate

Option 1)
Ooops at this step at the original tutorial it says to use unzip. I do not have unzip in my slug and I do not want to install it for one time use. So I copied the zip file to my laptop, unzipped and send to the server again. You could follow either way I gue

Option 2)
unzip thawte-roots.zip
cp Thawte\ Server\ Roots/ThawtePremiumServerCA_b64.txt ThawtePremiumServerCA.crt
Then configure msmtp.Replace UPPERCASE text with your personal settings
nano ~/.msmtprc


Paste the config file given below to the .msmtprc.


# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
defaults
logfile /var/log/msmtp.log

# isp account
account isp
auth login
host SMTP.YOURISP.COM
port 25
user YOURNAME@ISP.COM
from YOURNAME@ISP.COM
password *****

# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user YOURNAME@gmail.com
password *****
from YOURNAME@gmail.com
tls on
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt

# set default account to use (from above)
account default : gmail


Change permission of the msmtprc file:
chmod 600 ~/.msmtprc

Configure nail
nano ~/.mailrc

Copy/paste the config file below into .mailrc and make the necessary changes for your congiguration.

# set smtp for nail
# ref: http://ubuntuforums.org/showpost.php?p=4531994&postcount=6
# docs: http://msmtp.sourceforge.net/doc/msmtp.html#Configuration-files
# isp account (default)
# $ nail -s "subject line" -a /path/file recipient@email.com < /path/body.txt
set from="YOURNAME@ISP.COM"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a isp"

# gmail account
# $ nail -A gmail -s "subject line" -a /path/file recipient@email.com < /path/body.txt
account gmail {
set from="YOURNAME@gmail.com (YOURNAME)"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
}

You are all done. Now you can send test messages…


echo -e "testing email from the command line" > /tmp/test_email
nail -s "isp test" YOURNAME@gmail.com < /tmp/test_email nail -A gmail -s "gmail test" YOURNAME@gmail.com < /tmp/test_email

Check your email accounts for the new messages. You can chech the log file with the command below.
nano /var/log/msmtp.log

This is the procedure I followed to use my gmail account and it worked great. But some said that it is sufficient to use either msmtp or nail for this purpose. So if you know how to do that tell us. I tried that way for a while ago and I could not make it work maybe it is because I did not use certificate. Anyway, hope this helps someone.
This is the link to the original tutorial if you want to check http://phosphorusandlime.blogspot.com/2008/05/ubuntu-command-line-email.html

Thursday, January 8, 2009

Custom 404 error page for your Lighttpd webserver


It would be cool to have a custom 404 error page for your webserver. It is very easy to do thoughh, just edit lighttpd.conf.
nano /etc/lighttpd/lighttpd.conf

find the line below in this config file
#server.error-handler-404 = "/error-handler.html"

and uncomment it to
server.error-handler-404 = "/error-handler.html"

Now, you create a file called error-handler.html in your www root ( for my case /var/www/ ).
Restart the server to apply changes
/etc/init.d/lighttpd restart

That is all. You have a custom error page right now. Here is mine :)


Tuesday, January 6, 2009

MySQL server setup with phpmyadmin


If you want to have Mysql server in your little slug you should follow the guide. I installed it to try with wordpress but it was painfully slow. So I decided to remove it at least for now. But if you want to give it a try or if you need it for a specific application follow me :)
Install the mysql

apt-get install mysql-server

Then install phpmyadmin by typing

apt-get install phpmyadmin

when it ask you to for your webserver select lighttpd. (If you use something else then choose that one). Then restart your slug

shutdown -r now

That is all. Now you have a MySQL server with phpmyadmin interface.In my case I wrote

http://192.168.1.77/phpmyadmin/index.php
to reach the phpmyadmin interface.
By the way it is not secure to use it like this. You should create a password. As I do not use it I do not know the details but you can google around for securing your MySQL+phphmyadmin combination. See you next time...

Free more memory


Your little slug has only 32mb of memory. I know that you want to run a lot of useful applications with your slug then why do not you remove some of the applications already installed in your slug and free more memory. Actually I can feel the difference in my slug after removing the mentioned applications. It takes much less to load my website right now...

First you can think of disabling and removing exim4. (mailserver AFAIK - free 7 mb ram)
/etc/init.d/exim4 stop;
update-rc.d -f exim4 remove
apt-get --purge remove exim4-daemon-light exim4-config exim4-base

Also if you do not use nfs service (drive sharing AFAIK) just disable and remove it.
/etc/init.d/nfs-common stop;
update-rc.d -f nfs-common remove
apt-get --purge remove nfs-common

External HDD spindown issue


This guide shows how to automatically spindown your external hard drives connected to your NSLU2. Isn't it great to stop your external hdd when you are not using it. This will also extend the lifetime of your external hdd. I have been using this with my NTFS formatted hdd for a couple of months and I am very satisfied.
We need a program to control the harddisk connected to your NSLU2. SG3-utils will do it for us. To install write
apt-get install sg3-utils

After the installation you can try to spindown your harddrive to test if it's working.
In my case I wrote
/usr/bin/sg_start --stop /dev/sdb

If it works you are almost done. Let us automatize it now.Spindown is a daemon that spins down idle disks and so saving energy and giving the disks a longer lifetime. You can check http://code.google.com/p/spindown/ for more information. Follow the steps below to install it into your Debian machine. You may change the "spindown-0.2.2.tar.gz" parts according to the latest version.

cd
mkdir xxx
cd xxx
wget http://spindown.googlecode.com/files/spindown-0.2.2.tar.gz
tar xvzf spindown-0.2.2.tar.gz
cd spindown-0.2.2
make
make install


After compiling and installing the spindown you still need to configure it. I prepared a sample config file for you. Create spindown.conf by typing
nano /etc/spindown.conf

and copy and paste the lines below into this file.

[General]
cycle-time = 60 # Number of seconds between cycles.

idle-time = 3600 # The time in seconds a disk has to be idle before it is spundown.
# Do not use a value that is to small (less than 3600) unless you
# know what you are doing.

syslog = 0 # Turn this on if you want spindown to log messages using syslog.
# You will not want to turn this on if you are trying to spindown
# the disk with the root filesystem on.

[Disk 0]
name = sdb
spindown = 1
command = sg_start --stop


You will need to change name = sdb into something else depending which drive you want to stop or you can make it stop multiple drives. Check the website I gave before for more information.

Now you have your configuration file. It is time to start the daemon, write
/etc/init.d/spindown start

when you write the line below
/etc/init.d/spindown status

you should see something like



You can change the spindown time from the config file. 3600 is fine if you do not know what you are doing. Hope this helps. Write comments if I miss something.
Good luck...

Reading/Writing to NTFS in Debian


You do not have to format your existing harddrive with ext3 to use with slug. You can make Debian read it for you. By this way you can use the external drive when you disconnect from the slug in any windows machine easily.
I prefer to use ntfs-3g for this purpose. There are other packages for this purpose but I believe this is the best. To install write
apt-get install ntfs-3g

To see the list of connected drives you can use tree.
apt-get install tree

You should see your NTFS formatted drive in the list by typing
tree /dev/disk

You should mount the drive to use it. You can use
mount -t ntfs-3g /dev/sdb1 /mnt/hdd -o force

or
mount -t ntfs-3g /dev/sdb1 /mnt/hdd

to mount it. You will need to change sdb1 according to the screen you get with tree. Also you should have a directory created /mnt/hdd to mount. Write
mkdir /mnt/hdd

to create that directory. Good luck.

Mt-daapd - Firefly Media Server Installation


It is great that you can serve your music with this little tool. I prepared a guide for you to install firefly. Just follow the steps and hopefully you won't experience any problem. I recommend you to install all the packages below. I experienced a problem before and these packages resolved the issue.

apt-get install avahi-daemon
apt-get install libgdbm-dev libid3tag0-dev
apt-get install libsqlite0
apt-get install libsqlite0-dev
apt-get install gawk
apt-get install gcc
apt-get install mt-daapd


After these steps you should be able to log on using by typing the ip of your NSLU2. In my case I wrote

http://192.168.1.77:3689

to log in. And use "admin" as user name and "mt-daapd" as password for the first time login. You can change the config later through the web page. You should change the location of your music files before beginning to scan.

You can also change the config by editing the config file. Config file location: /etc/mt-daapd.conf
By the default settings, after the scan you will end up with having a database located at
Database : /var/cache/mt-daapd

You can start/stop Firefly media server by typing
invoke-rc.d mt-daapd start|stop|restart

invoke-rc.d mt-daapd start will start the server...

You can also write
mt-daapd -f

this will show you what the daemon is doing and the encountered errors. I also use this command to scan the directories for mp3. Somehow this is much faster than scanning the directories using the web interface.

If you have something to add to the firefly webpage it is located at: /usr/share/mt-daapd/admin-root

For example I added a flash player to that page. So I can easily listen to the music wherever I want.You can download the flash player from : http://www.mellberg.org/FirePlay.zip

Add the line below to the top of FirePlay.html
@include hdr.html@

and change
'width', '100%',
'height', '100%',

to
'width', '800',
'height', '600',

Also edit the hdr.html and add the line shown below.(Click to enlarge)


That is all. You should have a built in flash player now.


You can also use itunes but if you want to have a standalone java client you can look at http://sourceforge.net/projects/fireflyclient. Hope this guide helps someone.

Thursday, December 11, 2008

Transmission - Torrent download client


As you have a deice always running why do not use it to download your torrents. Follow the steps and you will have a device able to download torrents...

First install the required packages required that has build function
apt-get install pkg-config
apt-get install libc6-dev g++ gcc libssl-dev libcurl4-openssl-dev gettext intltool
cd
mkdir tmp
cd tmp
wget http://download.m0k.org/transmission/files/transmission-1.41b2.tar.bz2
tar xvf transmission-1.41b2.tar.bz2
cd transmission-1.41b2
./configure --disable-mac --disable-beos --disable-gtk --disable-wx
make
make install
If you don't want cli access just web access add --disable-cli to the end of the ./configure line. Alternatively if you don't want web/remote access just the cli add --disable-daemon. To add user type
adduser --disabled-password transmission
Download the init script
http://rapidshare.de/files/46348312/transmission-daemon.html

You can change the required fields in the script like download directory and the password.Then copy the script into /etc/init.d/. You can start/stop the transmission by typing
/etc/init.d/transmission-daemon start
/etc/init.d/transmission-daemon stop
Now you have a working torrent download machine. You can connect the web interface by typing 192.168.1.77:9091 and start downloading...

Lighttpd eaccelerator support



This is a highly recommended setup for your nslu2. As your slug has very limited resources you better install this to make it run pages faster. You will notice the difference if you are running a content management system. Run the codes below step by step to install eaccelerator on your system. It is basicly a caching We are not using apt-get this case as it debain has no package for this.
apt-get install build-essential php5-dev
mkdir work
cd work
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
tar xvfj eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
phpize
./configure --with-eaccelerator-userid=nobody
make
make install
Create eaccelerator.ini file
touch /etc/php5/conf.d/eaccelerator.ini
copy these into the file
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.d****="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
As you see, we are using the disk cache directory /var/cache/eaccelerator which we must create now and make it world-writable:
mkdir -p /var/cache/eaccelerator
chmod 0777 /var/cache/eaccelerator
then restart the server
/etc/init.d/lighttpd restart
After the restart the server if you write http://192.168.1.77/info.php and go the the info page you should see a new block like

Webserver installation - lighttpd

If you want to use your slug as a webserver with php support you should follow the steps through and you will have a webserve with php support.
first write
#touch /.ext3flash
to prevent your flash disk drive wear out.Then update the package list using
#apt-get update
After these install the required packages using
#apt-get install lighttpd
#apt-get install php5-cgi
#apt-get install php5-gd
After the install, open lighttpd.conf:
#nano /etc/lighttpd/lighttpd.conf
Add the code below under server.modules, like this:
"mod_fastcgi",
at the end of the file add
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket",
)))
After adding the code, save and exit.
try the server if it is working or not. Create info.php at /var/www/info.php
touch /var/www/info.php
edit this file
nano /var/www/info.php
write
?php
phpinfo();
?>
save and exit.Restart the server
/etc/init.d/lighttpd restart
Type your address and try
http://192.168.1.77/info.php
I hope you can see something and the guide worked for you.See you in the next guide

Installing debian on NSLU2


Hi,
NSLU2 is a very useful device and can do a lot of things. By installing Debian you can use your slug as a full linux machine. First step is how to install Debian linux to the slug.

First you have to get the slug into upgrade mode to flash the new firmware. Turn off the slug and while holding the reset key on the back turn it on. After a while you can see the orange light will become red. At that time immediately release reset key.

You must be seeing a red light blinking telling you that you did it right :). Now you have to install the firmware to the slug. It is adviced you to install latest debian .Go to

http://www.slug-firmware.net/d-dls.php and download the latest firmware.(For now it is debian-armel-5.0rc1.zip)

Now you need an updater to send this firmware to the device. From

http://www.nslu2-linux.org/wiki/Main/SercommFirmwareUpdater

you can download a tool to send the firmware to the NSLU2. (This tools work on xp and vista but not on vista x64, keep in mind).

With the tool you can search the wireless devices and select the firmware from your drive and send to the slug. It will take roughly about 10 to 15 minutes.

After the firmware update do not touch the slug. It will reset automatically and you will hear three beeps when it is ready.

Now you are ready to connect to the device. You can use putty to connect to the device. It is a free software and you can donwload it from

http://www.chiark.greenend.org.uk/~sgtatham/putty/

Once you download enter the ip of your nslu2 to connect.

installer is the user name install is the password for this release of the firmware. Now you should see a simple GUI for the installation. Just follow the steps. DONT SELECT ANY OTHER SERVICE WHILE INSTALLING (webserver, ssh server...). later it will ask some questions like the root password.

It will take about 4 to 5 hours to complete the installation. So do not close the putty during the install. Otherwise you will begin the process from the beginning(after the installation of firmware). Be patient and in the end you will have a lovely debian running NSLU2.

It will reset itself after the installation ends. You can log on using putty, root as user and the password you choose at the installation.

I am using 8gb of usb drive as the installation disk. I used 1gb drive before but it is very small for debian and you will not install much application if you use 1 gig. I will advice at least 2 gb of flash disk for the install.

You can also look at this guide if you are having problems during install
http://www.cyrius.com/debian/nslu2/install.html

Wait for the other guides for the cool applications