#!/bin/bash

if `wget --no-check-certificate --quiet -O kyotocabinet.tar.gz https://moneta:$DAV_PW@qxqx.de/dav/kyotocabinet.tar.gz`; then
  tar -xf kyotocabinet.tar.gz
else
  wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz
  tar -xzf kyotocabinet-*.tar.gz
  rm kyotocabinet-*.tar.gz
  cd kyotocabinet-*
  ./configure --prefix=/usr
  make
  cd ..
  tar -czf kyotocabinet.tar.gz kyotocabinet-*
  curl -u moneta:$DAV_PW -k -T kyotocabinet.tar.gz https://qxqx.de/dav/ || echo 'Nothing uploaded'
fi
cd kyotocabinet-*
sudo make install
