Saturday, February 28, 2009

Synaptic Search Bug in Intrepid

There seems to be a bug in Intrepid that causes problems with the search function in synaptic. The problem usually comes up after adding a new repository. For example, after adding the medibuntu repository, none of the medibuntu packages would come up in the quick search box and only occasionally in the traditional synaptic search box. The solution is to run the following command after each time you add a new repository:
sudo update-apt-xapian-index
If that doesn't work, be sure to try both the quick search box as well as the traditional search box.

Sources
Unbutu Forums

PDFSAM and JAR files

PDF Split and Merge (PDFSAM) is a nice utility to split and merge PDFs. Just download the program and unzip it into its own folder (I'll assume you call the folder pdfsam). Stick the new folder in /opt and then create a launcher with the following command in the command box:
java -jar /opt/pdfsam/pdfsam-1.0.3.jar
Note that the name of the file will depend on what version you download.

Also, the command "java -jar" is the basic command to run jar files. You just have to have jre installed.

Sources:
PDF Split and Merge
PDF Split and Merge Instructions
JAR Files

Midnight Commander

Midnight Commander is an excellent file manager for the shell. Works well if you are running a server and want a nice overview of files and folders without the command line. Install with apt. The package is called mc. It also runs with the command: mc

Friday, February 13, 2009

Transmission & Clutch on Ubuntu Server (with startup script)

Transmission, the default torrent program on Ubuntu now, also has a command line version that can be run on a server. This combined with Clutch, the web user interface for transmission, makes a nice pair. The version that is available in the repositories still has Transmission and Clutch as separate downloads, therefore, I recommend downloading directly from the Transmission site or Transmission repository. The instructions below have some references to synaptic just in case you are doing this on the desktop version. Here's how to set it up:

1. Add the Transmission repository to /etc/apt/sources.list or through synaptic. For hard the deb line is:
deb http://ppa.launchpad.net/transmissionbt/ubuntu hardy main
If you are using intrepid, just replace intrepid for hardy in the line above. See the download site for more explanation.

2. Add the GPG signing key with the following commands:
gpg --keyserver keyserver.ubuntu.com --recv 976b5901365c5ca1
gpg --export --armor 976b5901365c5ca1 | sudo apt-key add -

3. Now update and upgrade apt--you can do this with the following command or by hitting reload in synaptic:
sudo apt-get update && sudo apt-get upgrade

4. Now install transmission command line version with the following:
sudo apt-get install transmission-cli

5. After it is installed, type in the following command.
transmission-daemon
After you have executed it, it might be a good idea to restart after this is done. The purpose of starting the daemon is to make sure you get some folders and files in your home directory.

6. You now need to make some edits to the settings.json file. It is located at:
/home/username/.config/transmission-daemon/settings.json
It should look something like this to begin with:
"blocklist-enabled": 0,
"download-dir": "\/home\/anyone",
"download-limit": 100,
"download-limit-enabled": 0,
"encryption": 1,
"max-peers-global": 200,
"peer-port": 51422,
"pex-enabled": 1,
"port-forwarding-enabled": 0,
"rpc-authentication-required": 0,
"rpc-password": "",
"rpc-port": 9091,
"rpc-username": "",
"rpc-whitelist": "127.0.0.1",
"upload-limit": 100,
"upload-limit-enabled": 0
You want to change it so it looks something like this:
"blocklist-enabled": 1,
"download-dir": "\/home\/anyone",
"download-limit": 100,
"download-limit-enabled": 0,
"encryption": 1,
"max-peers-global": 200,
"peer-port": 51422,
"pex-enabled": 1,
"port-forwarding-enabled": 0,
"rpc-authentication-required": 0,
"rpc-password": "",
"rpc-port": 9091,
"rpc-username": "",
"rpc-whitelist": "127.0.0.1,198.168.1.*",
"upload-limit": 100,
"upload-limit-enabled": 0
As you can see, the first change is on the "blocklist-enabled" line. You are changing 0 to 1. This is obviously to enable blocklists. If you have something like moblock running, you can leave this as 0. I will discuss setting up blocklists further below. The second change is to the "rpc-whitelist" line. You basically need to add the ip address from which you will be accessing the server. The example listed above assumes your ip address will begin with 192.168.1. Throw in a * to cover everything else. To allow all ip addresses, you could probably add something like "*.*" although I have not tested this. In any even, change "192.168.1.*" to suit your individual ip address.

7. You now need to add a couple scripts to your system that the Transmission page provides for you. The first helps automate the startup of transmission when you boot. To do this, go to first to the Transmission Initd Script page so that you are able to copy the text of the script listed.

8. After you have copied the text, create a new file in /etc/init.d/ with the following command (nano can be substituted with gedit if you like):
sudo nano /etc/init.d/transmission-daemon
When the blank file comes up, paste in the script you copied from the transmission web page and hit save.

9. You also need to make this file executable by running the following command:
sudo chmod +x /etc/init.d/transmission-daemon

10. Now that we have the initd file, we need to add it to the appropriate spots in the system so that it starts automatically. It may work to simply add the new file/command (/etc/init.d/transmission-daemon start) to /etc/rc.local, however, the proper level is to add it to the appropriate rc runtime folders in /etc. To do this, run the following command to make sure transmission-daemon starts on startup and stops on shutdown:
sudo update-rc.d FOO defaults

11. Finally, we need a script to update the blocklist if you want one. Once again, you must copy the text of the script from the Transmission Blocklist Script page and paste it into a new file that you create. You can put this new file wherever you want, I suggest somewhere in your home directory. So you would create it with a command like this one:
sudo nano /home/yournamegoeshere/transmission-blocklist
Then paste in the text, save, and exit.

12. To automate this file, we simply need to add it to crontab. Do this with the following command:
crontab -e
Add the following line to have it update everyday at 1:00 a.m.:
00 01 * * * cd /home/yournamegoeshere && sh ./transmission-blocklist

13. Restart your system and you should have transmission running. You can access it by going to the following page:
http://serveripaddress:9091/transmission
If that doesn't work, try:
http://serveripaddress:9091/transmission/web/
Note also that you have the appropriate port open on your firewall. You shouldn't need the 9091 port open unless accessing the server from outside of your network, but you will need to open the peer port noted in your setting file described above. In that example, the port is 51422.

Sources:
Transmission
Transmission Initd Script
Transmission Blocklist Script
Startup Scripts Description
Crontab Explanation