A lot of my bash scripting experience has been, in one sense, relatively simple. I have several scripts that span several hundred lines and do fairly complex things across multiple systems. From that perspective they aren’t necessarily simple. However it wasn’t until recently that I had to really starting thinking about managing when scripts run and particularly keeping them from “stepping all over each other” when multiple instances of the same script must be run… enter the topic of “Job Control” or “Controlled Execution.”
A common scenario is that your bash script is written to access some shared resource. A few examples of such shared resources:
-An executable file that can only have one running instance at any given time
-A log file that must be written to in a certain order
-Sensitive system files (such as the interfaces file).
What happens if a bash script gets executed once, and then before the first instance finishes running a second instance is fired off? The short answer is typically unexpected/bad stuff that tends to break things.
So the solution is to introduce some job control logic into your scripts. And to that end I want to talk about two methods of controlling job execution that I have started to employ heavily for one of my projects: Simple Lock Files, and the more involved FLOCK application built into most newer Linux distributions. For reference, most of this article is based on a system running Debian Jessie. (more…)
I have been learning a ton of PHP lately in an effort to build a significant amount of custom functionality into a Drupal website. As I am not a developer by trade it has been a steep climb upward. Lately I have been refactoring a lot of my code using functions. Being a noob however, I ran into some issues in that I didn’t understand how PHP scoped the usage of variables.
Case in point, I had written a function to generate a bunch of variables dynamically based on some input into the function, but I wasn’t able to use those variables outside of the function. (more…)
Need to administer some drupal stuff from the command-line? DRUSH is the answer. But first you need to get it installed. I am putting the commands to run here to do just that for my own future reference. Hope this is of benefit to everyone else!
Check if Pear is installed:
If not, install it…
sudo apt-get install php-pear
Add the drush channel to pear:
pear channel-discover pear.drush.org
Finally, a common use for drush for me is updating modules..
drush pm-update --no-core
This tutorial is going to be a bit to the point so there is an assumption that you have a level of comfort with Linux and with basic file manipulation, ownership, etc. I recently launched a new site, www.mtkfirmware.com, that is focused on collecting firmware for Mediatek based devices. The majority of the site is dedicated to firmware download collection. However there is a subset of the site called “dev-tools” that is specifically a collection of software and tutorials on how to modify Mediatek roms. In this case, we are focusing on roms that can be flashed using the SPflash tool which means their format is a series of .img files, a scatter file, etc. Many Mediatek devices are for the Chinese/Asian market and therefore come with a lot of software that is of little interest to western users. Many just come with bloatware that is of interest to no one. Therefore it is often desirable to modify the firmware for these devices and remove all the bloat as well as do a bunch of other things.
I have put it off for a long time… You know… actually really deep-diving and really learning a programming language. After reading, and then reading some more, and then talking to some developers where I work (we are a Microsoft Shop from pretty much top to bottom), and then reading a few more things… I have come down to learning in basically this progression (which probably sounds… and probably is… a bit haphazard):