James' Tech Blog

Tag: gentoo

Seagate Dockstar

by on Aug.07, 2010, under dockstar

So I actually bought the WD Element drive to go with my new Seagate Dockstar! I bought 2 from woot.com for $20 a piece. I will be documenting what I did for posterity and hopefully usefullness for someone else.
There are 2 good websites for this:
[1] http://www.plugapps.com
[2] http://ahsoftware.de/dockstar/

I started with the latter. I will be using Gentoo on it (sorry plugboxlinux guys). I have a spare WRT that I hooked the dockstar and my desktop up to so that we were linked, but not on the internet. First follow the instructions on [2] to backup the MTD. I gzipped the images after I dd. There was probably an elegant way to do it all in one command using PIPE, but I didn’t bother doing it. MTD3 compressed really well presumable because it’s full of 0’s. Also, disable hbmgr from starting up on boot.

Next I hooked everything up to the “real” network so I could move on to [1] where we download blparam. I just ran blparam > out to a text file to save the original boot env. Then onward to update the bootloader. Then back to [2]! The only difference is that I will use the u-boot from [1] so root has to be /dev/sda1.

For u-boot I used the u-boot install script from [3]. It’s pretty safe, i.e. it won’t write to your USB. It just flashes the Plugapps u-boot.

[3] PlugApps:Pogoplug Setboot – PlugApps

After that it’s pretty much plug and chug. I set up my desktop as a distcc node using crossdev. It has an Athlon 64 X2 5000+ so it compiles almost anything pretty quick. Setting that up is pretty trivial, but just for reference:
[4] Gentoo DistCC guide
[5] Gentoo Crossdev guide

I had some problems with a couple packages compiling. Specifically xmlrpc-c. I found a sheeva binhost [6]. Yeah it’s “sheeva” but it’s the same processor so it should work just fine. That got me past that, but QT just wouldn’t build. I was trying to get Mythtv installed.

[6]Mark’s blog

After a couple days beating my head against the wall I found that there is a Debian group that compiled Mythtv for ARMv5e [7]. Not only that, but some very nice guy Jeff figured out how to install Debian on the dockstar [8].

[7]Debian Multimedia Packages
[8]Install Debian on your Dockstar or Pogoplug

So, alas, I tarred all my gentoo files on the root. Rebooted into stock firmware and deleted the files from the gentoo root. Then follow Jeff’s guide [8]. Well, mostly, I downloaded his script and realized it was a full-blown install u-boot and everything! I did not need that. I just cut to the chase: download the base.tar.bz2 file, untar, download sheeva kernel/modules, untar those too, cp kernel to uImage, make a new fstab, REBOOT. Then do normal Debian stuff.

I suck at Debian, but I’ll mention what I remember doing. Change timezone to America/Los_Angeles, do apt-get stuff: add debian-multimedia to pull in Mythtv. Getting Mythtv was nearly trivial. Because dockstar is headless no Xorg. No problem I have more than 1 computer that does. The only thing I needed to do was turn on TCP for my Xorg then xhost + to allow everybody to connect to it. Then on dockstar run mythtv-setup. Done!

So future work:

OpenWRT

Fix Gentoo

Make a custom initramfs to boot whatever I want

5 Comments :, , , , more...

Mythvideo now compiled

by on Mar.14, 2010, under Uncategorized

So, I switched to myth-0.22 awhile back because I finally got a sane database. No thanks to the mythtv guys, many thanks to the Gentoo guys for pointing out the bad behavior of mythtv not checking encoding formats and just assuming. I had been trying out the SVN version because 0.22 was broken in Portage. Long story short I haven’t been able to build mythvideo for months. Today I finally tried looking at the build log and internet searching. For reference here are the first few errors in the log file:
In file included from metadata.cpp:8:
/usr/local/include/mythtv/mythcontext.h:9:22: error: qptrlist.h: No such file or directory
In file included from main.cpp:18:
/usr/local/include/mythtv/mythcontext.h:9:22: error: qptrlist.h: No such file or directory
/usr/local/include/mythtv/mythcontext.h:13:23: error: qnetwork.h: No such file or directory
/usr/local/include/mythtv/mythcontext.h:13:23: error: qnetwork.h: No such file or directory
I stumbled upon someone else who couldn’t build that was getting similar errors to mine http://mythtv.org/pipermail/mythtv-users/2008-November/238546.html The problem was that the prefix for SVN is /usr/local/ whereas the ebuild prefix is /usr/ The quick and dirty solution:


mv /usr/local/include/mythtv /usr/local/include/mythtv-old
ln -snf /usr/include/mythtv /usr/local/include/mythtv

That solved the problem immediately, but I think the real problem is the ebuild. I checked the mythtv ebuild and the prefix is defined as /usr/, but the mythvideo ebuild does not have a prefix defined. I believe the solution is to define the prefix in the ebuild or make the symlink in the ebuild for mythtv.

Either way, I’m super-stoked! Now I can get back to encoding everything to something besides MPEG2 and watching it with mythtv instead of xine or mplayer.

Leave a Comment :, more...

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...

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...