2016-12-27 10:44:40 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-04-26 18:26:01 +02:00
|
|
|
seafile_version=6.0.9
|
2017-01-05 23:24:32 +01:00
|
|
|
|
|
|
|
## Adapt md5sum while you update app
|
2017-04-26 18:26:01 +02:00
|
|
|
x86_64sum="8d1547c51feecaff757eb64381ce154c"
|
|
|
|
i386sum="8a0b9e08d9c80790752b435c3e148328"
|
|
|
|
armsum="15ca4b69585a990e00474e4cfc4be9eb"
|
2017-01-05 23:24:32 +01:00
|
|
|
|
|
|
|
init_script() {
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
}
|
|
|
|
|
2016-12-27 10:44:40 +01:00
|
|
|
set_configuration() {
|
|
|
|
if [[ -e /var/www/$app ]]
|
|
|
|
then
|
|
|
|
final_path=/var/www/$app
|
|
|
|
seafile_user=www-data
|
|
|
|
elif [[ -e /opt/yunohost/$app ]]
|
2017-01-05 23:24:32 +01:00
|
|
|
then
|
2016-12-27 10:44:40 +01:00
|
|
|
final_path=/opt/yunohost/$app
|
|
|
|
seafile_user=seafile
|
|
|
|
else
|
|
|
|
ynh_die "Error : can't find seafile path"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_source() {
|
2017-04-26 18:26:01 +02:00
|
|
|
if [[ $1 == 'rpi' ]]
|
2016-12-27 10:44:40 +01:00
|
|
|
then
|
2017-01-05 23:24:32 +01:00
|
|
|
wget -q -O '/tmp/seafile_src.tar.gz' 'https://github.com/haiwen/seafile-rpi/releases/download/v'$2'/seafile-server_'$2'_stable_pi.tar.gz'
|
|
|
|
md5sum=$armsum
|
|
|
|
elif [[ $1 == 'x86-64' ]]
|
|
|
|
then
|
2017-07-01 11:57:40 +02:00
|
|
|
wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_x86-64.tar.gz'
|
2017-01-05 23:24:32 +01:00
|
|
|
md5sum=$x86_64sum
|
2016-12-27 10:44:40 +01:00
|
|
|
else
|
2017-07-01 11:57:40 +02:00
|
|
|
wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_i386.tar.gz'
|
2017-01-05 23:24:32 +01:00
|
|
|
md5sum=$i386sum
|
2016-12-27 10:44:40 +01:00
|
|
|
fi
|
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(md5sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $md5sum ]]
|
2016-12-27 10:44:40 +01:00
|
|
|
then
|
|
|
|
ynh_die "Error : can't get seafile source"
|
|
|
|
fi
|
2017-01-31 23:25:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
|
|
|
# $1 = Variable à vérifier
|
|
|
|
# $2 = Texte à afficher en cas d'erreur
|
|
|
|
test -n "$1" || (echo "$2" >&2 && false)
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
|
|
|
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
|
|
|
path="/$path" # Ajoute un / en début de path
|
|
|
|
fi
|
|
|
|
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère.
|
|
|
|
path="${path:0:${#path}-1}" # Supprime le dernier caractère
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-07 16:14:34 +01:00
|
|
|
# Find a free port and return it
|
|
|
|
#
|
|
|
|
# example: port=$(ynh_find_port 8080)
|
|
|
|
#
|
|
|
|
# usage: ynh_find_port begin_port
|
|
|
|
# | arg: begin_port - port to start to search
|
|
|
|
ynh_find_port () {
|
2017-01-31 23:25:17 +01:00
|
|
|
port=$1
|
2017-03-07 16:14:34 +01:00
|
|
|
test -n "$port" || ynh_die "The argument of ynh_find_port must be a valid port."
|
|
|
|
while netcat -z 127.0.0.1 $port # Check if the port is free
|
|
|
|
do
|
|
|
|
port=$((port+1)) # Else, pass to next port
|
2017-01-31 23:25:17 +01:00
|
|
|
done
|
2017-03-07 16:14:34 +01:00
|
|
|
echo $port
|
2017-01-31 23:25:17 +01:00
|
|
|
}
|