2018-02-11 01:20:58 +01:00
#=================================================
# SET ALL CONSTANTS
#=================================================
2016-12-27 10:44:40 +01:00
2017-07-21 14:56:41 +02:00
app = $YNH_APP_INSTANCE_NAME
2018-02-11 01:28:15 +01:00
[ [ -e "../settings/manifest.json" ] ] || [ [ -e "../manifest.json" ] ] && \
seafile_version = $( ynh_app_upstream_version)
2017-12-09 20:56:20 +01:00
2018-02-11 01:20:58 +01:00
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
2017-07-21 14:56:41 +02:00
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
2017-01-05 23:24:32 +01:00
}
2017-07-21 14:56:41 +02:00
config_nginx( ) {
2017-09-30 15:07:56 +02:00
# 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)
2017-09-30 17:52:42 +02:00
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)
2017-09-30 15:07:56 +02:00
ynh_app_setting_set $app seahub_port $seahub_port
ynh_app_setting_set $app fileserver_port $fileserver_port
fi
2018-05-09 16:13:36 +02:00
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
2016-12-27 10:44:40 +01:00
}
2018-01-19 20:55:44 +01:00
install_source( ) {
mkdir " $final_path /seafile-server- $seafile_version "
2018-07-31 17:46:42 +02:00
if [ [ $architecture = = "i386" ] ]
then
ynh_die "Error : this architecture is no longer supported by the upstream. Please create en issue here : https://github.com/YunoHost-Apps/seafile_ynh/issues to ask to discuss about a support of this architecture"
fi
2018-01-19 20:55:44 +01:00
ynh_setup_source " $final_path /seafile-server- $seafile_version " " $architecture "
2017-01-31 23:25:17 +01:00
}
2017-07-21 14:56:41 +02:00
install_dependance( ) {
2018-05-09 16:13:36 +02:00
ynh_install_app_dependencies python2.7 python-pip python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect python-requests python-dev \
2018-05-09 23:52:06 +02:00
libjpeg62-turbo-dev zlib1g-dev # For building pillow
2018-05-04 22:30:40 +02:00
# Upgrade setuptools for jessie because the new moviepy package is not compatible with setuptools 5.x
[ " $( lsb_release --codename --short) " = "jessie" ] && pip install --upgrade setuptools
2018-05-09 16:13:36 +02:00
pip install --upgrade pillow moviepy
2017-01-31 23:25:17 +01:00
}
2017-07-21 14:56:41 +02:00
ynh_clean_setup ( ) {
2017-08-09 15:34:10 +02:00
pkill -f seafile-controller
pkill -f seaf-server
pkill -f ccnet-server
pkill -f "seahub"
2017-01-31 23:25:17 +01:00
}
2018-06-07 21:20:50 +02:00
# Reload (or other actions) a service and print a log in case of failure.
#
# usage: system_reload service_name [action]
# | arg: service_name - Name of the service to reload
# | arg: action - Action to perform with systemctl. Default: reload
system_reload ( ) {
local service_name = $1
local action = ${ 2 :- reload }
# Reload, restart or start and print the log if the service fail to start or reload
systemctl $action $service_name || (
journalctl --lines= 20 -u $service_name >& 2
tail -n 50 $final_path /logs/*.log
false
)
}