2718.us blog » unslung http://2718.us/blog Miscellaneous Technological Geekery Tue, 18 May 2010 02:42:55 +0000 en hourly 1 http://wordpress.org/?v=3.0.4 More Hackery with Slug Asterisk http://2718.us/blog/2008/08/18/more-hackery-with-slug-asterisk/ http://2718.us/blog/2008/08/18/more-hackery-with-slug-asterisk/#comments Mon, 18 Aug 2008 05:29:32 +0000 2718.us http://2718.us/blog/?p=95 I wanted to make my slug running Asterisk do wakeup calls, since I currently pay $11/month for a daily wakeup call service and they’ll only try up to 4 times.  As my starting point, I was using this dialplan from the-asterisk-book.com:

  1. [hotel-intern]
  2. exten => _*77*XXXXXXXXXXXX,1,Answer()
  3. exten => _*77*XXXXXXXXXXXX,n,Set(year=${EXTEN:4:4})
  4. exten => _*77*XXXXXXXXXXXX,n,Set(month=${EXTEN:8:2})
  5. exten => _*77*XXXXXXXXXXXX,n,Set(day=${EXTEN:10:2})
  6. exten => _*77*XXXXXXXXXXXX,n,Set(hours=${EXTEN:12:2})
  7. exten => _*77*XXXXXXXXXXXX,n,Set(minutes=${EXTEN:14:2})
  8. exten => _*77*XXXXXXXXXXXX,n,NoOp(Wake-up call scheduled for ${CALLERID(num)} at ${hours}:${minutes} on ${day}.${month}.${year}.)
  9. exten => _*77*XXXXXXXXXXXX,n,System(echo -e "Channel: SIP/${CALLERID(num)}\\nContext: wake-up\\nExtension: 23" > /tmp/${UNIQUEID}.call)
  10. exten => _*77*XXXXXXXXXXXX,n,System(touch -t ${year}${month}${day}${hours}${minutes} /tmp/${UNIQUEID}.call)
  11. exten => _*77*XXXXXXXXXXXX,n,System(mv /tmp/${UNIQUEID}.call /var/spool/asterisk/outgoing/)
  12. exten => _*77*XXXXXXXXXXXX,n,Playback(rqsted-wakeup-for)
  13. exten => _*77*XXXXXXXXXXXX,n,SayNumber(${hours})
  14. exten => _*77*XXXXXXXXXXXX,n,SayNumber(${minutes})
  15. exten => _*77*XXXXXXXXXXXX,n,Hangup()
  16.  
  17. [wake-up]
  18. exten => 23,1,Answer()
  19. exten => 23,n,Wait(1)
  20. exten => 23,n,Playback(this-is-yr-wakeup-call)
  21. exten => 23,n,Wait(1)
  22. exten => 23,n,Hangup()

The problem is that my slug is unslung, running busybox for most basic *nix tools and busybox’s touch command doesn’t support the -t option, so I can’t set the modification time on the file to properly queue it.  My half-assed workaround is a shell script (because I couldn’t get the System() command to run the whole string, try as I might) that nohups a background shell process that sleeps for the difference in seconds between now and the wakeup time, then creates the call file.  Not great for far-future scheduling or for large numbers of calls and it won’t survive a reboot, but it’s a start.

#!/bin/sh
  1.  
  2. nohup sh -c "sleep $((`/bin/date –date="$1" +"%s"` – `/bin/date +"%s"`)) ; echo -e 'Channel: $2\\nContext: wake-up\\nExtension: 23' > /tmp/$3.call ; mv /tmp/$3.call /opt/var/spool/asterisk/outgoing/" >/dev/null &

My Asterisk diaplan macro passes the target time/date string as the first argument, the target channel as the second, and the ${UNIQUEID} as the third.  One further wrinkle:  busybox 1.3.1, which was what came with the unslung firmware I used, doesn’t have nohup, so it won’t work; busybox 1.10.3 is what ipkg installed into /opt/ and has nohup, but the date command in 1.10.3 didn’t seem to support –date (at all, or maybe just not properly), so nohup is a reference to the 1.10.3 busybox in /opt/bin while /bin/date is a reference to the original 1.3.1 busybox.  Stupid, but it works.

(Oh, and as I told the last person I saw wearing a t-shirt that said “If it’s stupid, but it works, then it isn’t stupid,” there’s definitely such a thing as works-but-stupid–this script hackery is such a thing.  The better solution, space permitting, is probably just to install the coreutils package so as to have proper non-busybox touch and date)

]]>
http://2718.us/blog/2008/08/18/more-hackery-with-slug-asterisk/feed/ 0
Steps to “Unsling” the NSLU2 http://2718.us/blog/2008/07/13/steps-to-unsling-the-nslu2/ http://2718.us/blog/2008/07/13/steps-to-unsling-the-nslu2/#comments Mon, 14 Jul 2008 00:39:33 +0000 2718.us http://2718.us/blog/?p=52 Since I’m on my second of what will probably be 4 or 5 unslung NSLU2 “slug” units (with identical 1GB flash drives from eBay), I figured it was time to write down specific step-by-step directions, if perhaps only for my own use later.  (As an aside, having the two ethernet ports on my Mac Pro is really helpful at times like this when I’m monkeying around with some piece of hardware that doesn’t do DHCP out of the box, forcing me onto some specific subnet.)  CAUTION: I take absolutely no responsibility for what you may do to your hardware/software/life/etc. if you follow these directions.  You should read lots of other, more thorough instructions like the how-to’s at the Unslung HomePage.

  1. Verify that the slug can do Reset Button Upgrade Mode.
  2. Get the Unslug firmware.
  3. On the admin web page for the slug (default IP is 192.168.1.77), go to Administration > Advanced > Upgrade (default username/password is admin/admin), browse to the unslung firmware, and do the upgrade.  (This step takes a few minutes.)  Wait for the reboot.
  4. Verify that the admin web page now shows the unslung firmware version.
  5. Do any network config you need (set IP address, etc.)—avoid DHCP as it doesn’t seem to work (the slug does a DHCPDISCOVER, my server(s) do DHCPOFFER, but the exchange goes no further).
  6. Enable telnet access (Home > Manage Telnet).  Note that this must be done before any disks are connected.
  7. Telnet into the slug (username/password is root/uNSLUng).  Keep this session open through the next steps, so there’s guaranteed root access.
  8. Plug the 1GB flash drive into the upper USB port (closer to the ethernet jack).
  9. Once the slug recognizes the disk, go to Administration > Advanced > Disk and format the flash drive (Disk 2).  This again takes several minutes (especially with the cheapo slow 1GB flash drives I’m using).  When the page shows “Formatted (EXT3)” for Disk 2, it’s ready for the next step.
  10. In the telnet session from step 7, type “unsling disk2″.  Enter a new root password here.
  11. Reboot by typing “DO_Reboot” in the telnet session.  The device will beep when it’s fully booted.
  12. Go to the admin web page and verify that it says “uNSLUng status:   Unslung to disk2, /dev/sda1″ in the bottom blue bar.
  13. Enable telnet again and connect to the device again, verifying that the “NOTE: THIS SYSTEM IS CURRENTLY UNSLUNG” banner shows upon login.
  14. Run “touch /.ext3flash” so that (after the next boot) the OS will try not to thrash the flash drive.
  15. Verify internet connectivity (e.g. ping google.com).
  16. Run “ipkg update” to update the package system.
  17. Run “ipkg install openssh” so we can get to the slug without having to enable telnet.
  18. Verify that SSH works by logging into the slug over SSH.  Disable telnet.
  19. Run “ipkg install openssh-sftp-server” so we can use SFTP to edit files on the slug.
  20. Set the admin web page password (it is independent of the root password).

Other notes:

  • The MAC address label on the bottom of the device is the default device name and seems to be “LKG” + the latter half of the MAC address; it seems that the correct MAC address is found by replacing “LKG” with “00:18:39″.
]]>
http://2718.us/blog/2008/07/13/steps-to-unsling-the-nslu2/feed/ 3
Small *nix Devices http://2718.us/blog/2008/05/22/small-nix-devices/ http://2718.us/blog/2008/05/22/small-nix-devices/#comments Thu, 22 May 2008 07:35:22 +0000 2718.us http://2718.us/blog/?p=38 Today, not only did the NSLU2 that I bought on eBay arrive, but the red anodized aluminum case for my Alix arrived, too.  Getting the NSLU2 to run “unslung” from a 1GB flash drive was a royal pain.  If I do a second one, I’ll have to verify my technique, but it seems that the direction to format the drive before reflashing is just a mess (since it’s nearly impossible to get the Linksys firmware to format a flash drive), but once the firmware is reflashed to non-stock, it’s easy to format the flash drive, then run the script to move the boot stuffs off to the flash drive, where there’s room to install stuff.  The problem is that the device seems to be spending about 90% of its time completely hung and non-responsive (telnet and ssh freeze ior maybe just hang, web interface unresponsive, intermittent “thrashing,” if you can call it that, of the flash drive) for reasons I can’t quite figure out.  It may not turn out to be as useful as I’d hoped, but even if it doesn’t do what I want, it will have been an interesting experiment.  Plus, I realized it’s the only linux box i’ve got on hand (my other machines are various Macs and OpenBSD boxes and a few PCs).

Speaking of OpenBSD boxes, the Alix seems to be much closer to usable than I’d expected now, having restarted from a newer pre-built flashdist image.  The hokey thing I’d forgotten about is how few of the standard basic *nix command programs are in the base flashdist, so I end up copying over program after program from another running OpenBSD box.  I’m hoping to get BIND and dhcpd up and running soon, get pf all set up for router/NAT/firewall use, and try it out with a DSL modem before the weekend is up.

And, with a little luck, by the end of the weekend, all these various devices will be self-updating the various common config files (BIND zones, dhcpd.conf, etc.) from a common server.  I’ve already got a shell script that can check for an update to itself and replace itself with the newer version; I just have to make it check for and retrieve updates for the actual config files.

]]>
http://2718.us/blog/2008/05/22/small-nix-devices/feed/ 1
Trying for more than Just a Home Network http://2718.us/blog/2008/05/17/trying-for-more-than-just-a-home-network/ http://2718.us/blog/2008/05/17/trying-for-more-than-just-a-home-network/#comments Sat, 17 May 2008 20:50:59 +0000 2718.us http://2718.us/blog/?p=35 The OpenBSD router machines I installed at my place and my parents’ have been failing and I’ve been doing band-aid fixes of little things as they break, but it’s annoying.  My new idea is to use hardware routers, but to install one or more “slug” NSLU2 devices, unslung, inside each network to provide DNS and DHCP (more than one should easily give redundancy).  At $50-60 on eBay and potentially running some variant of Linux from a small USB flash drive, it should be reasonable to set up two identically-configured “slugs” so that if one goes bad, the other can handle the load until the bad one can be replaced.  My first NSLU2 for testing should arrive in the middle of this coming week.  Details on the previous setup and history after the cut.

Since the point where both my parents and I had DSL, I’ve been fiddling with ideas of how to make it easier to share files across our two networks, easier for me to debug issues on their computers, and, well, just more technologically cool.  About a year and a half ago, I replaced the D-Link routers at both sites with a matched pair of used Dell business machines I’d bought on eBay, outfitted with OpenBSD (by far the best OS for trying to run a secure gateway).  This seemed to fit the bill, as it enabled me to more easily connect to my home network from elsewhere without opening up any of my internal machines directly to the outside world, it allowed me to similarly access my parents’ network without exposing any of their internal machines, and (at the peak of its working-ness) we had an encrypted VPN unifying the two sites so I could connect to shared drives on their machines and print to their color laser printer as if all those devices were on my own network.

But somewhere along the way, things started to go south.  A few months ago, the gateway router Dell box on my end died–just wouldn’t power up anymore.  I swapped in an old D-Link hardware router to keep my internet access up and I’ve been working on an Alix unit to replace it, but getting OpenBSD properly tweaked to run off a compact flash card took some time and I still haven’t quite gotten that install happy with PPPoE DSL connections, so it’s still not in place.

Now, making things worse, the machine at my parents’ place isn’t working quite right.  After an extended power failure that wore through the UPS, the machine appears to start up (even sounds right when I stood there and watched it “boot”), but it never shows up on the network, much less makes the DSL connection and joins the network to the DSL.  This led to a similar swap-in of a spare hardware router unit at their place.  Unfortunately, things got messier for them.

These OpenBSD machines I’d been using as routers on both ends had also been running DHCP and DNS for the internal networks and while my internal network had a second OpenBSD box that was able to step in and take over the DNS (it was already serving as a secondary DNS server) and the DHCP (it had been doing DHCP before I got the other machines), my parents’ network had no such machine.  Suddenly, lots of things stopped working correctly.  Printing over the network didn’t work because the IP printing port in Windows was trying to use the (former) FQDN of the printer, or maybe even its old IP address.  This is what got me looking at the slug.

]]>
http://2718.us/blog/2008/05/17/trying-for-more-than-just-a-home-network/feed/ 0