Tuesday, September 16, 2008

Remote Access to CUPS Web Interface

If you have a server(without gnome or kde running) and need to install a printer, the easiest way is to use the CUPS web interface. You can see it on your own ubuntu computer by going to http://localhost:631/admin. But to get to this page remotely for a server, you need to first make some edits to the cups conf file. So do the following:
1. Edit the cups configuration file by first running the following command on your server:
sudo nano /etc/cups/cupsd.conf
2. Your first edit to the file is to make the section that looks like:
# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock
look like this:
# Only listen for connections from the local machine.
Port 631
Listen /var/run/cups/cups.sock
3. You then want to change the sections that looks like this:
< Location / >
# Restrict access to the server...
Order allow,deny
< /Location >
< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
< /Location >
< Location /admin/conf >
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
< /Location >
so they look like this:
< Location / >
# Restrict access to the server...
Order allow,deny
Allow all
< /Location >
< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
Allow all
< /Location >
< Location /admin/conf >
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
Allow all
< /Location >
4. Finally, restart cups with the following:
sudo /etc/init.d/cupsys restart
5. You should now be able to log into cups on your server with:
http://yourserverip:631
Note that when you change something, it may tell you that you need to add a certificate to firefox. Do so by clicking the add/get certificate button at the bottom of the firefox error message page. It will also tell you that to change stuff, you need to use the "https" version of the page instead of "http" so just go to:
https://yourserverip:631
You might also have to open/port forward port 631.

Sources:
Ubuntu forums post
Ubuntu Community Docs on Network Printing

Sunday, September 14, 2008

Watch any NFL game! (Sopcast on Ubuntu)

UPDATE (February 2009):
You can now ignore the rest of this post and simply download and install sopcast and sopcast-player. Both are listed on the sopcast page, but rather than manually installing and moving sopcast, just download both as deb files from Jason Scheunemann's google code page and double click to install. You will need to install the sp-auth deb first and then sopcast-player.

Sources:
Sopcast-player (install everything you need from here)
Sopcast (not really needed)


The old instructions:
Sopcast allows you to watch any NFL game (or other games for that matter). To get it working on linux and ubuntu, do the following:
1. Download and install VLC using synaptic.
2. Download sopcast for linux from their site. I only needed the sp-auth.tgz file. I did not need the stdc++5 library.
3. Unzip the file.
4. In the new unzipped folder, you will want to move the file named sp-sc-auth to /usr/bin. I think the easiest way to do this is to run the command:
sudo nautilus
This will open a new file browser and you can move anything anywhere. Just close the file browser and terminal when you are done.

At this point, you have two options. The easy option is to install a script, the second is to run everything from the command line.

As stated, the first way is to download and use Chickamade's script:
1. Download the newest version here. There are already good instructions under details on the site but I did have to change a couple of things.
2. So after you have downloaded the file, unzip it. Similar to above, run "sudo nautilus" and then move the "sopcast" file from the new unzipped folder to /usr/bin.
3. In firefox, type "about:config" (without quotes) in the address bar. Then right-click the screen and choose New-->String.
4. In the first field that comes up, type in:
network.protocol-handler.app.sop
In the next field that pops up, the value field, type:
/usr/bin/sopcast
5. Finally, the first time you click on a sop link somewhere, firefox should ask you how you want to open the link. Alternatively, you can go into Edit-->Preferences-->Applications and click on sop. Either way, ignore the default and tell firefox to open the sop link with sopcast by pointing firefox to /usr/bin/sopcast.
6. Now when you go to a site like MyP2P or Sopcast Channel List and click on a sop link, it will autmatically open VLC.

The second method is to ignore this script and simply open the streams through the command line. For this method, do the following:
1. Go to a site like MyP2P and find a sop stream you want to watch. Right-click on the link and copy the link location.
2. Now open a terminal and run the following:
sp-sc-auth linklocation 3908 8908 > /dev/null &
Replace "linklocation" with the sop link you copied from the site. Also, for information, the "> /dev/null" portion of this command gets rid of any output from the command and the "&" tells it to run the command in the background.
3. Next, open VLC. Go to File-->Open Network Stream. In the HTTP line, type:
http://localhost:8908/tv.asf
4. You should now see the stream. The only catch is that when you close VLC, it doesn't also stop the sp-sc-auth process. For this, you have to go to System-Administration-->System Monitor and stop the sp-sc-auth process.

There is also a third super easy method:
1. Download and untar/unzip the linux version of sopcast from their site as described in steps 2 and 3 in the first section.
2. Rename the sp-sc-auth file to sp-sc.
3. Move the sp-sc file to /usr/bin with the "sudo nautilus" command.
4. Download Sopcaster here. It is a very simple gui to run sopcast.
5. Untar/unzip the sopcaster download and move the sopcaster file inside to /usr/bin.
6. Now just make a launcher for the command "sopcaster."

Sources:
Sopcast download
Sopcast script
MyP2P
Sopcast Channel List
Sopcast Instructions
Sopcast script Ubuntu forum post instructions
Sopcaster gui

Friday, September 12, 2008

Cron & Crontab

As stated in an earlier post, there are cron folders within /etc appropriately named cron.hourly, cron.daily, and cron.monthly. Stick a script into the appropriate folder, and it will be run accordingly. For example, stick a script into the cron.hourly folder, and it will be run every hour.

The crontab file (/etc/crontab) is a way to have even more control. You can edit this file so that a command is run whenever you want. Open it and you will get a sense of how it works. The first five columns tell it when to run your command. The columns are minute, hour, date of month (dom), month, and day of week (dow). Note Sunday is 0 or 7. By filling these in, you can customise when you want your command to run. Use stars for any blanks. See the sources for better examples. In the next column, specify who the command is to be run as. For example, type root to run it as root. Finally, type in the command. Save the file and then exit.

A good example is to automate updates. If you wanted your system to automatically update everyday at 10:00 a.m., you would add a line to crontab like this:
00 10 * * * root apt-get update && apt-get -y upgrade
Note: the "-y" option with apt-get upgrade means to say yes to any prompts

A couple other notes. First, crontab will let you use steps. For example, if you wanted something to run every 15 minutes (and didn't want to specifically tell crontab to run the command at 15, 30, 45, and 60), you could just specify this with the notation "*/15" instead of "15, 30, 45." Second, crontab always sends output somewhere after it has completed its task. By default, it goes to the users mailbox on the system. To just get rid of this output, add "> /dev/null" to the end of the command line. However, you could specify any output file you like. The ">" means to overwrite the previous file. Alternatively, ">>" means to append the file. So, if we wanted the above example run every 15 minutes and the system to simply get rid of any output, we would add the following to crontab:
*/15 * * * * root apt-get update && apt-get -y upgrade > /dev/null

Personally, I like:
@reboot root apt-get update && apt-get -y upgrade && apt-get clean > /dev/null


Sources:
Schedule tasks on Linux (very good)
Automatically update your Ubuntu system
Newbie: Intro to Cron
Crontab man page

Friday, September 05, 2008

Installing Jinzora

Jinzora is a streaming jukebox similar to Squeezecenter. The web interface is not as intuitive as squeezecenter, but for me, worked much faster and without as many glitches. There are several nice guides on installing Jinzora which I have linked to below so I won't go through everything (like installing a LAMP server) since others have already covered it. These guides work equally well with Hardy. There are a few problems I ran into while installing that I will highlight here. The basics to installing are the following (again see the links for more details and screenshots):

1. Initially, we need to install a package and edit a file so that we don't get errors once jinzora is installed. So first use synaptic or apt-get to install the package "php5-gd." Next, edit the file /etc/php5/apache2/php.ini with the following command:
sudo nano /etc/php5/apache2/php.ini
You want to find the following lines and make sure the corresponding values match what I have listed below:
max_execution_time = 300
memory_limit = 32M
post_max_size = 32M
upload_max_filesize = 32M


2. Restart apache with the following command:
sudo /etc/init.d/apache restart

3. Download Jinzora from their website.

4. Unpack the downloaded file which will result in a folder called jinzora2. Move the jinzora2 folder to the /var/www directory. Do this with the following command:
sudo mv /current/path/to/jinzora2 /var/www/

5. Now change certain permissions in the jinzora2 folder. One way is to simply make everything in the folder read/write/exectue with the following command:
sudo chmod -R 777 /var/www/jinzora2
Or, we can use the included script to change only what is needed by running these two commands:
cd /var/www/jinzora2
sudo sh ./configure.sh

6. Now complete the installation by using the web based installer located at http://your-server's-IP/jinzora2/ (Note that jinzora needs port 80 open). The mac install guide, linked to below, has very nice explanations and screenshots. Also, on the backend setup, you can probably can leave the database user as root and use root's password unless you have something other than a typical setup. Jinzora2 is a good database name, localhost for database server, database type is mysql, and set create database to true.

7. When you are all finished and try to log in (again using the url noted in the previous step), you will get a message regarding the install folder. You probably don't want to delete the install folder in case you need it later, so simply rename it with the following command:
sudo mv /var/www/jinzora2/install /var/www/jinzora2/install.bak

8. It should now work. Again, refer to the links below for further explanations if needed.

Sources:
Jinzora
Mac Install Guide
Windows Install Guide
Linux Install Guide
php5-gd instructions
php.ini file alterations

Wednesday, September 03, 2008

VirtualBox & USB

To get USB support in VirtualBox, you first need the non-opensource version. Get this by adding the appropriate repository listed on the VirtualBox site noted below. The authentication key is also listed in my sources. After it is installed, do the following:

1. After installation, you must add yourself as a user to the "vboxusers" group (System-->Administration-->Users and Groups). Unlock and click Manage Groups. Then find vboxusers, click properties, and put a check next to your user name.

2. Edit the /etc/init.d/mountdevsubfs.sh file by uncommenting (i.e. deleting the # symbols) to four lines in the section labeled "# Magic to make /proc/bus/usb work." After editing the section, it should look like the following:
# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

Then save the file.

3. Next, edit the file called "/etc/udev/rules.d/40-basic-permissions.rules." For example, type:
sudo gedit /etc/udev/rules.d/40-basic-permissions.rules
In Hardy, you want the section called "# USB devices (usbfs replacement)" to look like this:
# USB devices (usbfs replacement)
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="vboxusers"
SUBSYSTEM=="usb_device", MODE="0664", GROUP="vboxusers"

You are basically adding the "GROUP" stuff. After the edit, save the file.

4. Finally, you will need to run the command "/etc/init.d/mountdevsubfs.sh start" before you start VirtualBox each time. To automate, this you can just add the command to rc.local. You want to add the stated command just before the line "exit 0." So do the following:
sudo gedit /etc/rc.local
Then, add the above stated command. After the edit, my file looks like this:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# VirtualBox USB tweak
/etc/init.d/mountdevsubfs.sh start

exit 0


5. Finally, reboot your computer.

Sources:
VirtualBox repositories
VirtualBox authentication key (Right Click and choose "Save link as..."
Ubuntu Community Documentation on VirtualBox
VirtualBox FAQs (text search for USB)