Category Archives: Mac OS X

Synology NAS: Running CrashPlan in Docker Container


The reason to run CrashPlan in Docker container is to prevent any future Synology’s DSM updates from breaking the CrashPlan app.

Let’s assume the Synology NAS IP address is


Diskstation Manager

Log into Diskstation Manager:

Install Docker.

Package Center -> Utilities -> Third Party -> Docker


SSH into Synology NAS.

ssh admin@

Install CrashPlan Docker container.

sudo docker pull jrcs/crashplan

Run CrashPlan Docker container. In this example, we want to backup photo and video directories.

sudo docker run -d --name CrashPlan \
 -p 4242:4242 -p 4243:4243 \
 -v /volume1/photo:/volume1/photo -v /volume1/video:/volume1/video \

Back to Diskstation Manager

Get authentication token from the running CrashPlan.

Docker -> Container -> CrashPlan -> Details -> 
Terminal -> Create -> bash

Run command:-

cat /var/lib/crashplan/.ui_info

The following text are printed:-


Copy ########-####-####-####-############ to somewhere first.

By default, CrashPlan allocates 1GB of memory. The recommendation is to allocate 1GB of memory per 1TB of storage to prevent CrashPlan from running out of memory. In this example, we are going to increase it to 3GB.

Edit /var/crashplan/conf/my.service.xml.

vi /var/crashplan/conf/my.service.xml

Change the following line:-

<config ...>

Edit /var/crashplan/app/bin/run.conf.

vi /var/crashplan/app/bin/run.conf

Change the following line:-

SRV_JAVA_OPTS="... -Xmx3072m ..."                                                         

Stop CrashPlan Docker container.

Docker -> Container -> CrashPlan -> Action -> Stop

Enable auto-restart on CrashPlan Docker container.

Docker -> Container -> CrashPlan -> Edit -> General Settings -> 
Enable auto-restart -> OK

Start CrashPlan Docker container.

Docker -> Container -> CrashPlan -> Action -> Start

Back to Mac

Download and install CrashPlan software.

Disable CrashPlan service since the UI acts as a client.

sudo launchctl unload -w /Library/LaunchDaemons/com.crashplan.engine.plist

Edit /Applications/

sudo nano /Applications/

Uncomment serviceHost and update Synology NAS IP address.

#Fri Dec 09 09:50:22 CST 2005
#pollerPeriod=1000  # 1 second
#connectRetryDelay=10000  # 10 seconds


Edit /Library/Application Support/CrashPlan/.ui_info.

sudo nano "/Library/Application Support/CrashPlan/.ui_info"

Replace the authentication token with the value from above step. Replace IP address with Synology NAS IP address.


Finally, run CrashPlan app to view the backup process.

OS X + Sed: “extra characters at the end of l command” Error


When executing the following command on OS X…

sed -i 's/megatron/pony/g' /path/to/file.txt

… the following error occurs:-

sed: 1: "/path/to/file.txt": extra characters at the end of l command


Unlike Ubuntu, OS X requires the extension to be explicitly specified. The workaround is to set an empty string:-

sed -i '' 's/megatron/pony/g' /path/to/file.txt

… and now, Megatron has transformed into a pony.

Mac OS X: Setting Default Java Version

Let’s assume we have installed JDK 7 or JDK 8, and we want to set the default Java version. There are several ways to set default Java version. This is by far the easiest way without the need to look for the installed path or mess around with symlinks.

First, let’s make sure we are not on crack and we indeed installed the version we want:-

➜  ~  /usr/libexec/java_home -verbose
Matching Java Virtual Machines (3):
    1.7.0_25, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
    1.6.0_51-b11-457, x86_64:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_51-b11-457, i386:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

In this example, we are going to use JDK 1.7 as our default Java version. Open up the startup file (.bashrc, .zshrc, etc…) and enter this line:-

export JAVA_HOME="`/usr/libexec/java_home -v '1.7*'`"

Restart Terminal and verify the Java version:-

➜  ~  java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
➜  ~  javac -version
javac 1.7.0_25

Homebrew: “Invalid Multibyte Escape” Error


When running brew on OS X Maverick, you get this error:-

Error: /usr/local/Library/Homebrew/download_strategy.rb:84: invalid multibyte escape: /^\037\213/
invalid multibyte escape: /^\037\235/
Please report this bug:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'


After upgrading to OS X Mavericks, the default version of Ruby is v2.0, causing Homebrew to break because it relies on v1.8. See issue #23655 for more information.

To fix this, run the following command:-

brew update

If you are getting the “Permission Denied” errors when running the above command, run the following command to fix the permission problem:-

# Assuming your user name is USER_HERO
sudo chown -R USER_HERO:admin /usr/local
cd /usr/local
git reset --hard origin/master
brew update

“tree” Command on Mac OS X

So, I have been drawing the ASCII file structure tree by hand lately… and that is dumb and time consuming. After digging around, I found a great way to do so.

First, if you don’t have Homebrew, install it first.

Run the following command to install the tree command:-

brew install tree

Now, you can run the following command to create a tree:-

tree [directory]

For example:

tree testMe

… generates:-

├── src
├── testMe.iml
└── web
    ├── WEB-INF
    │   ├── lib
    │   └── web.xml
    └── index.jsp

Configuring Remote UPS Shutdown on Mac OS X

I have APC Smart-UPS SMT1500. It contains a SmartSlot that accepts a network management card that allows the UPS to be connected to the switch (or router) instead of plugging the USB cable from the UPS to a computer. That said, I also have APC AP9630 UPS Network Management Card 2.

My goal is to configure my UPS to shutdown all my Macs (MacBook Pros and Mac Mini) during a power failure.

This is how I do it…

  1. After installing the network management card to the UPS, plug the network cable from the network management card to the switch (or router). An IP address will be automatically assigned to the card. Let’s just say, the resolved IP address is
  2. Plug the Mac’s power plug to the UPS.
  3. Download Apcupsd and install it on your Mac.
  4. At the end of the installation, you will see /etc/apcupsd/apcupsd.conf file on your screen. Do not click on the “restart” button yet.
  5. In that file, change the following lines:-

    UPSCABLE smart
    UPSTYPE snmp

    The DEVICE value is IP:PORT:VENDOR:COMMUNITY, all you need is to change the IP address and leave the rest of to be the same.

    Based on the documentation, BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction… basically, the first that occurs will cause the initiation of a shutdown. So, since I want my Mac to shutdown right away during a power failure, I set my BATTERYLEVEL at 95%. When the UPS’s battery level drops before that mark, it will initiate the shutdown process.

  6. Save this file and reboot your machine.
  7. After rebooting the machine, to ensure the Apcupsd daemon is getting signals from the UPS, run this command:-

    sudo apcaccess

    You should see your Apcupsd configuration and the UPS information, like this:-

    APC      : 001,050,1249
    DATE     : 2013-09-24 20:09:37 -0500  
    HOSTNAME : goliath
    VERSION  : 3.14.10 (13 September 2011) darwin
    CABLE    : Ethernet Link
    DRIVER   : SNMP UPS Driver
    UPSMODE  : Stand Alone
    STARTTIME: 2013-09-24 18:29:28 -0500  
    MODEL    : Smart-UPS 1500
    LINEV    : 125.0 Volts
    LOADPCT  :   0.0 Percent Load Capacity
    BCHARGE  : 100.0 Percent
    TIMELEFT : 335.0 Minutes
    MBATTCHG : 95 Percent
    MINTIMEL : 150 Minutes
    MAXTIME  : 0 Seconds
    MAXLINEV : 126.0 Volts
    MINLINEV : 125.0 Volts
    OUTPUTV  : 110.0 Volts
    SENSE    : High
    DWAKE    : 000 Seconds
    DSHUTD   : 000 Seconds
    DLOWBATT : 10 Minutes
    LOTRANS  : 106.0 Volts
    HITRANS  : 127.0 Volts
    RETPCT   : -1073742588.0 Percent
    ITEMP    : 28.0 C Internal
    ALARMDEL : No alarm
    BATTV    : 27.0 Volts
    LINEFREQ : 60.0 Hz
    LASTXFER : Line voltage notch or spike
    NUMXFERS : 0
    TONBATT  : 0 seconds
    CUMONBATT: 0 seconds
    STESTI   : OFF
    STATFLAG : 0x0700000A Status Flag
    MANDATE  : 06/17/2013
    SERIALNO : AS1325121222
    BATTDATE : 06/17/2013
    NOMOUTV  : 120 Volts
    NOMBATTV : 3221224708.0 Volts
    HUMIDITY : 3221224708.0 Percent
    AMBTEMP  : 3221224708.0 C
    EXTBATTS : -1073742588
    BADBATTS : -1073742588
    FIRMWARE : UPS 08.3 / MCU 14.0
    END APC  : 2013-09-24 20:10:00 -0500

  8. Finally, pull the UPS plug from the wall to simulate a power failure. Once the battery level drops below your threshold, your machine will begin to shutdown in a minute or so.

Useful Information

If you tweak the Apcupsd configuration in /etc/apcupsd/apcupsd.conf file, you will need to restart Apcupsd daemon:-

sudo /Library/StartupItems/apcupsd/apcupsd restart