Categories

Bash scripts based on running processes

At work, our ERP system is built on Oracle running on a clustered Linux (Red Hat Enterprise) environment. Since this is a high availability/failover setup the processes running our development databases can be on either server for any number of reasons. I wanted to make installing code a bit easier on the server so I made some bash scripts to partially automate the install for me. Not wanting to get errors when it tries to install code on the wrong server, I found this little command to determine if the database is running on a server and thus let the script go on with the install.

ps -U oracle -u oracle u | grep -q pmon_dev2

Lets break this down into each part. The first part, ps -U oracle -u oracle u, gets the currently running processes running as “oracle” (first “-U” for real and second “-u” for effective ID) in a user-oriented format (last “u”). This is similar to an example in the MAN page for PS and I just replaced the usernames to fit my case. The pipe (“|”) takes the output from the left side, the PS command in this case, and uses it as input for the right side. The second part, grep -q pmon_dev2, searches for “pmon_dev2″ in the output from PS, the “-q” option suppresses output and exits successfully if any match is found.

So I just put this at the beginning of my script:

if ! ps -U oracle -u oracle u |grep -q pmon_dev2
then
echo "DEV2 not running"
exit 1
fi

This exits the script right away if the database isn’t running on the server. If it is, then the script goes on to get the latest code from source control run the code install and exit. If you can do this with no user input, then you can setup a CRON job to run the script to automatically get any updates.

Daniel

We Interrupt Your Regular Broadcast to Bring You This Important Message.

After spending most of this week working with and debugging approximately 8,000 lines of PL/SQL contained in two packages, I want to mention “Refactoring” by Martin Fowler. It’s one of the few books I had to buy in college and have kept since then. If your code smells, clean it up… That is all.

Now back to your regularly scheduled programming.

Daniel

I’m important enough for my own Google Doodle!

 

My Own Google Doodle

My Own Google Doodle

While I may not be the most famous person around (I’m still due about 14 and a half minutes), Google still thinks I’m important enough to make me my very own Google Doodle. Let’s just ignore the fact that they know my Birthday from Google+ and I’m always logged in to a Gmail or Google Calendar account… It’s my Doodle.

Daniel

Bitcoin Payments with a Click

With recent Bitcoin coverage in the news and media, I’ve picked up playing around with it again. One thing that came to mind was something that would make it easier to make payments to addresses found on the web. My first thought was doing the same thing as a MailTo link on the web, click the link and the client opens up with the details in place. Granted copying and pasting the address isn’t that big of a deal, but this makes it easier to send or donate to a website.

Now I have to be honest I wasn’t sure what the correct name for the MailTo link was called. One quick Google search led me to the MailTo URI Scheme Wikipedia page. Another Google search for “Bitcoin URI Scheme” led me to this page with a technical write up of a URI Scheme for sending Bitcoin payments. Lo and behold, the samples on that page work just like I’d expect by opening the local client on my computer with the address filled in. The only problem I can see is that most sites aren’t using this already. I would imagine that this would be a no brainer, where anything that makes it easier to send you money is always a good idea. So here’s my plea to other sites to add the code needed for the bitcoin link.

Just in case anyone needs a refresher, it’s done with the <a> tag and in it’s simplest form would look like this.

<a href="bitcoin:PutPaymentAddressHere">Link text goes here</a>
Daniel

Source Control Systems for Work

So I’m working on a project at work to evaluate and implement a source control system to replace a fairly non-existent use of Visual SourceSafe. It has been a while since I’ve looked really in depth at any version control software and I have to say that I’m impressed with the advancements around them. Not necessarily in the version control systems specifically, but in a lot of the auxiliary functionality that they can offer either natively or as with easy add-on. Things like automated builds and continuous integration are things that weren’t even on the map last time I looked at this in any depth.

At my work we decided to evaluate three types of version control; Team Foundation Server (TFS), Subversion, and Git. I’m most familiar with Subversion since that’s what I’ve used in the past and TFS is a fairly obvious choice for us since we are mostly a Microsoft shop with the tools we use. Git however was a bit of a research project for me and I have to say that we fairly quickly decided that it wasn’t for us. Don’t get me wrong it has it’s use cases where it shines, particularly in development environments where the development team is widely dispersed geographically and not necessarily always network connected. In these cases Git seems really ideal which is probably why it has taken off and is so popular in open source projects, but this is completely different from our primary development environment and the downsides outweigh these benefits.

I don’t know which way we’ll end up going at my job. We’re wanting something simple that will be easy to use and we’re just implementing source control as part of the project. This is why I’m starting to think that we might go with Subversion because TFS can be such a bear to administrate and after getting them installed and starting to set them up, I can understand.

Daniel

Status Report Captain…

So everything has been pretty busy recently and here’s a quick update for some projects. I had some hardware problems with my home virtual server project. I think it came down to a motherboard that went bad, so I changed out the internals and then had some “less than graceful” shutdowns. I think this might have caused some trouble with terabyte drive, but interestingly the RAID 10 setup seems to be fine. In switching out the hardware I did have to downgrade as well, so I bought another Core 2 Duo from my university’s surplus sale recently and upgraded it back to original specs. I’ve also thought that I would dedicate the mass storage into a NAS build from another surplus computer. I’ll have some more about each of these in the near future.

Daniel

Thoughts on the Raspberry Pi board

You may have heard about the Raspberry Pi, which is a low cost ($25 – $35) ARM based computer that has been making the rounds with some geek/technology enthusiasts. Their stated goal is to get more kids interested in programming and computer science by creating a low barrier to entry as possible. There’s been a huge demand for the board from the community and some really cool projects have already been started around them. If I get any, these projects are what I have in mind for them.

  • As an “HTPC” probably using Raspbmc. I’ll probably want to use this as a receiver for a more powerful media streaming server.
  • Driving a wall mounted LCD as a digital signage type display
    • An upgrade would be to drive a touchscreen and make it a “Control Center”
  • Home monitoring and automation
  • Data Acquisition system – I don’t know what this means yet, but it sounds cool…
  • Car computer
  • Kitchen computer
  • Weather Station
  • Of course there’s always the option of using it as an actual computer too…

I think it would be a good fit for any of these type projects, and the low cost makes it ideal for specialty purposes. I’ve seen plenty of people say that they would use it as a NAS and while it would be able to function like one, the performance on it isn’t going to be good at all. The mass storage will be limited to the USB (2.0?) speeds. It could work if you’re wanting to play around with some concepts or as a Pogoplug replacement, but you’ll quickly want a more robust full blown NAS solution when you inevitably scale past the Raspberry Pi’s performance.

Daniel

Running a Home Virtual Server – Part 1: On Hardware and Hypervisors

In this last post I talked about picking up a computer at my university’s surplus sale to use as a replacement server in my home setup. The plan is to use this machine to run several virtual machines on, mostly to play around on but also as my home server. I didn’t go into to much detail in that first post, so I’m going to break this down into multiple posts that can go into more detail. I’m not sure how many parts there will be as of now, but I’ll be sure to try and link all the posts together so they should be easy to find. First up is a discussion about the hardware and my final decision about what virtual environment I decided to go with.

Continue reading Running a Home Virtual Server – Part 1: On Hardware and Hypervisors

Running a Home Virtual Server – Part 0: Reasoning and Requirements

There are pros and cons to working on any kinds of projects, and a setting up a home virtual server is one of those projects that you really need to weigh each and see if you’re up for it. Having started well down the path of implementing one in my home, I think for me it’ll be worth it in the long term going this route. I’ll tell you some of the benefits and drawback I think I’ll have as well as some of the requirements I started out with in my head.

Continue reading Running a Home Virtual Server – Part 0: Reasoning and Requirements

My Computer is How Old?

I came to a sad realization about a week ago now. My university will occasionally have a surplus sale about once a quarter and at least once a semester. They usually sell stuff like desks, chairs, and old couches from the dorms (disgusting). They also use this way to unload computers that get replaced and can’t find a home somewhere else in the school. I’m lucky because they sell computers individually (monitors separate), where a lot of other schools I’ve seen will bundle a pallet and sell them at surplus auctions. In order to sell them individually they have to sell them really cheap ($2 per desktop, $4 per LCD monitor, $10 per laptop) and this will draw quite the crowd. People will camp out the night before in order to be the first in line to get some computers/laptops, it’s a bit like watching footage of Black Friday shoppers.

Continue reading My Computer is How Old?

Implementing multiple Dynamic DNS providers

DNS-o-Matic LogoDynamic DNS services allow people with a dynamic IP address from there ISP (like me) to access resources using a name instead of by IP address. Most routers have support for updating dynamic DNS services, but are usually limited to one service. I use DynDNS (free, which is no longer offered) for this type of access. I wanted to switch my DNS servers to OpenDNS and while they don’t require the same type of updates like DynDNS to work, they offer some interesting features like stats and category filtering using a dynamic DNS type service. The problem is my router only support updates for one dynamic DNS service and it was already updating DynDNS. Luckily, OpenDNS also runs a service called DNS-o-Matic which will update multiple dynamic services at once. Here are some quick steps to set this up on DD-WRT.

Continue reading Implementing multiple Dynamic DNS providers

Quick Thoughts on OpenMediaVault

I’ve played around with FreeNAS in the past. If you aren’t aware it underwent some major changes a while ago where the main developer (Volker) stopped developing and handed over development and maintenance to a company to handle. They basically re-wrote the (now) legacy version (0.7) focusing on business requirements first and foremost and removing many of the features that excited home users about FreeNAS. Since then Volker has been working on a NAS project written on top of Linux (Debian Squeeze) called OpenMediaVault (OMV). Every once in a while I would peek in on each and see how the development has been moving, and from what I can tell OMV has made up a lot of the ground it lost having to write everything from scratch. I’ve started playing around some with OMV in a VirtualBox install and am trying to do some more research to see if it’s “Production” ready for the home environment and would meet any requirements I might have.

Daniel

Getting Stuff From Free Google AdWords Credits

So two months ago Lifehacker detailed some steps to max out bonus referral space on Dropbox with Google AdWords and free ad credits. I ran this as a short experiment with SugarSync, a service similar to Dropbox, which I’ll talk about my experience with. But first a quick overview, The idea is to take free advertising credits offered for Google AdWords and use that to run text ads pointing at your referral link to get people to sign up and get the bonus space offered for the referrals.

The Lifehacker article didn’t have quite the same success as the article they originally based the idea from. It looks like they spent $60 of their $100 credit to get 8 GB of free space, the original article maxed out 16 GB using just under $10. Both of them used Dropbox while I went a similar route with SugarSync. There are some advantages of SugarSync over Dropbox. The two that stand out the most are they currently offer a larger amount of free storage over Dropbox (5 GB vs. 2 GB), and they don’t cap the maximum amount you can get from their referral bonus (which is also larger than Dropbox, 500 MB vs 250 MB).

While running the ads for about 3 days I spent a total of $43 in credits; this netted me 304 click-throughs, 33 sign-ups, with 13 currently completed that have awarded me bonus space. Of course if those other sign-ups can download the SugarSync software in the future, and I’ll get the bonus space when they do. Read more after the break for some ideas I have regarding this method along with some other ideas for using my free AdWord Credits.

Continue reading Getting Stuff From Free Google AdWords Credits

A Gamer’s Dilemma.

So with Christmas and the Steam Winter sale over now, I have A LOT of video games that I haven’t played. Between getting a PS3 bundle with 2 games, 2 Xbox 360 games, 7 games in the last Humble Indie Bundle, and 8 games from the Steam Holiday Sale I’ve built up quite the backlog. Of course this is on top of my existing game backlog which is already pretty long.

Continue reading A Gamer’s Dilemma.

Setting up a FreeNAS Box Part 1: The Install

FreeNAS is a task specific operating system designed to be used in Network Attached Storage (NAS) devices. It’s built using FreeBSD as the underlying OS which lets it have some fairly low power hardware requirements. For example the Dell I used is an old Pentium 4 1.7 GHz with 512 MB of RAM and it runs like a charm, granted I don’t put a lot of demand on the box in the way of concurrent transfers or running processes. It’s worth mentioning that the recommended way to install FreeNAS is to install to, and boot from a USB thumb drive. This is the recommended method so it can save as much hard drive space for data storage, but even though it looked like I could boot from the thumb drive like a hard drive in the BIOS I had trouble getting it to boot so I installed the OS to the 160 GB hard drive with partitions for the OS and data. Here’s the parts list with some specifics after the jump.

Parts List:

  1. Old Dell Dimension 4400 – bought at university surplus sale, $5
  2. Various old IDE hard drives I had sitting around – two ~20 GB; one 160 GB, probably cost me something at some point…
  3. USB thumb drive – “borrowed” from family, free

Continue reading Setting up a FreeNAS Box Part 1: The Install