Upgrade CrashPlan on Synology

My Crashplan installation stopped working a while ago now it’s time fix it.
Update: A few days  after I did this there was a new release available from pcloadletter at http://packages.pcloadletter.co.uk/ so I just installed it and it works perfectly. I recommend to use the packaged version instead of modifying as I did.
On my laptop, Mac OS X, I have version 4.4.1 of Crashplan and on the server it is the 4.3.0-0033 package.
The server log says:
I 09/10/15 03:37PM Upgrades available at central.crashplan.com:443
I 09/10/15 03:37PM Downloading a new version of CrashPlan.
I 09/10/15 03:58PM Download of upgrade complete - version 1430802000433.
I 09/10/15 03:58PM Installing upgrade - version 1430802000433
I 09/10/15 03:58PM Upgrade installed - version 1430802000433
I 09/10/15 03:58PM CrashPlan stopped, version 4.3.0, GUID 646867822750203914
I 10/03/15 02:13PM Synology repairing upgrade in /var/packages/CrashPlan/target/upgrade/1430802000433.1441893534258
You can view the log on the server or via the web interface.
> tail -20 /var/packages/CrashPlan/target/log/history.log.0
If I list the update directory it looks like this:
> ll /var/packages/CrashPlan/target/update
drwxr-xr-x    4 root     root          4096 Oct  3 14:53 .
drwxrwxrwx   11 root     root          4096 Oct  3 14:10 ..
drwxr-xr-x    4 root     root          4096 Oct  3 14:13 1430802000433.1441893534258
-rw-r--r--    1 root     root       9414120 Sep  3 21:55 1430802000433.jar
drwxr-xr-x    2 root     root          4096 Jul 28 15:49 UpgradeUI
-rw-r--r--    1 root     root           127 Jul 28 15:49 start.bat
-rw-r--r--    1 root     root            66 Oct  3 14:53 start.log
-rwxr-xr-x    1 root     root           247 Oct  3 14:13 start.sh
-rw-r--r--    1 root     root            92 Jul 28 15:49 startDesktop.bat
-rwxr-xr-x    1 root     root           312 Oct  3 14:13 startDesktop.sh
-rwxr-xr-x    1 root     root           135 Oct  3 14:13 startDesktopLinux.sh
-rwxr-xr-x    1 root     root           137 Oct  3 14:13 startDesktopSolaris.sh
-rwxr-xr-x    1 root     root            87 Oct  3 14:13 startFirst.sh
-rwxr-xr-x    1 root     root           211 Oct  3 14:13 startLinux.sh
-rwxr-xr-x    1 root     root           213 Oct  3 14:13 startSolaris.sh
Remove the 1430802000433.1441893534258 directory and the 1430802000433.jar file.
> rm -rf 1430802000433.1441893534258
> rm 1430802000433.1441893534258
Now try to start the application again; Action > Run
It will have the status Running but since the packaged version is wrong yo will still see Version: 4.3.0-0033 in the web ui but if you look in the log file you will se another version
I 10/03/15 03:02PM CrashPlan started, version 4.3.3, GUID 646867822750203914
I 10/03/15 03:03PM Backup scheduled to always run
And now there are a new versions to be downloaded, version 4.4.0 and 4.4.1
In my log file I see
I 10/03/15 03:03PM Upgrades available at central.crashplan.com:443
I 10/03/15 03:03PM Downloading a new version of CrashPlan.
I 10/03/15 03:04PM Download of upgrade complete - version 1435726800440.
I 10/03/15 03:04PM Download of upgrade complete - version 1435726800441.
I 10/03/15 03:04PM Installing upgrade - version 1435726800440
I 10/03/15 03:04PM Upgrade failed - version 1435726800440

You can see that Crashplan has downloaded two versions 440 and 441. It tried to upgrade to 440 but failed. Ok, what is happening here?
Crashplan is downloading the new package 1435726800440.jar and extracts it to 1435726800440.<some number>. After the file is extracted it tries to run the command ‘/bin/bash upgrade.sh‘ but of course it fails because bash isn’t installed. By default Synology uses Ash Shell on Busybox. Since BusyBox provides minimalist replacements for most of the utilities you will get the following error when trying to run the script with ash:

> /bin/ash upgrade.sh
upgrade.sh: line 28: syntax error: unexpected "("
We are happy that the script fails because it does a lot of things that will only work on linux so we have to do it another way.
pcloadletter.co.uk have done some modification in the start and stop script to handle a upgrade but it requires a restart of the service.
Now stop and start the service again. After the upgrade (repair) the script will exit without starting the server.
I 10/03/15 05:06PM Stopping CrashPlan
I 10/03/15 05:10PM Synology repairing upgrade in /var/packages/CrashPlan/target/upgrade/1435726800440.1443884368292
Start the server again. It will start and then stop with the following error:
# A fatal error has been detected by the Java Runtime Environment:
# SIGILL (0x4) at pc=0x600f2744, pid=13666, tid=1082590320
# JRE version: Java(TM) SE Embedded Runtime Environment (7.0_75-b13) (build 1.7.0_75-b13)
# Java VM: Java HotSpot(TM) Embedded Client VM (24.75-b04 mixed mode linux-arm )
# Problematic frame:
# C [jna266172871821141437.tmp+0x12744] ffi_prep_cif_machdep+0x16c
# Core dump written. Default location: /volume1/@appstore/CrashPlan/core or core.13666
# An error report file with more information is saved as:
# /volume1/@appstore/CrashPlan/hs_err_pid13666.log
In the script /var/packages/CrashPlan/scripts/start-stop-status.sh created by pcloadletter.co.uk you can see the following statements:
#any downloaded upgrade script will usually have failed despite the above changes  
#so ignore the script and explicitly extract the new java code using the chrisnelson.ca method
  UPGRADE_SCRIPT=`find ${OPTDIR}/upgrade -name "upgrade.sh"`
  if [ -n "${UPGRADE_SCRIPT}" ]; then
    rm ${OPTDIR}/*.pid

    #make CrashPlan log entry
    echo "I ${TIMESTAMP} Synology repairing upgrade in ${SCRIPT_HOME}" >> ${DLOG}

    mv ${SCRIPT_HOME}/upgrade.log ${SCRIPT_HOME}/upgrade.log.old
    UPGRADE_VER=`echo ${SCRIPT_HOME} | sed -r "s/^.*\/([0-9]+)\.[0-9]+/\1/"`
    unzip -o ${OPTDIR}/upgrade/${UPGRADE_VER}.jar "*.jar" -d ${OPTDIR}/lib/
    unzip -o ${OPTDIR}/upgrade/${UPGRADE_VER}.jar "lang/*" -d ${OPTDIR}
    mv ${SCRIPT_HOME}/upgrade.sh ${SCRIPT_HOME}/upgrade.sh.old
    exit 0
The script refers to Cris Nelsons instructions that you can find at http://chrisnelson.ca/2015/07/02/fixing-crashplan-4-3-0-on-synology/.
The script is looking for a file named ‘update.sh’ in the upgrade directory and in my case it found it in the 1435726800440.1443884368292 directory. Then the script is copying files from the1435726800440.jar file. After that the script is exiting so you have to start again after the upgrade.
When looking at the script I saw a bug that will probably lead to an error in the future and it did, see abow. It is because we do not clear the lib directory before we copy the new jar files to it, this means that we can have different versions of the same java library (jar). Another bug that appeared for me was that Synology tried to upgrade the same version multiple times so I had a new directory for each try. This means that the find command in the script returns a list of update scripts instead of just one.
After this was changed I realized that the jna.jar in update file was of version 4.1.0 and the script copied version 3.2.5 to the lib folder. Crashplan loaded the new jna.jar file and it didn’t work. Here is the bug. After I removed it Crashplan started without problems. I have taken care of that in the script below.
This is my modified version of the update statements in the script.
 #any downloaded upgrade script will usually have failed despite the above changes
 #so ignore the script and explicitly extract the new java code using the chrisnelson.ca method
  UPGRADE_SCRIPT=`find ${OPTDIR}/upgrade -name "upgrade.sh"`
  if [ -n "${UPGRADE_SCRIPT}" ]; then
    rm ${OPTDIR}/*.pid
    #make CrashPlan log entry
    echo "I ${TIMESTAMP} Synology repairing upgrade in ${SCRIPT_HOME}" >> ${DLOG}
    mv ${SCRIPT_HOME}/upgrade.log ${SCRIPT_HOME}/upgrade.log.old
    UPGRADE_VER=`echo ${SCRIPT_HOME} | sed -r "s/^.*\/([0-9]+)\.[0-9]+/\1/"`
    mkdir ${BACKUP_DIR}
    echo "I ${TIMESTAMP} Backing up jar files in lib folder before upgrading to ${UPGRADE_VER}" >> ${DLOG}
    mkdir ${BACKUP_DIR}/lib >> ${DLOG}
    cp -p ${OPTDIR}/lib/*.jar ${BACKUP_DIR}/lib >> ${DLOG}
    rm -fv ${OPTDIR}/lib/*.jar >> ${DLOG}
    unzip -o ${OPTDIR}/upgrade/${UPGRADE_VER}.jar "*.jar" -d ${OPTDIR}/lib/ >> ${DLOG}
    echo "I ${TIMESTAMP} Backing up language files in the lang folder before upgrading to ${UPGRADE_VER}" >> ${DLOG}
    mkdir ${BACKUP_DIR}/lang >> ${DLOG}
    cp -p ${OPTDIR}/lang/* ${BACKUP_DIR}/lang >> ${DLOG}
    unzip -o ${OPTDIR}/upgrade/${UPGRADE_VER}.jar "lang/*" -d ${OPTDIR}/lang/ >> ${DLOG}
    echo "I ${TIMESTAMP} Backing up so files  before upgrading to ${UPGRADE_VER}" >> ${DLOG}
    cp -p ${OPTDIR}/*.so ${BACKUP_DIR} >> ${DLOG}
    # Do not copy .so files since we might be on a arm processor
    #unzip -o ${OPTDIR}/upgrade/${UPGRADE_VER}.jar "libjtux*.so libjniwrap.so libjniwrap64.so libmd5.so jniwrap.lic " -d ${OPTDIR} >> ${DLOG}
    mv ${SCRIPT_HOME}/upgrade.sh ${SCRIPT_HOME}/upgrade.sh.old
    echo "I ${TIMESTAMP} CrashPlan is now upgraded to version ${UPGRADE_VER}." >> ${DLOG}
    # dont know why we should exit here, commenting exit command
    #exit 0

  #updates may also overwrite our native binaries
  [ -e ${OPTDIR}/bin/libffi.so.5 ] && cp -fp ${SYNOPKG_PKGDEST}/bin/libffi.so.5 ${OPTDIR}/lib
  [ -e ${OPTDIR}/bin/libjtux.so ] && cp -fp ${OPTDIR}/bin/libjtux.so ${OPTDIR}/
  # for some reason only version 3.2.5 of jna.jar is working and not 4.1.0
  mv ${OPTDIR}/lib/jna.jar ${OPTDIR}/lib/jna.jar.save
  cp -fp ${OPTDIR}/bin/jna-3.2.5.jar ${OPTDIR}/lib
Time to connect with my graphical client to the Synology server
Update: This step is no longer nececcary.
Edit the file /Applications/CrashPlan.app/Contents/Resources/Java/conf/ui.properties on the client computer and add the serviceHost property. Since serviceHost property is commented we will let it be and add a new one with the IP address to our NAS, e.g.:
We also have to update the GUID so the client can connect to the server.
Run the following command on the server:
cat /var/lib/crashplan/.ui_info ;echo
For my server the output is:
Now edit the file /Library/Application\ Support/CrashPlan/.ui_info on the client.
This file contains information about your client GUID so copy this information to a safe place first and then replace it with the output from your server. Don’t forget to update the address with the address to your server. Your probably want to comment out the original property but it doesn’t work so you have to remove it. For me the file looks like this:
After doing this it’s time to start the client.

Move a git repository to another location.

You might think that when moving a git repository from one location to another, all you have to do is to clone and then push to the new location. That is not true. You have to make sure that all remote branches and tags are included. Note that the following instructions will also push all your local branches to.

The following steps will move a repository called my_repo from Google Code to Github. Of course you can use the same steps to move from and to which ever git hosting service you like.

Step by step instructions
  1. Clone the the repository
    git clone https://code.google.com/p/my_repo
    cd my_repo
  2. List all local and remote branches. Note: All branches will be pushed later, both local and remote.
    git branch -a
  3. Track all remote branches.
    for remote in `git branch -r | grep -v '\->'`; do git branch --track ${remote#*/} $remote; done
  4. Add the new remote repository.
    git remote add new-origin git@github.com:user/my_repo.git
  5. List all remote repositories.

    git remote -v
  6. Push all branches to the new remote repository location.
    git push -u --all new-origin
  7. Push all tags to the new remote repository location.
    git push --tags new-origin
  8. Remove or rename the old origin
    git remote rm origin  # or rename ‘git remote rename origin old-origin'
  9. Rename the new-origin.
    git remote rename new-origin origin
  10. List all remote repositories.

    git remote -v
Thats it!

Mavericks and slow Finder

Last weekend I upgraded my MBP to Mavericks. I have been waiting with the upgrade because I didn’t want to have problem with my computer so I figured I’ll wait for some bugfixes before upgrading. So last weekend I decided to take the jump and upgrade. The first thing I discovered was that HyperSwitch was not working as it should and I still have not found a solution to the problem. The next problem was that Finder was incredibly slow when showing the content in folders. Today I was googling for a solution and I encountered a solution by Snaggletooth_DE, https://discussions.apple.com/thread/5492808?start=50&tstart=0.

The solution is to edit the auto_master file.

  1. Open up a Terminal window
  2. Open up the file auto_master
     $ sudo nano /etc/auto_master
  3. Comment out the row “/net  -hosts -nobrowse,hidefromfinder,nosuid”
     #/net                    -hosts          -nobrowse,hidefromfinder,nosuid
  4. Save the file with Ctrl+X
  5. Now restart the computer.
     $ sudo restart

After I have done the changes my Finder was as responsive as it used to be. I decided to test and see if I could reproduce the problem by uncomment the same row. So I did that and restarted. The funny thing now was that Finder was still responsive so I decided to go with that and close the case.

Regex and negative lookbehind

In my current project our application is built with Spring and we are using a couple of Spring profiles. Unfortunately we didn’t make them unique so if we deploy it with another application in the same application server we might get a name clash. We decided that we better try to use names that are specific for our application. So I started renaming all of our spring profiles by just adding the prefix apigw. to the name so it will be more unique.

auth-http-basic => apigw.auth-http-basic
auth-x509 => apigw.auth-x509

It was pretty easy to search for all occurrences and just add the prefix, totally 52 files and 92 changes. But what if I have missed any change that should have been done? It must be some way to use a regex to search for the string ‘auth-http-basic’ that is not preceded by ‘apigw.’. After a quick search with Google I found the answer; Negative Lookbehind.

“(?<!a)b matches a “b” that is not preceded by an “a”, using negative lookbehind. It doesn’t match cab, but matches the b (and only the b) in bed or debt.(?<=a)b (positive lookbehind) matches the b (and only the b) in cab, but does not match bed or debt.”

This is how the regex looks for me, (?<!apigw.)(auth-http-basic|auth-x509). Just fire up SublimeText and use Find in folder..

Black screen when starting Ubuntu

Today I started up my Ubuntu laptop and the login screen was all black. I could see the cursor arrow but everything else was black. The laptop is dual boot with Windows and Ubuntu and I quite recently changed from Linux Mint to Ubuntu. A quick lookup with Uncle Google pointed me to this page, My computer boots to a black screen, what options do I have to fix it? If your system is dual boot. So it was quite easy to fix and since I have Nvidia graphics card I just followed these steps:

  1. In the GRUB menu at startup, press e; then,
  2. Use the arrow keys to replace quiet splash with no splash or nomodeset.
  3. Then press the Ctrl+x key combination to boot.

That’s it. Now everything is fine and dandy

“Eclipse” is damaged and can’t be opened.

Yesterday I downloaded the latest Eclipse named Kepler to my Mac. I unzipped the package as usual and tried to launch it by clicking on the Eclipse file. I received the following error message:


After a quick search on the internet I found the solution in a bug report at Eclipse Bugs . It is the OS X GateKeeper that thinks that the file is corrupt and should be moved to trash. However, the problem is easy the solve. Just follow the following steps.

  1. Open up a shell
  2. Cd yourself into the eclipse directory.
  3. Check the attributes of the directory Eclipse.app/
    $ xattr Eclipse.app/
  4. Remove the ‘com.apple.quarantine’ attribute.
    $ xattr -d com.apple.quarantine Eclipse.app/

Now you should be able to launch Eclipse.

Happy coding

No sound in OS X when playing YouTube videos in Chrome

It have happened a couple of times that I suddenly don’t have any sound from my speakers when watching YouTube videos in Chrome. I don’t know how and when this happens but it is easy to fix. Just open a terminal and run “sudo killall coreaudiod”. I probably should investigate why this happens but I will do that on a rainy day.

$ sudo killall coreaudiod

That’s it.

Alldeles för tyst vid datorn

Hmm, vad tyst det är när jag sitter vid datorn. Hade glömt att installera Spotify på min Linux box.  Ett par klick så är det installerat och tystnaden bruten. Ge mig Timbuktu….

Spotify har tyvärr ingen skarp version av sin programvara utan den för Linux är en preview, som varit preview ganska länge men fungerar alldeles utmärkt 😉 Ett annat alternativ är att köra Spotify i Wine men det är inget jag känner för då de tuffa killarna kör native. Spotify har en bra beskrivning hur man installerar deras preview version.

Lägg till följande rad i filen /etc/apt/sources.list

deb http://repository.spotify.com stable non-free

Kör följande kommando

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59

Uppdatera paketen

sudo apt-get update

Installera spotify

sudo apt-get install spotify-client

Uppgradera Linux Mint

Skriver detta inlägg som dokumentation till mig själv.

För ett tag sedan uppgraderade jag Linux Mint från release 12 till 13. Folket på Linux Mint vill att man skall göra en “fresh uppgrade” vilket innebär att man tar backup på allt sitt data och alla program för att sedan installera över den gamla releasen. Efter att installationen är klar sås skall man läsa tillbaka data och program från backupen. Jag är van att göra en paket-uppgradering istället vilket innebär att man tar en backup (?) och sedan uppgraderar. Beskrivningar för att göra detta är ganska knapphändiga eftersom de inte rekommenderar att man gör på det sättet. Efter att ha googlat runnt en stund så visste jag hur jag skulle göra.

Öppna filen /etc/apt/sources.list och lägg till följande rader:

# Linux Mint 13
deb http://packages.linuxmint.com/ maya main upstream import
deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ precise partner
deb http://packages.medibuntu.org/ precise free non-free

och kommentera bort de rader som tillhör Mint 12. För mig var det följande rader:

# deb http://packages.linuxmint.com/ lisa main upstream import
# deb http://archive.ubuntu.com/ubuntu/ oneiric main restricted universe multiverse
# deb http://archive.ubuntu.com/ubuntu/ oneiric-updates main restricted universe multiverse
# deb http://security.ubuntu.com/ubuntu/ oneiric-security main restricted universe multiverse
# deb http://archive.canonical.com/ubuntu/ oneiric partner
# deb http://packages.medibuntu.org/ oneiric free non-free

Efter att detta var gjort var det bara att köra

apt-get update
apt-get dist-upgrade

Det gick inte bra första gången och jag var tvungen att ta bort ‘mint-search-addon’

apt-get remove mint-search-addon

Nästa gång kanske jag gör en “fresh uppgrade”. Kanske 😉

Installera Google Chrome i Linux Mint

Har precis installerat Linux Mint på min ena dator. Har kört Ubuntu i några år nu men kände att det var dags att byta. Hur som helst så finns inte Google Chrome med i repositoryt så det går inte att installera den från den vanliga software managern. Hur som helst så är det ganska enkelt att installera i Linux ändå. Gör bara följande.

  1. Öppna ett Terminal fönster.
  2. Kör följande kommandon:
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
    sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
    sudo apt-get update && sudo apt-get install google-chrome-stable

Efter att Chrome är installerad är det bara att logga in och synka sina bokmärken, plugins, lösenord mm.

Hade lite trubbel att synka Google Chrome. Det var iofs lätt fixat.

  1. Välj skiftnyckeln längst till höger och sedan Preferences.
  2. Välj Personal stuff i menyn till vänster.
  3. Välj Disconnect Your Google Account.
  4. Nu är kontot bortkopplat från Chrome och det är dags att starta om Chrome.
  5. Starta nu upp Chrome igen och gå sedan in under Personal Stuff och koppla ditt konto.