Automatic Shutdown/Wake Up on FreeNAS

In an attempt to conserve as much electricity as I can, I used some python scripting to automatically turn my FreeNAS server on and off as required. Requires programming knowledge.

WARNING: THIS POST ASSUMES SOME PROGRAMMING KNOWLEDGE, as you will have to tweak it to your own setup. If you aren’t able to generally figure out what is going on in this post, you shouldn’t try it. I take no responsibility to damage caused to your system! I wrote this post in a rush, so I may miss out basic steps.

In an attempt to conserve as much electricity as I can, I turn off my FreeNAS server whenever it’s not being used. Unfortunately, this was quite a tedious task to do manually. So, I used some scripting to automatically turn it on and off. The scripting for auto shutdown is done on the FreeNAS server, while auto wake up is done client-side.

Auto Shutdown

Using a cronjob, the FreeNAS server monitors a preset list of computers (via IP addresses). Once all the computers are off (i.e. no longer reachable on the network), it’ll turn itself off.

1) Create a file named shutdown.py with the following code: shutdown.py

2) Edit the IP addresses section with whichever computers you want to monitor in your network, e.g.:

###### IP addresses #####
# IP addresses go underneath this line, one on each line in the format: ip_list.append('x.x.x.x')
ip_list.append('192.168.1.2')
ip_list.append('192.168.1.3')
###### End IP addresses

3) Place the file somewhere on your server, and make sure it’s executable. You can make a file executable by SSH’ing into the FreeNAS server, and entering the command chmod +x /mnt/path/to/shutdown.py, changing /mnt/path/to/ to the directory that shutdown.py is in.

4) Create a cronjob to run the file. You can do this via the Web UI. For example, the following settings run the script every 5 minutes from 12am-5am. You can adjust this to your own liking.

Automatically Wake Up

Whenever any of the computers in the house are turned on, they send a Wake-on-LAN signal to the FreeNAS server and automatically mount the shares.

Mac OS

Python is required to run this script! Basically, these scripts will check every 3 minutes that the FreeNAS server is on, and that the network shares are mounted. If not, it will attempt to turn on the FreeNAS server (by sending WakeOnLAN) and mounting afp shares. Please feel free to edit the scripts as you see fit, or change the directories they are in, of course making the necessary changes.

1) Create the file com.hoongern.nasmounter.plist in /Users/<your username>/Library/LaunchAgents

2) Create the file nas.py in /Library/Scripts/. YOU HAVE TO EDIT the configuration in the script as required:

3) Restart your Mac. If I remember, launchctl should find the new task. You can run launchctl list and check if com.hoongern.nasmounter is listed. If it’s not, I can’t actually remember what to do. I don’t actually use Mac OS, you see…

Windows

To be honest, I haven’t written a script for Windows. Not that it should be hard at all – just use a similar python script, the Task Scheduler, and the “net use” command to mount Samba shares. If there’s enough interest, I can write it up and post it here – let me know!

Linux

Again, no script yet. Shouldn’t be difficult with a similar python script, cronjob, and the “mount” command to mount Samba/NFS shares.

OpenWRT, a great alternative to DD-WRT

A short opinion on the 3rd party firmwares DD-WRT and OpenWRT, running on my TP-Link TL-WR1043ND router.

For many years now, I’ve been running DD-WRT on my Linksys WRT54GL & WRT54G2.2 routers. The two routers have lasted for over 6 years, but recently they started to develop certain issues such as wireless dropouts and slow ping times (including packet losses).

As a replacement, I decided to go the cheap route and get a TP-Link TL-WR1043ND router. To be honest, my home network requirements are pretty small. I didn’t care too much about wireless throughput as most of the network is wired gigabit. The only features I needed were:

  • Flexible port-based VLAN tagging
  • Full dnsmasq control, for assigning hostnames/domain to local machines
  • Dynamic DNS client (for dyndns.org)
  • Remote SSH management

To be honest, I have managed to achieve much of this via DD-WRT, but the whole interface is messy, with various settings being in seemingly random places. In particular, VLAN/port based tagging was so confusing via the Web UI, and CLI management (via SSH) felt disconnected and more of a “hack”, as many commands have to be saved as start-up scripts.

Enter OpenWRT, which may not have as “nice looking” a Web UI (though more than enough, in my opinion). What draws me is the neat layout of the OS. All configuration is done by editing config files directly in the file system. In addition, all the configuration options are nicely separated into different files such as ddns, network, wireless, dhcp, firewall, etc. The flexibility is nearly limitless, and because one is able to give names to interfaces and reference them in other configuration files, things are far less confusing. Configuring the switch was a breeze via the Web UI, and I was able to set up my Unifi internet connection easily to split up Internet and IPTV.

OpenWRT feels much more like a fully-fledged OS. For example, there is direct access to iptables. All I need to do is to change /etc/config/firewall, and when I’m done, just restart it with /etc/init.d/firewall restart, just like in any other Linux installation. Also, OpenWRT has built in package management, with the ability to install more packages (Yes, DD-WRT does have similar ability with optware). I quickly added WebUI Wake-On-LAN and OpenVPN.

To be honest, there are a ton of other things you can do with OpenWRT, and this messy post isn’t really a thorough comparison of the two. But having used both DD-WRT and OpenWRT, I have to say that when you need flexibility and getting the most out of your router, OpenWRT definitely trumps DD-WRT (which is still a good 3rd-party firmware, no doubt, but more useful for general/easy tasks, or for nice graphs). Once you have grasped the basics of how to manage an OpenWRT installation, you’ll be amazed how the configuration is so much easier to apply and how it works.

Malaysian Mountain Hiking Gear

A while back, I wrote a post on what I EDC (Everyday Carry). While that list included many items which I do find useful, a number of them are only useful in an urban area. Further more, when one is climbing mountains, any extra weight makes things a lot harder. Here is a list of the probably-still-more-than-necessary equipment I use while hiking. To be honest, I’m far from being an experienced hiker, but as someone who loves gear, I thought I’d still write this.

Clothing & Shoes

Top: Cheap & thin t-shirt (mostly the breathable sports type). Something I don’t care about if it gets dirty or torn. If I’m climbing high altitudes, I may wear a singlet underneath.
Bottom: I wear a pair of cycling shorts (tight), which prevents chaffing and leeches, and can also be used as swimming attire. On top of that, short sports pants mostly, but for high altitudes (or very narrow trails) I wear trek bottoms.
Socks: 2 pairs of socks for greater comfort, and if I’m going somewhere leech infested, I add 2 pairs of thin stockings in between the socks to prevent leeches from getting to my feet.
Shoes: A pair of Columbia hiking shoes. Lightweight and decent ankle support, though unfortunately not waterproof. It does have a few flaws: the treads are too close together to be effective in the mud, and wear out over time. In addition, there isn’t enough protection near the bottom of the sides against roots/rocks. I also have a pair of kampung adidas, which I have not gotten around to using yet.

Clothing. Clockwise from top left: T-shirt, cycling shorts, short pants, 2 pairs of socks, 2 pairs of stockings, extra socks, singlet, long sleeve singlet, raincoat
Columbia Hiking Shoes

In addition, I carry the following in my backpack:

  • Extra long-sleeve single for warmth
  • Extra singlet
  • Extra underpants
  • Light (<1500m) or medium (>1500m) raincoat – Also for extra warmth if needed
  • Extra pair of socks

While most mountains in Malaysia don’t get very cold, if it rains heavily, summits can be EXTREMELY windy and cold, to the point where you start shivering badly. I’d estimate with wind chill, you may experience chills < 10 degree celcius. There are times I’d consider taking my lightweight down jacket or a fleece T-shirt, but generally a singlet + long sleeve singlet + t-shirt + raincoat is sufficient.

Navigation & Electronic Gadgets

  • Small compass – Only good for finding North/South/etc. Will replace this with a Suunto A-10 in the future
  • Qstarz BT-Q818XT Bluetooth GPS receiver – I found my phone’s GPS to be inferior. With AGPS, I get <10 second locks and <2m accuracy (with DGPS in the USA I get ~1m accuracy). 36hr battery life and makes my phone last longer
  • Samsung Galaxy S Plus GT-i9001 – Nav Software: Google Maps  & Navigation, GPS Essentials, Bluetooth GPS, My Tracks, EveryTrail, Compass, SkEye. The main reason I went with Android was the fact that I could easily use external GPS receivers and remove the battery (I carry an extra).
  • Casio Pathfinder PAS400B-5V watch – Technically a fishing watch; it’s rugged (nylon strap), shows moon phase, sunrise/sunset and has a silent (vibration) alarm
  • Topographic map of the area – Sometimes I get lazy to print it out, but honestly it’s good to do so, in case the GPS breaks. Although it’s next to impossible navigating in the jungle anyways, if you’re lost, unless you’re very experienced.
  • Digital Camera – currently I’m using a Canon Ixus 310HS which isn’t mine, but generally I let others take photos

IMPORTANT:My GPS, smartphone and camera go into waterproof pouches to protect them from rain & rivers/streams. One definitely can’t afford to have them die in the middle of a hike!

Part of my collection of waterproof bags & drypack

Flashlights, Fire, Signalling & Emergency

Light:


AA battery included for size reference

  • 4Sevens Quark AA (0.2 – 170 lumens) – Main flashlight. Small and powerful, I run it on a Li-Ion. Soon to be replaced with a dedicated headlamp, probably the Zebralight H51F[w].
  • 4Sevens Quark 123^2 (0.2 – 190 lumens) with headband – Secondary flashlight which I can also turn into a headlamp. I run it on a rechargeable Li-Ion cell with 2 spare CR123 cells in my backpack.
  • iTP EOS A3 (max 80 lumens) – Backup flashlight, runs 1xAAA. I hardly ever use this (it’s really small & light) but it’s there if I need it.
  • 4Sevens Quark Turbo X 123^2 (max 500 lumens) – I only carry this if I’m going somewhere I know I’ll need a lot of light.

Fire:

  • 2″ Firesteel / Ferro rod
  • 2x WetFire fire starting tinder
  • 2x simple butane lighters
  • Small box of matches
  • Candle

AA battery included for size reference

Signalling & Emergency:

  • Whistle (Fox 40) – It’s loud and works underwater, but it does require a reasonably strong blow, so effectiveness in an emergency is yet to be tested
  • Signalling Mirror – Good as a general purpose mirror but also features a sighting hole which shows exactly where you’re pointing light
  • Emergency Blanket

Tools & Knives


AA battery included for size reference

  • Benchmade 556 Mini-Griptilian – A small but sturdy 3″ knife. Personally, I find it on the heavy side, but it serves me well. I keep it in a drybag (or wetbag) as tropical jungle humidity can ruin even 154CM steel. Alternatively, a 2.5″ SOG Flash 1.
  • Spyderco Ladybug H1 – Backup blade, very small but rustproof
  • Leatherman Juice Multitool – Decent for its size, although I don’t really like the can opener and scissors compared to those in Swiss Army Knives. Recently, I stopped carrying this as I didn’t find the need for pliers that often.
  • Swiss Army Knive (Tinker)

These days, I generally also pack a small 10″ machete/parang, Chandong style. While it’s really not big enough to do proper cutting, it’s still ok in emergencies, or clearing the odd bush or branch. I decided that if I got a bigger parang, I’d never carry it because of its weight!

Depending on the length of the trip, I may bring my set of sharpening stones – 4″ DMT diamond stones (photo below). At home, I use the Spyderco SharpMaker, and so keep all my knives with 15°/20° edges.


AA battery included for size reference

If you’re going on an uncleared path or need to do any serious work, a machete is essential. Unfortunately, I don’t have one right now.

Food & Hydration

Food tends to vary a lot, but I try to carry carbohydrate-rich snacks, and fatty food. This tends to be foods like nuts (cashew is my favorite), peanut butter/nutella sandwiches, oat bars, dried fruit, etc.

Now and then, I carry a small alcohol stove I made (a penny stove), with about 60ml of methylated spirits and a small mess tin, however, I’ve generally found this unnecessary as I bring foods which do not need cooking and already carry a good amount of water treatment devices.


AA battery included for size reference

For hydration, I sometimes carry the 2x 1 liter bottles pictured above, but these days tend to just use the standard lightweight plastic bottles (600ml and 1.5L), to carry anywhere between 1.2-6L of water. I tend to sweat a lot, so all liquid I carry is isotonic (I make my own isotonic drink with 50ml ribena + 1/4tsp salt per liter of water). On long climbs, one may have to refill water, so I carry a few measured packets of salt, each to be diluted in 1 liter of water, and 30 grams of sugar, as well as 75g of glucose drink mix. If I don’t consume enough salt, I start getting muscle cramps.

For water treatment, I carry:

  • Small carbon water filter, good for 75L of water, pictured above
  • 10 chlorine dioxide tablets, each good for 1L
  • LifeStraw 0.2 micron filter, good for 1000L, pictured below.

One thing I lack currently is a proper hydration pack, which would make life much easier!

Shelter

I carry a 7’x10′ lightweight tarp/flysheet, to which I’ve attached 4m of mini paracord (2mm) to each of the 6 attachment rings. In addition, I carry a hammock with an attached mosquito net. With this lightweight setup, I can pretty much camp anywhere if needed. (I.e. in case I can’t cross a river due to high levels, etc.) Of course, it does add about 1.2kg to my overall pack weight.

Rope/cordage

I’m a huge fan of ropes and knots, and even though I don’t do any climbing, I always have cord with me. On person, I always carry 10m/30ft of orange paracord.

In my bag, I have:

  • 30m/100ft of green paracord (pictured above)
  • 7m/23ft of 15kN 25mm tubular webbing
  • Some amount of 25mm/400kg rated webbing for my hammock
  • 30m of rafia string (mostly for marking trails)
  • 7m of mini paracord
  • 2x 30kN lightweight non-locking D-carabiners

I’d love to carry a good amount of proper 6-8mm static rope for me (i.e. Amsteel Blue), but costs just don’t allow me to do so right now.

Other

I generally carry a wooden hiking stick, which has many uses besides being a hiking stick.

I use a medium sized 32L Columbia backpack which isn’t suitable for camping (for which I borrow my friend’s 70L pack), but works well for day hikes, and has good waist support. Inside it:

  • 1st aid kit (medicine, bandages, tweezers, etc.)
  • Small tub of Vaseline (for preventing chaffing)
  • Small notebook, mini sharpie, mini pen
  • Sewing kit
  • Fishing kit (courtesy Lee YK)
  • Glue (Superglue & small hot glue stick)
  • Garbage bag & zip-lock bags
  • 25 liter Deuter dry/wet bag
  • Tissue paper & small towel
  • Bandanna
  • Roll of gaffer tape
  • Extra eyeglasses & swimming goggles – For full UV/impact/wind protection and swimming.
  • Clip-on sunglasses
  • Insect repellent (I have 2 types – Mosiguard [lemon eucalyptus oil] & DEET) – VERY important in the jungle!
  • Garden gloves

There are a few other small items I carry around but they’re not really related to hiking so I didn’t bother mentioning them.

In general, my pack’s weight without any liquids tends to weigh in about 5-7kg. There are times when I imagine I’d be able to complete a hike much easier if not for the extra weight on my back, but honestly, I consider it good training, and it’s comforting to know I have most of the essentials on me.

Bukit Kutu

A 3hr up + 2hr down hike through thick jungle to the peak of Bukit Kutu (1100m). Great view at the top, although not on the day we climbed (it was cloudy).

DISCLAIMER: This post was written in 2012. Information may be out of date!

Location: Kuala Kubu Bharu, Selangor, Malaysia.
Start point: 3.572510N, 101.738128E ~300m a.s.l.
Summit: 3.543263N, 101.719998E 1103m a.s.l.
Difficulty: Moderate. No technical skills required, just a fair amount of stamina. The trail is not very steep, but it goes on for a fair amount of distance. Trail is easy to follow but has a fair number of obstacles (branches, fallen trees, etc.)

Date climbed: Thu 2 Aug 2012

View my post on my 2nd climb to Bukit Kutu (more details, photos, etc.)

Bukit Kutu is technically classified as a hill, but is higher than Mount (Gunung) Datuk which I climbed previously, probably due to its proximity to Fraser’s Hill, which stands even higher at over 1200m. While the name “Kutu” means head lice, I found no lice along the way. It is probably more likely that the name is a shortening of “Bukit Sekutu” which it has also been called in the past.

The drive from Petaling Jaya took about an hour and a half (North-South highway exiting at Bukit Beruntung, passing through Rasa and Kuala Kubu Bharu towards Fraser’s Hill, and then turning into Kg. Pertak). We drove along a narrow gravel road as far as the first bridge crossing, where there was some space at the side of the road to park about 4 cars. One can take a short walk down to the river, which would likely be an ideal picnic/recreational spot. On this particular day, we decided not to do so and to immediately begin our hike up Bukit Kutu.

From the start point, we crossed a total of 3 rivers and 3 streams. The hike through all these was on relatively flat ground. The first 2 rivers were crossed with bridges. The second bridge was broken (and has been broken for quite a while, as I understand), but was still easily crossed without any contact with the water. There are two forks in the path at which we kept right. (Going left at one of the forks apparently goes on to a waterfall, but I have not been there)

For the 3rd river, one can either take off your shoes & socks, and walk across (depth is less than 2ft/60cm), or try to leap from stone to stone (which one of my friends did successfully without getting wet). Keep in mind that if you do this, you may end up slipping into the water and getting your shoes wet. A stick can provide extra stability while crossing. The water was clear and refreshing, but as usual, don’t drink any water without treating/filtering it!


The 3rd river


The 3rd river from the other side

The next 3 streams can all be crossed with shoes on. Just test rocks before placing your weight on them, otherwise you may end up slipping and getting your feet wet – something you definitely would not enjoy with a whole climb ahead of you.

Somewhere around the last stream we walked through an area filled with many fruits such as durian, mangosteen, jackfruit and rambutan.


Durians!

After passing the streams, the trail gradually became steeper, although never as steep as Gunung Datuk is. Traction was limited as the path was sloping, although there are enough tree roots which form natural steps. The trail was abundant with bamboo.

After a while, we reached checkpoint 4 (not sure where CP1, 2, 3 were), and then CP5, which was where we encountered the famous huge boulders. From here, the trail became slower to traverse as there were many fallen trees and bamboo lying across the trail.


Checkpoint 4


Checkpoint 5

Near the summit, we came across the abandoned British outpost, where a chimney remained.


Chimney?

We rested here for a few minutes before climbing up to the summit via ladders. The summit is a small boulder on which you can probably fit, at the most, 5 people. Beware of a wasps nest which is on the underside of the first boulder! (still there as of August 2012) The last thing you would want is to be stung all the way up here. Unfortunately, the weather wasn’t on our side on the day we climbed, so we couldn’t see much. However, we managed to catch glimpses of the Sungai Selangor Dam, which we drove by on our way. On the plus side, the temperature was very cool and there was a strong breeze. The top provides a 360 degree view of the surrounding area.


View of Sg. Selangor dam from the summit

Total ascent time was 3.5hours, although it can be climbed in a much shorter time. We just decided to take a relaxed climb as we were in no hurry. We spent 40 minutes at the summit before beginning our 2 hour descent back to the car.

Extra Notes:

  • While Bukit Kutu has been known for leeches, we didn’t see any on this particular day, probably because it hadn’t been raining for a while.
  • I brought 2 liters of my homemade isotonic drink. This was just enough to last me through the climb, although I sweat a lot more than most people.

GPS Details

View my MUCH MORE detailed Bukit Kutu trail map post

Download GPX, KMZ (Google Earth)
View on EveryTrail (interactive map)

Total distance: 6.72 km (4.2 mi)
Total time: 3:24:06
Moving time: 1:52:19
Average speed: 1.97 km/h (1.2 mi/h)
Average moving speed: 3.59 km/h (2.2 mi/h)
Max speed: 14.96 km/h (9.3 mi/h)
Max elevation: 1103 m (3620 ft)
Min elevation: 287 m (941 ft)
Elevation gain: 905 m (2970 ft)

Download GPX, KMZ (Google Earth)
View on EveryTrail (interactive map)