Archive for the ‘Linux’ Category

Connect to RoboRIO USB on Linux

Saturday, January 3rd, 2015

We got our RoboRIO imaged today, and my first thought was whether I could use it on Linux without needing to plug it into a network. Turns out, this is a pretty simple thing to do!

  1. Plug the RoboRIO in to your computer
  2. Identify the network device, it should be something like enp0s29u1u2
  3. Assign it an IP address like so:
    sudo ip addr add 172.22.11.1/24 dev enp0s29u1u2

Now you need to start an DHCP server to give it an address, because FIRST didn’t give it a static address for some reason. You could modify the configuration on the RoboRIO… but let’s assume you don’t want to do that. Instead:

  1. Download this python script that acts like a DHCP server
  2. Run this:
    sudo python simple-dhcpd -a 172.22.11.1 -i enp0s29u1u2 -f 172.22.11.2 -t 172.22.11.2

And that’s it! When it works, you should get a message that says “Leased: 172.22.11.2”.

If it’s not working, here are some things to watch out for:

  • Make sure your firewall allows port 67 on UDP
  • Make sure dnsmasq or some similar program isn’t listening on port 67 (use “netstat -ln | grep 67” to check)

Things that would be nice to change:

  • It’d be nice if FIRST changed the usb0 device to have a static address instead of depending on dhcp
  • Probably should create a udev rule to make the network device something pretty
  • When you disconnect the device, you have to run the scripts again. Probably should set something more permanent up, but this is good enough for now

Hope this helps you out!

Ubuntu Karmic: definitely a good upgrade

Tuesday, October 6th, 2009

Ubuntu just released the Beta for Karmic a few days ago, so I figured that I would give it a whirl on my desktop now that I’ve switched to using Linux on my desktop fulltime. So far, I’m very happy about this upgrade, hopefully they don’t screw it up before release. :p

My first impression so far as been that its a vast improvement — and I’ve got rather old hardware, so I think thats a really positive thing. Maybe its just firefox, but it seems like to me that everything works a lot better and is more responsive. The file browser in GNOME too — it used to lag quite a bit while browsing through my drive — now it seems to work exactly as I might expect. I know they’ve been touting a really quick boot time, and it feels a little bit faster, but I’m not quite sure about that. I haven’t bothered timing it or anything though.

There were two annoying things about the upgrade. First, X didn’t work at first and just kept blinking in a loop — but that was totally my fault, since I’m using the latest NVidia drivers, and forgot to reinstall before I rebooted. However, a quick boot into a command prompt and reinstalling the drivers got it all working again. The second thing that is a bit weird is they must have changed the font or the way its anti-aliased now, since everything looks a bit more.. blurry. Or something, I can’t quite put my finger on it. I’m starting to get used to it, but its too bad the fonts aren’t a bit crisper.

FWIW: Keep in mind that I’m using rather old hardware on my desktop, but XP always worked well on it! I’m using an Athlon 3000+ with a triple-monitor setup on two NVidia 6600 cards (one PCI, one AGP). 2GB RAM, and some various SATA and IDE disks.

Make BitTorrent/P2P less annoying at home using Linux, Iptables, and QoS

Saturday, November 17th, 2007

At home, I’ve been using a Linux router for as long as I can remember… since, a rather long time ago, I didn’t have money for a router but I happened to have an extra computer that I had been playing with Linux on it. So, I developed an ipchains script (which I eventually converted to iptables) to do NAT on it, and its worked pretty well ever since then. I honestly don’t remember where I derived the script from, however.

When I was in the dorms and afterwards in an apartment with others, we had used my Linux router, since it was pretty simple and theres a ton of things you can do with a Linux server. However, something we noticed (which wasn’t specific to this router) is that whenever someone was using BitTorrent or some other P2P app (you know, to download Linux distros and CC-licensed stuff), it would totally kill our internet access unless the person made their upload rate ridiculously low.. which is fine, unless a visitor stops by, plugs in, and forgets to turn their torrents down.

So, sometime last year I decided that there was probably a good way to filter different types of traffic so they don’t get excessive. Turns out, you can combine iptables and the QoS functionality of the kernel to do just that.

(more…)

Web Interface to the fortune program

Sunday, August 26th, 2007

I got bored last night, so I created a wrapper around the fortune program on my Gentoo box… then made it better with jQuery AJAX goodness. And then I combined it with my rndsay wrapper to make the fortunes be echoed by cows. 🙂 Of course, getting it to work on my host here has been annoying, but I finally got it working! Enjoy!

Random Fortune Generator

Source Code

rndsay: Random cow sayings and fortune combined

Saturday, June 9th, 2007

Have you ever used fortune? Or how about cowsay (or for that matter, have you even heard of it?) . If you haven’t heard of them… well, you’re missing part of your Linux experience.

Fortune (or fortune-mod), is a program that prints out random quotes/funny things on the console — it is IMHO essential to have in ANY linux system, especially if you run it on login. Cowsay is a program that prints out the text passed to it in a bubble, with a cow illustration. Its extremely amusing.

Anyways, I combined fortune and cowsay awhile ago in a script that randomly selects a different cow and cow type to display the fortune, and I have it installed in my /etc/bash/bashrc file. Heres an example of some output from it.

 ________________________________________
( Do you know the difference between     )
( education and experience? Education is )
( what you get when you read the fine    )
( print; experience is what you get when )
( you don't.                             )
(                                        )
( -- Pete Seeger                         )
 ----------------------------------------
        o   ^__^
         o  (@@)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Enjoy! http://www.virtualroadside.com/download/rndsay.tar.bz2

How to get remote SSH shell access on some servers running PHP

Saturday, June 2nd, 2007

I was trying to do an XML dump with MediaWiki for a friend, and the tools MediaWiki provides to do it requires shell access — which my friend does not have in his hosting package. So I tried using phpshell, but got annoyed that it would freeze anytime I executed something that required user input. After much thought, I devised a way to create an SSH shell using PHP (sorta) that I could use. Heres how you can do it too.

The Concept:

PHP can (usually) execute arbitrary executable files on the server that it resides on. If the executable forks, then it can open other programs or connect to remote resources, without hanging the PHP connection. I’ve written a program that does this, and executes a statement that connects to a remote SSH server, creates a tunnel to it, and opens a shell on that tunnel so that a user on the remote SSH server can connect to that port and use the shell. The statement looks like this:

netcat -l -p 20000 -s 127.0.0.1 -e "/bin/bash -i" | ssh -NR 20001:localhost:20000 username@hostname -o "StrictHostKeyChecking false" -i key_file_name

You can connect to this shell by doing a

netcat localhost 20001

on the remote SSH server. You need to setup an SSH key on both servers so that the authentication doesn’t ask you for a password at all (see below). Of course, if those programs don’t exist on the remote server then this wont work (however, I have included a compiled version of gnu-netcat with the program that you can use).

The Usage:

This code works, but is still mostly a ‘proof of concept’.

Requirements:

  • You must be able to upload files to the server and ensure they are executable (though, the software tries to set the executable bits if it is not the case)
  • You must be either able to compile files in a executable format that the server can execute, or you must be able to compile files on the server itself (in which case, you probably don’t need this program!).
  • The user that the webserver (or the php CGI script) is running as must be able to write to a file
  • You need an accessible SSH server setup somewhere that you can add user accounts to
  • Forwarding must be enabled (default: yes)
  • Public key authentication must be enabled (default: yes)
  • It needs to have netcat installed
  • I used Linux to set this up

(more…)

Awstats and 1and1.com logfiles

Monday, May 21st, 2007

I use 1and1.com for my web hosting, and they provide raw dumps of the apache logs for the website. Which is great, because you can do whatever analysis on them and it works nicely.. except for two things:

  • They don’t use a standard LogFormat directive
  • After about 6 weeks, the oldest log files get deleted

So, after much trial and error, I figured out a decent way to use Awstats to do my log analysis. I wrote a cron job that runs every monday morning (had to modify my crontab from the default), which basically downloads the latest logfile from my 1and1 account, and then runs awstats on it. It sounds pretty trivial — but 1and1 names their logfiles in the format access.log.[week].tar.gz.. which works until the year rolls over. So I added some logic in there to intelligently rename the files like access.log.[year].[week].tar.gz.

You can download the awstats 1and1 cron job here.

To use it, you need to be running Linux, and have awstats installed. You will need to modify some of the parameters of the cron script, but its decently commented. Additionally, your awstats configuration file needs to have the following two directives in it:

LogFormat= “%host %other %logname %time1 %methodurl %code %bytesd %virtualname %refererquot %uaquot %otherquot”

LogFile=”gunzip -c $(for i in `ls -rt /home/awstats/roadside/`; do echo /home/awstats/roadside/$i; done) |”

Just make sure you replace /home/awstats/roadside with the directory that you want to place your logfiles. Refer to the script for more documentation.

Note: The biggest problem I have with it is that it only updates once a week. I played with doing it every day, but then awstats tended to drop/ignore records that were out of sync, and it seemed to be better to have complete stats instead of having them updated every day. If you have a good solution for this, let me know!

Standalone GPS SQL logging software for Linux

Thursday, May 10th, 2007

I was not able to find any decent standalone GPS data logging software for Linux (for use in my car computer), so I decided to write my own — and it works pretty well for what I want to do. Of course, I’m not quite sure what the practical implications are, but I guess I’ll figure that out later (and post it here, of course!). Anyways…

geoHist is a (relatively) simple program I wrote to log GPS data retrieved from GPSD into a MySQL database. It is designed to meet the following requirements:

  • Standalone
  • Run from system startup to shutdown
  • Small/fast, non-intrusive
  • Robust
  • Log data to an SQL database

geoHist will poll GPSD every 10 seconds and then send that data to a preconfigured MySQL database. It will attempt to detect if you are standing still, and if you are then it will NOT log the data. It decides this using a simple drift factor. It will always log position to the database at least once if there is a satellite fix.

All this program does is log your data into mysql. You will need to figure out what exactly you want to do with that data. At the moment, I’m not quite sure what I’m going to do with the data either, but if I figure something out I will surely include it in the next release.

I haven’t put it through a ton of use (yet), but it seems to be doing its job quite well. Now all I need to do is figure out a good practical application, and write some scripts to export the data from the database nicely.

Link: http://www.virtualroadside.com/geoHist/

Carputer Project Site

Thursday, April 26th, 2007

For my CS 4540 class, we had to do something related to Linux… but, really, theres not a whole lot of things that are particularly interesting to me that I haven’t done yet in Linux. So, instead me and my partner built a tiny computer and stuck it in my car! Its Linux based, tiny, and shiny! Its not quite done yet, but the pictures are quite neat! Check it out.

http://www.virtualroadside.com/carputer/

A Better Linux On Screen Keyboard

Wednesday, February 14th, 2007

I use Ubuntu Linux on my desktop, and Gentoo Linux on my server/router at home. Right now, I am in the process of installing a computer in my shiny new Grand Am (I’m going to add a few pages about that here soon), and I’ve bought a number of things for it and am in the process of installing the software for the computer. One of the items is a 7″ touchscreen.

Of course, with a touchscreen, having a nice on screen keyboard is critical. Gentoo didn’t really have anything nice, but the default keyboard installed for Ubuntu is pretty awesome! So, I’ve created a portage overlay for it, which you can download using this link here. Go to this page if you want more information on how to install packages using a portage overlay. I’ve also submitted the ebuilds to bugs.gentoo.org, and you can view that here.

If you use this, keep in mind that this is NOT an official package of any kind, so its not supported by anyone, including myself. I might help you if you’re nice, but I’m not obligated to. With that said, it should work just fine for you, it seems to be quite stable and has minimal dependencies.