James' Tech Blog

Chromium OS uses Gentoo?

by on Feb.27, 2010, under Uncategorized

Just poking around Chromium pages (you know “Google ChromeOS”) and found some interesting stuff. They have a page about building the OS http://dev.chromium.org/chromium-os/building-chromium-os/portage-based-build First the URL says it all Portage based build. Later in the page they have emerge-<board_name>. Then about ebuilds and their chromium-overlay.

Does it actually use Gentoo? I’m not sure what their overlay has, but it seems like they are using Portage to build and maybe some Gentoo patches along the way. Check out the part about dependencies. It clearly has eselect ebuilds and gentoo-syntax for vim. Also, core-utils with -vanilla USE flag (as in include Gentoo patches). Why use Portage though? Especially since the user already has a working system and can install missing dependencies. Why not use Paludis? Well Google isn’t the only ones to ever use Portage in their project. I believe Openembedded’s bitbake is Portage based also.

Anyways, way to go Gentoo! Helping the world reach a brighter tomorrow!

Leave a Comment :, , more...

Shell and PHP script for dynamic IP address

by on Dec.05, 2009, under Remote Admin

This is the second post in the series “Remote admin your mama’s gentoo boxen” This post I will be going over how I am going to handle the “dynamic” IP address on the WAN of my router. I say “dynamic” because I’m not really sure how dynamic it is. It’s likely only dynamic in the way that Comcast could give it to someone else (like if they wanted to pay for it) and there’s nothing I could do about it (unless I told them I would pay more for it!).

You probably just said to yourself, “DyDNS! Don’t they have services for that already?” The answer is yeah, they do, if you want your router to have a URL and probably be poked at more. Oh and dydns has sent me emails before about my IP not being “dynamic enough” and that I should “use static registration!” Besides, this way I can encrypt my IP not only when I update it, but when the client retrieves it. Not to mention client authentication.

Here is the scheme:

Router runs ash script reporting IP to remote server

Server does it’s thing and records IP

Client runs bash script getting IP from remote server

From there the client knows the router IP and can connect with reverse SSH.

Here comes some code. I would have prefered to write this in PERL but my router doesn’t have PERL! Also, less dependencies on client. Everyone has a shell. I decided to send the IP as hexadecimal without separators. As I’m not really proficient at shell scripts I looked up how to convert IP’s to hex: http://blog.mecworks.com/articles/2007/07/05/bash-scripting-tip-convert-ip-address-to-hex/ I did some fun stuff for the client. It probably looks horrible, but it should work.

First up is the router script:


#!/bin/sh
SUCCESS=1
while [ $SUCCESS -eq "1" ]
do
RTR_IP=`ifconfig eth0.1 | awk -F "[: ]+" 'NR==2 {print $4}'`
UPDATE_IP=`printf '%02X' ${RTR_IP//./ }; echo`
SUCCESS=`wget -q -O - "http://www.ultravstudios.com/myphpscript.php?update=$UPDATE_IP"`
sleep 5
done

I’ll break it down for y’all. It loops until it works. We use ifconfig to get the IP of WAN (eth0.1), use printf to turn it into 8 character hexadecimal, send it to the special secret PHP page. The PHP page will return a value 0 on success 1 on error. Next is client side


#!/bin/bash
GET_IP=`wget -q -O - "http://www.ultravstudios.com/myphpscript.php?get=0"`
K=`printf "%d". "0x"${GET_IP:0:2} "0x"${GET_IP:2:2} "0x"${GET_IP:4:2} "0x"${GET_IP:6:2}`
RTR_IP=$(echo ${K%\.})

So this one’s really easy.  Get the value from the special secret PHP page. Turn it back to decimal with period separators. Chop the last period off. Okay, so that’s just the part to retrieve the IP. Next is my PHP code for the remote server. It seems like WordPress doesn’t like me adding php tags?!


$filename = "supersecretfilename";
//open file and get old ip
$file = fopen($filename, 'r');
$old_ip = fgets($file);
if ($_REQUEST['get'] == "0") {//the client does want the ip
print $old_ip;
fclose($file);
return;
}
//so the rest means that the client does not want ip
if (is_null($_REQUEST['update']) || $_REQUEST['update'] == "") {//there is not data
fclose($file);
print "1"; //tell client there was error
}
elseif ($_REQUEST['update'] == $old_ip) {
//there was no update close file and return
fclose($file);
print "0";
return;
}
else {//ip is new
fclose($file);
$file2 = fopen($filename, 'w');
fwrite($file2, $_REQUEST['update']);
fclose($file2);
print "0";
}

Apparently I comment my php code more than my bash! So it’s pretty dumb right now. There is no authentication, no encryption, very few fail-safes. If my router is somehow having problems updating the IP, like the script doesn’t work, it will try forever until it works. I assure you, this is just the beginning, a quick hack to get things rolling.

Leave a Comment :, , , , more...

Remote admin for your mama’s Gentoo Boxen

by on Dec.02, 2009, under Remote Admin

So a couple years ago before I moved to NorCal I setup a computer for my mother. I did it with the intention that she would be able to use the webcam to communicate with my sister/nephew/niece in NorCal. I tried Ubuntu and got nowhere cause it just didn’t work. So I said screw it, I’ll throw Gentoo on it. It works great, but it’s hard to admin 2000 miles away. A year ago I did the big ’emerge -avu world’ took a couple days.

Long story short my brother said the other day he’s going to setup a WinXP boxen for her! WinXP are you kidding? So she can use Skype? You know Linux Skype does video right? Well I can fix that! And my mama’s Gentoo box! I have a pretty good scheme for how to do it with _minimal_ help from anyone actually in front of the machine.

Here’s the scheme:

Mama boxen gets IP addy for my router

Mama boxen reverse ssh into my router

I ssh into Mama boxen through router. Point-to-point encryption! Secure tunnel through 2 NATs and at least 4 firewalls!

I start fixing stuff (I’m going to setup a change-root on my machine so that I can build packages for her and just send binaries instead of having Mama boxen compile everything, well maybe the kernel)

Get VPN to my router, Skype, TightVNC, etc running so that I can kick more ass with remote admin.

Tell my brother’s not to worry about Mama boxen!

First I setup my router, an important aside my WRT54GS is running Openwrt Kamikaze 8.09,  to accept keys for ssh connection that way shell script can run without password input. I added a user to /etc/passwd and /etc/groups and put my new key into it’s .ssh/authorized_keys. Next I need to open up the firewall to allow connection to dropbear over WAN. I’m going to wait till I actually need that though.

Moving forward: I am going to have a script to update a special PHP script (on this website) with my public IP every so often. Then make a script to get the public IP from special PHP script and open reverse ssh tunnel with router using new user.

Once that’s done I will be able to ssh into Mama boxen through router and it should be pretty straight forward from there. Kernel updates are worrying me, but GRUB can have if/then, file exists kinda stuff so I should be able to work something out for that. Stay tuned for more and alot more specifics.

Leave a Comment :, , , more...

iNoPhone2

by on Nov.27, 2009, under iNoPhone

My wonderful cat Perry decided to chew up a bluetooth headset (Jabra BT5020). I’ve seen before the iNoPhone which is totally awesome! I decided to rip it all the way apart and make my own iNoPhone from a spare Apple mouse that I had.

iNoPhone2

It wasn’t too hard after I figured out what wire to use. At first I tried 22 or 24 gauge wire. It worked, but the wires were stiff and it was hard to solder onto the tiny switches. Also, I pulled a trace off so I decided that it wasn’t going to work. I previously cut up an IDE cable to wire an SD card in my WRT54GL. There was plenty of spare ribbon to go into this project as well.

iNoPhone2

On top of pulling a trace off, I broke the wire for the mic. One problem with the design of the iNoPhone was charging. So I used a headphone jack and drilled out the normal cable hole to accommodate. This was awesome till I pulled the single trace I had found that went to the +5V on the USB. After a lot more searching I gave up cause the 22 gauge wire was too big to solder to the tiny _8_ pins for the USB on the board.

Close-up

In comes the IDE ribbon cable. Definitely small enough to solder to the USB pin and alot easier to solder to the pins of the switches. Now I was having problems with the mic. I just couldn’t get it soldered well. I needed a couple more hands, but I didn’t have them so I did the next best. I pulled out the mic from an old “desktop mic” I had around. Plenty of room to solder!

As above I wired in a headphone jack to charge the unit. Then I cut the end off a USB cable and soldered a male stereo plug on. Now if I only had smaller buttons it would look pretty awesome.

Charging jack

I haven’t been able to verify that charging works. The LED is not the right color when it’s supposed to be charging. I did get my multimeter out and checked the voltage on the battery, 3.86V without charger, 3.96V with charger. So, I think it works.

I will close with thanks to Mark from geektechnique.org I probably would have never thought of this without first seeing his iNoPhone.

I never knew you, but R.I.P. Mark

Leave a Comment :, more...

Live TV Working

by on Jul.20, 2009, under Uncategorized

Searching continued for watching Live TV with Hauppauge HVR950Q and mythtv… Found mythtv mail-list post, from yesterday, about xc5000 and not being able to watch Live TV. My initial suspicions were correct. Firmware was taking way too long to load, supposedly about 7 seconds! That causes time-out and Live TV fails. I guess the timeout for recording is high enough that recordings work. When I set up the card initially I ticked the box to “Open DVB card on demand”. This means that when the backend isn’t using it the card is in “power off”, the tuner is not on, amber light is off, device is free for any program to grab it. Sounds great then if I want I can use mplayer to watch streams and the card will be off most of the time. So the solution is to untick the box. This loads the firmware when mythbackend starts and the card is left “power on” so that the firmware is only loaded once and not every time the backend wants to use the card. Good fix for now, but I might try tweaking the timeout settings so that I can retick the box. I’ll add an update for what I find out. Other good news, I successfully recorded 2 streams on the one device the other day. It seems like comcast has a large amount (over 10) of streams at 83.X so I should be able to record a lot of streams at once. Awesome!

On a separate note I was doing some updates and my xorg got screwy. At first it wasn’t working at all, after reinstalling ati-drivers and rebuilding xorg, banging my head on the wall, it worked. QT is messed up though, when I start mythfrontend fullscreen the screen is totally corrupted video playback is corrupted. Tried rebuilding mythtv to no avail. If I “mythfrontend –geometry 1438×898” it is almost fullscreen and not corrupted at all. Again, I’ll update when I find something out.

1 Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...