mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
134 lines
4.3 KiB
Bash
134 lines
4.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
# Detect the system architecture to download the right tarball
|
|
# NOTE: `uname -m` is more accurate and universal than `arch`
|
|
# See https://en.wikipedia.org/wiki/Uname
|
|
if [ -n "$(uname -m | grep 64)" ]; then
|
|
architecture="x86-64"
|
|
elif [ -n "$(uname -m | grep 86)" ]; then
|
|
architecture="i386"
|
|
elif [ -n "$(uname -m | grep arm)" ]; then
|
|
architecture="arm"
|
|
else
|
|
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
|
your hardware and the result of the command \"uname -m\"." 1
|
|
fi
|
|
|
|
# Read the value of a key in a ynh manifest file
|
|
#
|
|
# usage: ynh_read_manifest manifest key
|
|
# | arg: manifest - Path of the manifest to read
|
|
# | arg: key - Name of the key to find
|
|
ynh_read_manifest () {
|
|
manifest="$1"
|
|
key="$2"
|
|
python3 -c "import sys, json;print(json.load(open('$manifest'))['$key'])"
|
|
}
|
|
|
|
# Read the upstream version from the manifest
|
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
|
# For example : 4.3-2~ynh3
|
|
# This include the number before ~ynh
|
|
# In the last example it return 4.3-2
|
|
#
|
|
# usage: ynh_app_upstream_version
|
|
ynh_app_upstream_version () {
|
|
manifest_path="../manifest.json"
|
|
if [ ! -e "$manifest_path" ]; then
|
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
fi
|
|
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
|
echo "${version_key/~ynh*/}"
|
|
}
|
|
|
|
# Read package version from the manifest
|
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
|
# For example : 4.3-2~ynh3
|
|
# This include the number after ~ynh
|
|
# In the last example it return 3
|
|
#
|
|
# usage: ynh_app_package_version
|
|
ynh_app_package_version () {
|
|
manifest_path="../manifest.json"
|
|
if [ ! -e "$manifest_path" ]; then
|
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
fi
|
|
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
|
echo "${version_key/*~ynh/}"
|
|
}
|
|
seafile_version=$(ynh_app_upstream_version)
|
|
|
|
get_configuration() {
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
seafile_user=$(ynh_app_setting_get $app seafile_user)
|
|
|
|
if [[ -z $final_path ]] || [[ -z $seafile_user ]]
|
|
then
|
|
if [[ -e /var/www/$app ]]
|
|
then
|
|
final_path=/var/www/$app
|
|
seafile_user=www-data
|
|
elif [[ -e /opt/yunohost/$app ]]
|
|
then
|
|
final_path=/opt/yunohost/$app
|
|
seafile_user=seafile
|
|
else
|
|
ynh_die "Error : can't find seafile path"
|
|
fi
|
|
ynh_app_setting_set $app final_path $final_path
|
|
ynh_app_setting_set $app seafile_user $seafile_user
|
|
fi
|
|
}
|
|
|
|
set_path_2() {
|
|
if [[ $path == '/' ]]
|
|
then
|
|
path2=$path
|
|
else
|
|
path2=$path"/"
|
|
fi
|
|
}
|
|
|
|
config_nginx() {
|
|
|
|
# In the 3.x seafile version package the seahub_port and fileserver_port wasn't saved in the settings. If the settings is empty we try to get it and save in the settings
|
|
|
|
if [[ -z $seahub_port ]] || [[ -z $fileserver_port ]]
|
|
then
|
|
seahub_port=$(head -n 20 /etc/nginx/conf.d/$domain.d/seafile.conf | grep -E "fastcgi_pass.*127.0.0.1:" | cut -d':' -f2 | cut -d';' -f1)
|
|
fileserver_port=$(head -n 50 /etc/nginx/conf.d/$domain.d/seafile.conf | grep -E "proxy_pass.*127.0.0.1:" | cut -d':' -f3 | cut -d';' -f1 | cut -d'/' -f1)
|
|
|
|
ynh_app_setting_set $app seahub_port $seahub_port
|
|
ynh_app_setting_set $app fileserver_port $fileserver_port
|
|
fi
|
|
|
|
ynh_replace_string PATHTOCHANGE1 $path ../conf/nginx.conf
|
|
ynh_replace_string PATHTOCHANGE2 $path2 ../conf/nginx.conf
|
|
ynh_replace_string ALIASTOCHANGE $final_path/ ../conf/nginx.conf
|
|
ynh_replace_string SEAHUB_PORT $seahub_port ../conf/nginx.conf
|
|
ynh_replace_string SEAFILE_FILESERVER_PORT $fileserver_port ../conf/nginx.conf
|
|
ynh_replace_string WEBDAV_PORT $webdav_port ../conf/nginx.conf
|
|
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
|
|
systemctl reload nginx.service
|
|
}
|
|
|
|
install_source() {
|
|
mkdir "$final_path/seafile-server-$seafile_version"
|
|
ynh_setup_source "$final_path/seafile-server-$seafile_version" "$architecture"
|
|
}
|
|
|
|
install_dependance() {
|
|
ynh_install_app_dependencies python2.7 python-pip python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect python-requests python-dev
|
|
pip install pillow moviepy
|
|
}
|
|
|
|
ynh_clean_setup () {
|
|
pkill -f seafile-controller
|
|
pkill -f seaf-server
|
|
pkill -f ccnet-server
|
|
pkill -f "seahub"
|
|
}
|