Linux

Reading Time: 0

JSON Parsing Nagios Script

MadPsy : October 30, 2016 15:08 : Internet, Linux

Parsing JSON in Bash is never usually the best idea but sometimes it may be necessary or preferred. Here’s a nice easy script which uses the ‘jq’ command to perform JSON parsing in Bash.

imgres

Let’s imagine you have the following JSON which is outputted by a stats gathering process:

{"web_rate":1,"db_rate":2,"php_rate":2}

Parsing that in Bash by writing some regex’s etc is perfecting possible but there’s an infinitely easier way. Welcome to ‘jq’. Let’s see it in action.

more »

Leave a response »

Useful to know Bash parameters

MadPsy : October 30, 2016 14:46 : Linux

Even having written many hundreds of Bash scripts over the years I sometimes forget the basic special parameters which are available. For that reason I’ve made this post which is a copy of the page from gnu.org.

bash-logo-web

more »

Leave a response »

Prevent apcupsd shutting down the OS

MadPsy : October 30, 2016 14:33 : Linux

If you have an APC UPS you may not, for whatever reason, want the OS to trigger a shutdown. The ‘apcupsd’ package will call shutdown whenever the battery capacity is reported too low. To prevent this, just edit the following file.

8c516a38-5056-ae36-fe9e72b8749700c8_pr

more »

Leave a response »

How to download iplayer content on Linux

MadPsy : October 30, 2016 14:18 : Linux

Here is a very simple way to download iPlayer content using a Linux command line tool. This literally downloads the stream and saves it to a file. The best part is, because they’re not DRM protected, you can keep it forever.

bbc-iplayer-logo

more »

Leave a response »

How to resize a VirtualBox disk

MadPsy : October 30, 2016 14:01 : Linux

Very quick post on how to resize a VirtualBox virtual disk.

virtualbox

 

When using QCOW based disks with Virtual Box there’s no automagic method for resizing the disks. Because of that you first have to convert it. Here’s the commands you need…

more »

Leave a response »

That’s not a server, THIS is a server!

MadPsy : April 4, 2016 16:03 : Internet, Linux, Networking

I thought a wee article on what a server is and why they are expensive compared to your average PC might be interesting. When you hear someone say they have built a server for the house what they usually mean to say is they’ve built a PC and have it running various applications which serves ‘stuff’. A real server is a different beast all together.

bullion26_profi_reduced607x350

So what makes a server a server? It boils down to the hardware feature set. Sure, you can get low-end servers which are nothing more than a PC in a fancy rack mount chassis, but lets take a look at higher end goodness.

more »

Leave a response »

How To Create a Tor Exit Node

MadPsy : November 17, 2015 22:07 : Internet, Linux

This will be a quick tutorial on how to configure an Exit Node for the Tor Network. Doing this comes with some inherent risks for the operator but exit nodes are essential for bridging Tor with the ‘clear net’. Without exit nodes, anyone suffering from ISP filtering or those not wishing to have their Internet activity logged (BBC Article) couldn’t utilise Tor to access the Internet.

tor-exit

Unlike bridges, exit nodes (and normal relays) are publicly known devices, for which their IP address and configuration is available for anyone to see. They effectively make the final connection to the destination on behalf of the originating (anonymous) client. The Tor network is drastically short of exit nodes, but for good reason. Because they are the final hop in the chain, they will be making hundreds of outbound connections to whatever website or service Tor users request. It is therefore easy for the powers who be to blame an exit node operator for ‘doing bad things’ when in fact their node is merely participating in a network, much like a traditional router would in any network. Anyway, assuming you have balls of steel and willing to run an exit node I’ll take a look at how to do this with least hassle as possible.

more »

Leave a response »

How To Configure Tor On Your Network

MadPsy : November 15, 2015 15:13 : Internet, Linux, Networking, Security

Tor (‘The Onion Router’) is by far the most popular solution for anonymous browsing, with over 6000 relays and 2.5 million active users.  I’m going to look at how to configure Tor on your network, in a variety of ways. The so called ‘Dark Web’ seems to get a bad press, maybe because of illegal sites like Silkroad, but it’s actually an invaluable resource for citizens or visitors to countries who have severe Internet censorship (including the UK!). Even Facebook has a .onion address, as does the DuckDuckGo search engine and Aphex Twin’s ‘Syro’ album.

tor-logo

By far the simplest and most secure way of using Tor is to install the Tor Browser. It’s dead simple and takes literally a few minutes. However, depending on your goal, there are other ways to use Tor. I’m going to look at a few ways to deploy Tor, including the pros and cons of each. These are:

  • Using the Tor Browser Bundle
  • Configuring a Tor SOCKS proxy
  • Creating a transparent Tor network

more »

Leave a response »

How To: FreePBX on Raspbian

MadPsy : October 30, 2015 14:54 : Linux, RaspberryPi

FreePBX is an opensource front-end for the Asterisk VoIP solution. It can be installed on a Raspberry Pi via a prebuilt image but what if you want to use it directly on Raspbian (or other distros)? Well, it is possible with a few minor tweaks.

FreePBX

Because FreePBX and Asterisk are tightly bound it is a permissions nightmare to get the web interface to work with any other user than ‘asterisk’. If you already have Apache running for other purposes then this is obviously not ideal. For this reason we need to get second Apache process running as the ‘asterisk’ user, while at the same time allowing the main Apache process to run as is. Here’s how you do that.

more »

Leave a response »

How To: Rebuild Linux RAID (Simples!)

MadPsy : October 24, 2015 18:37 : Linux

There are many tutorials on rebuilding Linux Software RAID but most are unnecessarily overly complicated. It’s fairly straight forward – here’s how.

Raid1

Unlike hardware RAID, software RAID is all handled by the operating system itself. This means the process of replication, rebuilding and control is performed by the filesystem with various kernel and userspace software.

more »

Leave a response »

Headless Torrent Daemon on Raspberry Pi

MadPsy : October 19, 2015 08:30 : Internet, Linux, RaspberryPi

If, like me, you use a Raspberry Pi as a multimedia centre it’s really handy being able to kick off a torrent without having to be logged into the Pi. This is especially useful if you want to download something using your phone, to your Pi, from literally anywhere.

transmission

Here’s how to configure Transmission so you can download torrents to your Pi from anywhere.

more »

Leave a response »

How To: Install Tarsnap on Linux

MadPsy : October 14, 2015 16:27 : Internet, Linux, Security

After posting how great Tarsnap is I thought it only fair to write a ‘how to install Tarnsap on Linux’ article, so here goes.

Sign up for an account

This is the easiest part, simply create an account at Tarsnap.com and verify your e-mail address. You will need to ‘top up’ your account with at least 5 American Pasos to actually get started so may as well do that right away. I used Paypal as it makes me feel safe and when I feel safe I sleep better at night.

Once you have an account balance there’s actually not much else to do via the website; the rest is all command line goodness.

Download and Compile the Source Code

I’m going to do the rest as the ‘root’ user. If you’re not feeling as brave you may wish to prefix every command with ‘sudo’ as your normal user – for some reason Ubuntu et al seem to love doing this.

At the time of writing version 1.0.36.1 was the latest.

First up lets get root and change to /tmp and then download the tarball:

sudo -i
cd /tmp/
wget https://www.tarsnap.com/download/tarsnap-autoconf-1.0.36.1.tgz

tarsnap1

more »

Leave a response »

Tarsnap – The Ultimate Backup Solution

MadPsy : October 14, 2015 13:24 : Linux, Security

Tarsnap is a no nonsense backup service for Unix (Linux, Mac etc) and is very nice indeed from a sysadmin’s point of view. It is inherently uber secure by design. It somewhat lacks being end-user friendly though – for example it doesn’t handle expiry of archives out-the-box. Therefore if you wanted GFS style rotation you need to wrap it in something which handles deleting old archives according to whatever deltas.

tarsnap

Their payment model is a bit strange in that it is prepay so you get a warning email when running low on credit or risk having your backups deleted for good. The cost of a particular backup run can more »

1 Comment »

Mopify Behind Apache Reverse Proxy

MadPsy : October 12, 2015 20:23 : Audio, Linux, RaspberryPi

I’ll be writing a post about how great Mopify is shortly but essentially it’s a web plugin for Mopidy which provides a web front end to Spotify running on just about any machine. It means you can control Spotify running on a machine plugged into your HiFi without the needs for the Spotify App on your device. This is handy where you have other people in the house with their own accounts but still want them to be able to control the music on the main HiFi.

spotify-tile

Of course, an ideal host machine might well be a Raspberry Pi with a decent USB Soundcard.

Mopidy runs its own little web server which means more »

1 Comment »

Energy Monitor Cacti Graphing

MadPsy : October 11, 2015 20:09 : Electronics, Linux

Using an off the shelf energy monitor you can graph your energy using Cacti. The monitor unit I’ve used here is a Current Cost ENVI. E-On were giving these away for free but they’ve probably stopped that now.

CurrentCostENVI

It comprises of a sender unit, with a single phase clamp sensor and an more »

Leave a response »

Bluetooth Proximity Sensor

MadPsy : October 11, 2015 18:12 : Linux

bluetooth-logo

I wanted a way to detect if someone was in the house without anyone having to do anything. This is useful, for example, to run a script or launch a program if we can identify who it is. The solution I wanted to play with was using mobile phones. Given that folks are fairly attached to their phones these days this seemed a reasonable detection method.

The script below is written in Python and uses bluetooth to detect if anyone more »

Leave a response »
« Page 1 »