The Crane Has Landed


Remote notification
January 12, 2011, 11:04 am
Filed under: MythTV, networking, Ubuntu, xbmc

I have been playing around with a way to get my Ubuntu box (that is running VLC on startup to stream our satellite TV across the network) to notify other boxes that it is awake and broadcasting. This is so that my wife can start the box up from a WOL script on the kitchen PC and then, once it is booted up, turn on the modded Xbox and run XBMC to connect to the stream and pick up TV downstairs.

Nice enough. :)

I managed to get it working using the following steps.

  1. On the PC that broadcasts TV, I added passwordless SSH (via this link) for the user that the kitchen PC runs under.
  2. On the kitchen PC, I created a script in the /usr/bin called notifier that has the following in it:
    export DISPLAY=:0 && export XAUTHORITY=/home/[KITCHEN COMPUTER USERNAME]/.Xauthority && sudo -u [KITCHEN COMPUTER USERNAME] /usr/bin/notify-send "TV is now broadcasting" 2>&1.

    Most of this is via this page.

  3. After adding the same user to the TV PC, I have a line in the TV PC /etc/rc.local that says
    su [KITCHEN COMPUTER USERNAME] -c notifyKitchen
    The notifyKitchen is a /usr/bin script that simply says
    ssh [KITCHEN COMPUTER USERNAME]@[KITCHEN COMPUTER] 'notifier'.

Done and done. When the TV PC boots, it calls this command and the Kitchen PC gets a pop-up notification that TV is running.



Tip: how to get the size of a folder in Linux CLI
October 24, 2010, 7:15 pm
Filed under: Linux, Tips, Ubuntu | Tags: , , , ,

It seems like a simple request…and it mostly is. But if you want to get the size of a folder – including sub-folders – in Linux from the command line, you need to use the du command. The simplest trick (thanks linuxforums.org) to get the total size without listing all the sub-folders is to use the following:

du -h | grep -v '/' | awk '{print $1}'


Shutting down via the web
July 5, 2010, 10:15 pm
Filed under: Tips, Ubuntu | Tags: , ,

One of the annoying things about Ubuntu is the fact that you need to be an admin user to shutdown the PC. This makes sense if you are running a server, but not when you have a few PCs scattered throughout the house that you’d just like to shutdown quickly.

So, I found a way to enable this through Apache. Warning: this will allow anyone who browses to your PC to shut it down without prompting. So use carefully.

Basically, what you need to do is remove the need for admin/sudo access when shutting down as the www-data (Apache) user. To do this, you use a specific command called visudo which specially edits a file containing what commands require admin access.

In short, make sure that the last line in that file is the following:

www-data ALL= NOPASSWD: SHUTDOWN_CMDS

and that there is a line further up that says Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/reboot, /sbin/halt.

Then, once this is done, you can have a shutdown.php that has the following code:

<?php
echo exec('sudo shutdown -h now');
?>

Q.E.D.



Streaming PVR-150 via VLC
March 21, 2010, 1:51 pm
Filed under: PVR-150, Tips, Ubuntu | Tags: , ,

So, after some pretty massive renovations, I now have Cat-5E cable throughout the house. Sweet. :)

I also have a need to somehow get the feed from my Sky box upstairs to the TV downstairs so the younglings can watch Playhouse Disney. In the past, I’ve done this through ye ol’ UHF backfeed, but the new HD box doesn’t allow that without an RF modulator.

What to do? Oh, well I do have an Xbox softmodded with XBMC downstairs. And I do have a Shuttle running Ubuntu with a Hauppauge PVR-150 TV card beside the Sky box upstairs. How abouts a little VLC streaming? :)

I’ve added the following line of code to my

/etc/rc.local

file on the Shuttle:

su [A NON-ROOT USER] -c "vlc pvr:// :pvr-device=/dev/video0 :pvr-norm=0 --sout '#standard{access=http,mux=ts,dst=[IP ADDRESS OF SHUTTLE]:8080}' --daemon"

Then, on my XBMC install, I have a file called

Sky.strm

which has this one simple line in it:

http://[IP ADDRESS OF SHUTTLE]:8080

and is sitting under the Playlists folder in the Videos directory of my UserData folder. When I go and select it, after a couple of seconds I get full MPEG-2 streaming across my network!

I can also access the stream from any VLC player on my other machines too.

Super sweet!

EDIT: After upgrading to 10.04, I inexplicably needed to add the line :pvr-channel=2 to make this pick up more than static.



Bash history
January 18, 2010, 7:01 pm
Filed under: Tips, Ubuntu | Tags: , , , ,

This is a simple trick, but a good ‘un: if you’re wanting to hunt through the bash shell history of commands (i.e. what appears when you press the up key), use the

history

command. To search for a specific phrase, use

history | grep [phrase]

.

For more, better detail, check out this link.



Keyless SSH entry – Ubuntu, Windows and iPhone
January 18, 2010, 6:58 pm
Filed under: Tools, Ubuntu, Windows | Tags: , , , ,

A great feature of SSH is the ability to log in using public/private key encryption, rather than just simple passwords.

The way this works is that each server and client creates a public and a private key. Then, you copy the public key of the client you wish to authorise into the authorized_keys file of the server you are logging on to. When you attempt to log in, your SSH client will create a signature using your private key which the server will then decrypt using the public key and you’re in. :) Easy. (More details here.)

Because your keys should be encrypted, this doesn’t remove the need to enter a password when you use the key. To do that, you need to use Paegant – a free accompaniment to Putty in Windows – which will ask for your passphrase once and then use it to open sessions to your heart’s content.

To get this working, you:

  1. Generate the key pair on the client using PuttyGen. Specify a decent passphrase for your private key.
  2. Copy the public key to the clipboard or export to a file
  3. On the server, for the user you are planning to log in as, go to ~/.ssh/ and edit the authorized_keys (or authorized_keys2) file
  4. Paste in the public key RSA string
  5. In Putty, for the server connection, add the username to the Connection > Data > Auto-login username field, and the path to the private key file Connection > SSH > Auth > Private key… field.

Done. :)

For the iPhone iSSH app, the app has a generate public key function. With that you can follow the same instructions to authorise the key and it will work from your iPhone as well. Sweet!



New year, new tech?
January 15, 2010, 3:46 pm
Filed under: Karmic, Ubuntu, VOIP | Tags: , , ,

Just realised how long it has been since I last posted! A few things have changed in the technology landscape in my house – not least of which is my attempts to get an Asterisk-based PBX up and running.

I’ve bought a Linksys SPA3102 which bridges the POTS Telecom line onto my LAN. I did have it all up and running on a VirtualBox image on my Ubuntu 9.10 server, but then ran into timing issues.

So, I’m following these instructions again, and starting from scratch in the server proper. Wish me luck!



Continuing adventures with DNS
November 1, 2009, 8:15 pm
Filed under: Jaunty, Karmic, Ubuntu | Tags: , , ,

After installing the new Ubuntu 9.10 over the weekend, I set about again trying to establish my new DNS server running on the platform. I have found what seems to be a great tutorial for DDNS (i.e. DNS which is updated with DHCP leases) here.

I’m still working through the bugs, but things at least seem to be getting DHCP addresses, so that’s a good start. :)

A couple of gotchas early one – Ubuntu runs a thing called AppArmor which seems to cause a lot of problems with applications like DHCP wanting to update BIND and all that. The comments on this post at DebianAdmin.com outline the changes that are needed to be made, specifically you have to make one last minor change to /etc/apparmor.d/usr.sbin.dhcpd3:


/etc/bind/ rw,
/etc/bind/** rw,



DNS
October 26, 2009, 3:51 pm
Filed under: Development, Hardy, networking, Ubuntu | Tags: , ,

I’m reworking my home network, and playing with a VirtualBox image of Ubuntu 8.04 LTS that is acting as my DNS server and DHCP server. This is an attempt to deal with the frustrations of my Netgear gear not doing what I want re: IP addressing, and to simplify accessing servers and other devices by name on all my various IP-enabled equipment.

I’m still getting to the bottom of all this DNS stuff, but a couple of key links I don’t want to forget are:



Great link for command line SAMBA
July 12, 2009, 9:06 am
Filed under: Development, Tips, Tools, Ubuntu

I’m just discovering the usefulness of smbclient and this link has a great summary of the commands you can fire through this tool from the terminal.

Probably the most common one I need to do is to use the tarmode to copy whole folders down, like so:


tarmode
lcd /tmp #this switches the local directory
recurse
prompt
mget pdf995/ #this recurses and tars the pdf995 remote directory and puts it in /tmp on the client




Follow

Get every new post delivered to your Inbox.