#!/bin/bash
#
# Simple script to download and install my seafile service script
#
# See http://www.linux-tips-and-tricks.de/en/raspberry/429-how-to-install-seafile-on-raspberry-pi-includes-my-config-files/ for details about the script
#
# (C) 2015 - framp at linux-tips-and-tricks dot de

file="seafile"
logfile="./$file.log"
url="www.linux-tips-and-tricks.de/de/downloads/seafile/download"
target="/etc/init.d"

echo "Downloading $file from $url ..."
if ! wget "http://$url" -O $file 2>$logfile; then
	echo "??? Download of $file failed with RC $?"
	exit 127
fi
echo "Installing $file in $target ..."
if ! sudo mv $file $target; then
	echo "??? Move of $file failed"
	exit 127
fi
if ! sudo chmod 755 $target/$file; then
	echo "??? chmod of $file failed"
	exit 127
fi
echo "$file installed successfully" 
rm $logfile
rm $0
