mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Package full upgrade
This commit is contained in:
parent
abc26ef460
commit
ff97d28f63
13 changed files with 340 additions and 291 deletions
|
@ -1,5 +1,5 @@
|
|||
[WEBDAV]
|
||||
enabled = true
|
||||
port = WEBDAV_PORT
|
||||
port = __WEBDAV_PORT__
|
||||
fastcgi = true
|
||||
share_name = /seafdav
|
||||
share_name = /seafdav
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: seafile-server
|
||||
# Required-Start: $local_fs $remote_fs $network mysql
|
||||
# Required-Stop: $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Starts Seafile Server
|
||||
# Description: starts Seafile Server
|
||||
### END INIT INFO
|
||||
|
||||
# Change the value of "user" to your linux user name
|
||||
user=SEAFILE_USER
|
||||
|
||||
# Change the value of "script_path" to your path of seafile installation
|
||||
seafile_dir=SEAFILE_DIR
|
||||
script_path=${seafile_dir}/seafile-server-latest
|
||||
seafile_init_log=${seafile_dir}/logs/seafile.init.log
|
||||
seahub_init_log=${seafile_dir}/logs/seahub.init.log
|
||||
|
||||
# Change the value of fastcgi to true if fastcgi is to be used
|
||||
fastcgi=false
|
||||
# Set the port of fastcgi, default is 8000. Change it if you need different.
|
||||
seahub_web_port=SEAHUB_PORT
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
|
||||
if [ $fastcgi = true ];
|
||||
then
|
||||
sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${seahub_web_port} >> ${seahub_init_log}
|
||||
else
|
||||
sudo -u ${user} ${script_path}/seahub.sh start ${seahub_web_port} >> ${seahub_init_log}
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
|
||||
if [ $fastcgi = true ];
|
||||
then
|
||||
sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${seahub_web_port} >> ${seahub_init_log}
|
||||
else
|
||||
sudo -u ${user} ${script_path}/seahub.sh restart ${seahub_web_port} >> ${seahub_init_log}
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
|
||||
sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
14
conf/seafile.service
Normal file
14
conf/seafile.service
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Seafile
|
||||
After=network.target
|
||||
After=mysql.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/opt/yunohost/__APP__/seafile-server-latest/seafile.sh start
|
||||
ExecStop=/opt/yunohost/__APP__/seafile-server-latest/seafile.sh stop
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
13
conf/seahub.service
Normal file
13
conf/seahub.service
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Seafile hub
|
||||
After=network.target seafile.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/opt/yunohost/__APP__/seafile-server-latest/seahub.sh start
|
||||
ExecStop=/opt/yunohost/__APP__/seafile-server-latest/seahub.sh stop
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -23,7 +23,7 @@
|
|||
"mysql"
|
||||
],
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.4.2"
|
||||
"yunohost": ">= 3.5.2.2"
|
||||
},
|
||||
"arguments": {
|
||||
"install": [
|
||||
|
|
|
@ -11,8 +11,8 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
|
||||
get_configuration() {
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
seafile_user=$(ynh_app_setting_get $app seafile_user)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
seafile_user=$(ynh_app_setting_get --app $app --key seafile_user)
|
||||
|
||||
if [[ -z $final_path ]] || [[ -z $seafile_user ]]
|
||||
then
|
||||
|
@ -25,34 +25,18 @@ get_configuration() {
|
|||
final_path=/opt/yunohost/$app
|
||||
seafile_user=seafile
|
||||
else
|
||||
ynh_die "Error : can't find seafile path"
|
||||
ynh_die --message "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
|
||||
ynh_app_setting_set --app $app --key final_path --value $final_path
|
||||
ynh_app_setting_set --app $app --key seafile_user --value $seafile_user
|
||||
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_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
}
|
||||
|
||||
install_source() {
|
||||
mkdir "$final_path/seafile-server-$seafile_version"
|
||||
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"
|
||||
ynh_die --message "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
|
||||
ynh_setup_source "$final_path/seafile-server-$seafile_version" "$architecture"
|
||||
}
|
||||
|
@ -67,26 +51,13 @@ install_dependance() {
|
|||
fi
|
||||
}
|
||||
|
||||
set_permission() {
|
||||
chown -R $seafile_user:$seafile_user $final_path
|
||||
}
|
||||
|
||||
ynh_clean_setup () {
|
||||
pkill -f seafile-controller
|
||||
pkill -f seaf-server
|
||||
pkill -f ccnet-server
|
||||
pkill -f "seahub"
|
||||
}
|
||||
|
||||
# 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
|
||||
)
|
||||
pkill -f seahub
|
||||
}
|
||||
|
|
|
@ -14,24 +14,37 @@ ynh_abort_if_errors
|
|||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Set configuration for user and final path
|
||||
get_configuration
|
||||
|
||||
# retrieve useful param
|
||||
domain=$(ynh_app_setting_get ${app} domain)
|
||||
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
ynh_print_OFF
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
ynh_print_ON
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
|
||||
# # Backup app files
|
||||
ynh_backup $final_path
|
||||
ynh_backup /home/yunohost.app/seafile-data "data" 1
|
||||
ynh_backup /etc/nginx/conf.d/$domain.d/${app}.conf
|
||||
ynh_backup /etc/init.d/seafile-server
|
||||
ynh_script_progression --message="Backing up code..." --weight=3
|
||||
ynh_backup --src_path $final_path
|
||||
ynh_script_progression --message="Backing up user data..." --weight=10
|
||||
ynh_backup --src_path /home/yunohost.app/seafile-data --dest_path "data"
|
||||
ynh_script_progression --message="Backing configuration..."
|
||||
ynh_backup --src_path /etc/nginx/conf.d/$domain.d/${app}.conf
|
||||
ynh_backup --src_path /etc/systemd/system/seafile.service
|
||||
ynh_backup --src_path /etc/systemd/system/seahub.service
|
||||
|
||||
# Backup mysql
|
||||
ynh_mysql_dump_db ccnetdb > ${YNH_CWD}/ccnetdb.dmp
|
||||
ynh_mysql_dump_db seafiledb > ${YNH_CWD}/seafiledb.dmp
|
||||
ynh_mysql_dump_db seahubdb > ${YNH_CWD}/seahubdb.dmp
|
||||
ynh_script_progression --message="Backing database"
|
||||
ynh_print_OFF
|
||||
ynh_mysql_dump_db --database ccnetdb > ${YNH_CWD}/ccnetdb.dmp
|
||||
ynh_mysql_dump_db --database seafiledb > ${YNH_CWD}/seafiledb.dmp
|
||||
ynh_mysql_dump_db --database seahubdb > ${YNH_CWD}/seahubdb.dmp
|
||||
ynh_print_ON
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
|
@ -14,14 +14,16 @@ ynh_abort_if_errors
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrive arguments
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
domain=$YNH_APP_NEW_DOMAIN
|
||||
old_path=$(ynh_normalize_url_path ${YNH_APP_OLD_PATH:-'/'})
|
||||
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'})
|
||||
seahub_port=$(ynh_app_setting_get $app seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get $app fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get $app webdav_port)
|
||||
old_path=$(ynh_normalize_url_path $YNH_APP_OLD_PATH)
|
||||
path_url=$(ynh_normalize_url_path $YNH_APP_NEW_PATH)
|
||||
seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
|
||||
|
||||
# Get dest folder and system user
|
||||
get_configuration
|
||||
|
@ -45,44 +47,55 @@ fi
|
|||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Updating nginx configuration..."
|
||||
|
||||
# Update nginx config
|
||||
if [ "$old_domain" != "$domain" ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
|
||||
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
|
||||
# Stop service before any change
|
||||
sudo systemctl stop seafile-server.service
|
||||
ynh_systemd_action --service_name seafile --action stop
|
||||
ynh_systemd_action --service_name seahub --action stop
|
||||
sleep 2
|
||||
pkill -f seafile-controller || true
|
||||
pkill -f seaf-server || true
|
||||
pkill -f ccnet-server || true
|
||||
pkill -f seahub || true
|
||||
|
||||
# Update Seafile Config
|
||||
ynh_replace_string "SERVICE_URL = https://$old_domain$old_path" "SERVICE_URL = https://$domain$path_url" $final_path/conf/ccnet.conf
|
||||
ynh_script_progression --message="Updating seafile configuration..."
|
||||
|
||||
# Update Seafile Config
|
||||
ynh_replace_string --match_string "SERVICE_URL = https://$old_domain$old_path" --replace_string "SERVICE_URL = https://$domain$path_url" --target_file $final_path/conf/ccnet.conf
|
||||
|
||||
ynh_replace_string --match_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' --replace_string 'FILE_SERVER_ROOT = "https://'"$domain"'/seafhttp"' --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'SITE_ROOT = "'"$old_path2"'"' --replace_string 'SITE_ROOT = "'"$path_url2"'"' --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string 'MEDIA_URL = "'"$old_path2"'media/"' --replace_string 'MEDIA_URL = "'"$path_url2"'media/"' --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string "LOGIN_URL = '${old_path2}accounts/login/'" --replace_string "LOGIN_URL = '${path_url2}accounts/login/'" --target_file $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string --match_string ' = "seafile@'"$old_domain"'"' --replace_string ' = "seafile@'"$domain"'"' --target_file $final_path/conf/seahub_settings.py
|
||||
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${domain}'\]@g" --target_file $final_path/conf/seahub_settings.py
|
||||
|
||||
ynh_script_progression --message="Updating seafile database" --weight=7
|
||||
|
||||
ynh_replace_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' 'FILE_SERVER_ROOT = "https://'"$domain"'/seafhttp"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'SITE_ROOT = "'"$old_path2"'"' 'SITE_ROOT = "'"$path_url2"'"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string 'MEDIA_URL = "'"$old_path2"'media/"' 'MEDIA_URL = "'"$path_url2"'media/"' $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string "LOGIN_URL = '${old_path2}accounts/login/'" "LOGIN_URL = '${path_url2}accounts/login/'" $final_path/conf/seahub_settings.py
|
||||
ynh_replace_string ' = "seafile@'"$old_domain"'"' ' = "seafile@'"$domain"'"' $final_path/conf/seahub_settings.py
|
||||
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${domain}'\]@g" $final_path/conf/seahub_settings.py
|
||||
# Update database
|
||||
|
||||
# This fonction relplace all old domain name by the new domain name.
|
||||
# use : mysql_relpace_db db_name table collum
|
||||
mysql_relpace_db() {
|
||||
sql_request='UPDATE `'"$2"'` SET '"$3 = replace($3, '$old_domain', '$domain')"
|
||||
ynh_mysql_execute_as_root "$sql_request" $1
|
||||
ynh_print_OFF
|
||||
ynh_mysql_execute_as_root --sql "$sql_request" --database $1
|
||||
ynh_print_ON
|
||||
}
|
||||
|
||||
# ccnet DB
|
||||
|
@ -144,5 +157,8 @@ mysql_relpace_db seahubdb wiki_personalwiki username
|
|||
sleep 2
|
||||
|
||||
# Reload services
|
||||
sudo systemctl reload nginx.service
|
||||
system_reload seafile-server start
|
||||
ynh_script_progression --message="Starting services..."
|
||||
ynh_systemd_action --service_name seafile
|
||||
ynh_systemd_action --service_name seahub
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||
|
|
|
@ -8,49 +8,6 @@ elif [ -n "$(uname -m | grep 86)" ]; then
|
|||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
ynh_die --message "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', encoding='utf-8'))['$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/}"
|
||||
}
|
||||
|
|
127
scripts/install
127
scripts/install
|
@ -14,16 +14,20 @@ ynh_abort_if_errors
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
server_name="$YNH_APP_ARG_SERVER_NAME"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
is_public=$YNH_APP_ARG_PUBLIC_SITE
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
final_path=/opt/yunohost/$app
|
||||
seafile_user=seafile
|
||||
ynh_print_OFF
|
||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
ynh_print_ON
|
||||
|
||||
# Create special path with / at the end
|
||||
if [[ $path_url == '/' ]]
|
||||
|
@ -33,68 +37,77 @@ else
|
|||
path_url2=$path_url"/"
|
||||
fi
|
||||
|
||||
# Check domain/path availability
|
||||
test $(ynh_webpath_available $domain $path_url) == 'True' || ynh_die "$domain$path_url is not available, please use an other domain or path."
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
||||
|
||||
# Check Final Path availability
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
||||
|
||||
# Find available ports
|
||||
ynh_script_progression --message="Finding available ports..."
|
||||
seahub_port=$(ynh_find_port 8000)
|
||||
fileserver_port=$(ynh_find_port 8082)
|
||||
webdav_port=$(ynh_find_port 8080)
|
||||
|
||||
# store config in yunohost
|
||||
ynh_app_setting_set $app server_name "$server_name"
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set $app seafile_user $seafile_user
|
||||
ynh_app_setting_set $app admin $admin
|
||||
ynh_app_setting_set $app seahub_port $seahub_port
|
||||
ynh_app_setting_set $app fileserver_port $fileserver_port
|
||||
ynh_app_setting_set $app webdav_port $webdav_port
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set $app installed_version $seafile_version
|
||||
|
||||
# Retrieve admin email
|
||||
admin_email=$(yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_app_setting_set --app $app --key server_name --value "$server_name"
|
||||
ynh_app_setting_set --app $app --key final_path --value $final_path
|
||||
ynh_app_setting_set --app $app --key seafile_user --value $seafile_user
|
||||
ynh_app_setting_set --app $app --key admin --value $admin
|
||||
ynh_app_setting_set --app $app --key seahub_port --value $seahub_port
|
||||
ynh_app_setting_set --app $app --key fileserver_port --value $fileserver_port
|
||||
ynh_app_setting_set --app $app --key webdav_port --value $webdav_port
|
||||
ynh_app_setting_set --app $app --key is_public --value $is_public
|
||||
ynh_app_setting_set --app $app --key installed_version --value $seafile_version
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
# Create User
|
||||
ynh_system_user_create $seafile_user $final_path
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_system_user_create --username $seafile_user --home_dir $final_path
|
||||
|
||||
# Check dependencies
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=7
|
||||
install_dependance
|
||||
|
||||
# Copy files to the right place
|
||||
test -e $seafile_data && ynh_secure_remove "$seafile_data"
|
||||
ynh_script_progression --message="Cleaning data directory..."
|
||||
test -e $seafile_data && ynh_secure_remove --file="$seafile_data"
|
||||
|
||||
ynh_script_progression --message="Creating base directory..."
|
||||
mkdir -p $final_path
|
||||
mkdir -p $final_path/installed
|
||||
mkdir -p $final_path/logs
|
||||
mkdir -p $final_path/seafile-data
|
||||
|
||||
# Download new version from sources
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
install_source
|
||||
|
||||
# init databases
|
||||
dbuser=seafile
|
||||
db_pwd=$(ynh_string_random 15)
|
||||
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
|
||||
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
|
||||
ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
|
||||
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
db_user=seafile
|
||||
ynh_print_OFF
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name ccnetdb
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd"
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
|
||||
ynh_print_ON
|
||||
|
||||
ynh_script_progression --message="Configuring application..." --weight=3
|
||||
|
||||
# Run install script
|
||||
chmod +x expect_scripts/install.exp
|
||||
chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
||||
ynh_print_OFF
|
||||
expect_scripts/install.exp "$final_path/seafile-server-$seafile_version" "$server_name" "$domain" "$seafile_data" "$fileserver_port" "$db_pwd"
|
||||
ynh_print_ON
|
||||
|
||||
# Update seafile config
|
||||
ynh_replace_string http:// https:// $final_path/conf/ccnet.conf
|
||||
ynh_replace_string :8000 $path_url $final_path/conf/ccnet.conf
|
||||
ynh_replace_string --match_string http:// --replace_string https:// --target_file $final_path/conf/ccnet.conf
|
||||
ynh_replace_string --match_string :8000 --replace_string $path_url --target_file $final_path/conf/ccnet.conf
|
||||
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SITE_ROOT = "'$path_url2'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SERVE_STATIC = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
|
@ -108,10 +121,10 @@ echo "ALLOWED_HOSTS = ['"$domain"']" | tee -a $final_path/conf/seahub_settings.p
|
|||
echo 'EMAIL_USE_TLS = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST = "localhost"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST_USER = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST_PASSWORD = ""' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_PORT = "25"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'DEFAULT_FROM_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'SERVER_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo 'EMAIL_HOST_PASSWORD = ""' | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# LDAP configuration
|
||||
echo '[LDAP]' | tee -a $final_path/conf/ccnet.conf
|
||||
|
@ -123,26 +136,22 @@ echo 'LOGIN_ATTR = mail' | tee -a $final_path/conf/ccnet.conf
|
|||
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# Fix local warning
|
||||
ynh_replace_string en_US.UTF-8 ${LANG:-'en_US.UTF-8'} $final_path/seafile-server-$seafile_version/seahub.sh
|
||||
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh
|
||||
|
||||
# Update gunicorn config
|
||||
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf
|
||||
|
||||
# Add webdav
|
||||
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
||||
ynh_replace_string WEBDAV_PORT $webdav_port $final_path/conf/seafdav.conf
|
||||
ynh_replace_string --match_string __WEBDAV_PORT__ --replace_string $webdav_port --target_file $final_path/conf/seafdav.conf
|
||||
|
||||
# Add Seafile Server to startup
|
||||
cp ../conf/seafile-server /etc/init.d
|
||||
ynh_replace_string SEAHUB_PORT $seahub_port /etc/init.d/seafile-server
|
||||
ynh_replace_string SEAFILE_DIR $final_path /etc/init.d/seafile-server
|
||||
ynh_replace_string SEAFILE_USER $seafile_user /etc/init.d/seafile-server
|
||||
chmod +x /etc/init.d/seafile-server
|
||||
systemctl daemon-reload
|
||||
update-rc.d seafile-server defaults
|
||||
ynh_add_systemd_config --service seafile --template seafile.service
|
||||
ynh_add_systemd_config --service seahub --template seahub.service
|
||||
|
||||
# Config nginx
|
||||
config_nginx
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
|
||||
# Copy first launch script
|
||||
cp expect_scripts/first_launch.exp $final_path
|
||||
|
@ -155,43 +164,59 @@ chown -R $seafile_user:$seafile_user $seafile_data
|
|||
# Start seafile, seahub and populate admin account
|
||||
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-$seafile_version/seafile.sh start"
|
||||
# We escape all char witch needed.
|
||||
ynh_replace_special_string "__ADMIN_PASSWORD__" $admin_password "$final_path/first_launch.exp"
|
||||
su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email"
|
||||
ynh_secure_remove "$final_path/first_launch.exp"
|
||||
ynh_print_OFF
|
||||
ynh_replace_special_string --match_string __ADMIN_PASSWORD__ --replace_string "$admin_password" --target_file $final_path/first_launch.exp
|
||||
ynh_print_ON
|
||||
su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin@$domain"
|
||||
ynh_secure_remove --file="$final_path/first_launch.exp"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent
|
||||
cp ../conf/add_sso_conf.py $final_path
|
||||
cp ../conf/remove_sso_conf.py $final_path
|
||||
python3 $final_path/add_sso_conf.py
|
||||
python3 ../conf/add_sso_conf.py || ynh_die --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. Please fix the syntax to install this app."
|
||||
|
||||
# unprotect media
|
||||
ynh_app_setting_set seafile unprotected_uris "/media"
|
||||
ynh_app_setting_set --app $app --key unprotected_uris --value "/media"
|
||||
|
||||
if [ "$is_public" = "0" ]
|
||||
then
|
||||
ynh_app_setting_delete seafile unprotected_uris
|
||||
ynh_app_setting_delete --app seafile --key unprotected_uris
|
||||
else
|
||||
ynh_app_setting_set seafile unprotected_uris "/"
|
||||
ynh_app_setting_set --app $app --key unprotected_uris --value "/"
|
||||
fi
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate $final_path/logs
|
||||
ln -s $final_path/logs /var/log/seafile
|
||||
|
||||
# register yunohost service
|
||||
yunohost service add seafile-server
|
||||
yunohost service add seafile
|
||||
yunohost service add seahub
|
||||
|
||||
# Restart seafile
|
||||
ynh_script_progression --message="Starting starting services..." --weight=3
|
||||
|
||||
# Kill all services launched for initialisation
|
||||
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seahub.sh stop"
|
||||
systemctl stop seafile-server.service
|
||||
systemctl kill seafile
|
||||
systemctl kill seahub
|
||||
sleep 2
|
||||
|
||||
# We kill all process lunched by the script
|
||||
pkill -f seafile-controller || true
|
||||
pkill -f seaf-server || true
|
||||
|
||||
system_reload seafile-server start
|
||||
# Start service
|
||||
ynh_script_progression --message="Starting seafile services..." --weight=3
|
||||
ynh_systemd_action --service_name seafile
|
||||
ynh_systemd_action --service_name seahub
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -14,17 +14,23 @@ set -u
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Init get Final path
|
||||
get_configuration
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
||||
systemctl stop seafile-server.service
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
|
||||
# Stop all services
|
||||
ynh_systemd_action --service_name seafile --action stop
|
||||
ynh_systemd_action --service_name seahub --action stop
|
||||
|
||||
# Force to kill all process in case of a process is not stoped cleanly
|
||||
pkill -f seafile-controller || true
|
||||
|
@ -33,33 +39,48 @@ pkill -f ccnet-server || true
|
|||
pkill -f seahub || true
|
||||
|
||||
# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent
|
||||
test -e /var/www/$app/remove_sso_conf.py && python3 /var/www/$app/remove_sso_conf.py
|
||||
test -e /opt/yunohost/$app/remove_sso_conf.py && python3 /opt/yunohost/$app/remove_sso_conf.py
|
||||
ynh_secure_remove /var/log/seafile
|
||||
ynh_secure_remove /var/www/$app
|
||||
ynh_secure_remove /opt/yunohost/$app
|
||||
ynh_secure_remove /etc/init.d/seafile-server
|
||||
ynh_secure_remove /home/yunohost.app/seafile-data
|
||||
ynh_secure_remove /tmp/seahub_cache
|
||||
ynh_script_progression --message="Cleaning SSO configuration..."
|
||||
python3 ../conf/remove_sso_conf.py
|
||||
|
||||
ynh_script_progression --message="Removing logs..."
|
||||
ynh_secure_remove --file=/var/log/seafile
|
||||
ynh_script_progression --message="Removing code..."
|
||||
ynh_secure_remove --file=/var/www/$app
|
||||
ynh_secure_remove --file=/opt/yunohost/$app
|
||||
ynh_script_progression --message="Backing up user data..." --weight=10
|
||||
ynh_secure_remove --file=/home/yunohost.app/seafile-data
|
||||
ynh_secure_remove --file=/tmp/seahub_cache
|
||||
|
||||
# Remove databases
|
||||
ynh_mysql_drop_db ccnetdb
|
||||
ynh_mysql_drop_db seafiledb
|
||||
ynh_mysql_drop_db seahubdb
|
||||
ynh_script_progression --message="Removing databases..."
|
||||
ynh_mysql_remove_db --db_name ccnetdb --db_user seafile
|
||||
ynh_mysql_remove_db --db_name seafiledb --db_user seafile
|
||||
ynh_mysql_remove_db --db_name seahubdb --db_user seafile
|
||||
|
||||
# Remove systemd service
|
||||
ynh_script_progression --message="Removing systemd units..."
|
||||
ynh_remove_systemd_config --service seafile
|
||||
ynh_remove_systemd_config --service seahub
|
||||
|
||||
# Remove user
|
||||
ynh_system_user_delete seafile
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
ynh_system_user_delete --username seafile
|
||||
|
||||
# Remove depandance
|
||||
ynh_script_progression --message="Removing dependencies" --weight=10
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
# Remove domain config
|
||||
ynh_secure_remove /etc/nginx/conf.d/$domain.d/seafile.conf
|
||||
# Remove nginx config
|
||||
ynh_script_progression --message="Removing configuration..."
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# Remove logrotate
|
||||
ynh_remove_logrotate
|
||||
|
||||
yunohost service remove seafile-server
|
||||
# Remove the dedicated fail2ban config
|
||||
ynh_remove_fail2ban_config
|
||||
|
||||
# Reload nginx
|
||||
systemctl reload nginx.service
|
||||
yunohost service remove seafile
|
||||
yunohost service remove seahub
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -14,20 +14,25 @@ ynh_abort_if_errors
|
|||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get --app $app --key path))
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
ynh_print_OFF
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
ynh_print_ON
|
||||
|
||||
# Check domain/path availability
|
||||
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain or path."
|
||||
ynh_webpath_available $domain $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path."
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
|
||||
# Restore all config and data
|
||||
ynh_script_progression --message="Restoring files..." --weight=10
|
||||
ynh_restore
|
||||
|
||||
# Get configuration for user and final path
|
||||
|
@ -37,44 +42,56 @@ get_configuration
|
|||
[[ $seafile_user = "seafile" ]] && ynh_system_user_create $seafile_user $final_path
|
||||
|
||||
# Restore dependencies
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
install_dependance
|
||||
|
||||
# Restore mysql dump
|
||||
dbuser=seafile
|
||||
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
|
||||
ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
|
||||
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
|
||||
db_user=seafile
|
||||
ynh_print_OFF
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name ccnetdb --db_pwd "$db_pwd"
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd"
|
||||
ynh_mysql_setup_db --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd"
|
||||
su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp"
|
||||
su -c "mysql -u ${app} -p$db_pwd seafiledb < ${YNH_CWD}/seafiledb.dmp"
|
||||
su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
||||
ynh_print_ON
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Restore sso persistent config
|
||||
python3 $final_path/add_sso_conf.py
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
python3 ../settings/conf/add_sso_conf.py || ynh_die --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. Please fix the syntax to install this app."
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate $final_path/logs
|
||||
ln -s $final_path/logs /var/log/seafile
|
||||
|
||||
# Set permissions to seafile directory
|
||||
chown -R $seafile_user:$seafile_user $final_path
|
||||
chown -R $seafile_user:$seafile_user $seafile_data
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Add Seafile to YunoHost's monitored services
|
||||
yunohost service add seafile-server
|
||||
yunohost service add seafile
|
||||
yunohost service add seahub
|
||||
|
||||
# Reload nginx
|
||||
systemctl reload nginx.service
|
||||
|
||||
# Enable service and start seafile
|
||||
ynh_script_progression --message="Reconfiguring application..."
|
||||
systemctl daemon-reload
|
||||
update-rc.d seafile-server defaults
|
||||
systemctl enable seafile
|
||||
systemctl enable seahub
|
||||
|
||||
# Avoid the current effect
|
||||
sleep 5
|
||||
|
||||
# Restart service
|
||||
system_reload seafile-server start
|
||||
ynh_script_progression --message="Starting seafile services..." --weight=3
|
||||
ynh_systemd_action --service_name seafile
|
||||
ynh_systemd_action --service_name seahub
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
130
scripts/upgrade
130
scripts/upgrade
|
@ -14,23 +14,39 @@ ynh_abort_if_errors
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Init get Final path
|
||||
get_configuration
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
installed_version=$(ynh_app_setting_get $app installed_version)
|
||||
seahub_port=$(ynh_app_setting_get $app seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get $app fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get $app webdav_port)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get --app $app --key path))
|
||||
installed_version=$(ynh_app_setting_get --app $app --key installed_version)
|
||||
seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
|
||||
fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
|
||||
webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
|
||||
ynh_print_OFF
|
||||
root_pwd=$(cat /etc/yunohost/mysql)
|
||||
ynh_print_ON
|
||||
|
||||
# Get configuration for user and final path
|
||||
get_configuration
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
|
||||
# stop seafile server
|
||||
systemctl stop seafile-server.service
|
||||
if [ -e /etc/init.d/seafile-server ]
|
||||
then
|
||||
# Old init script support
|
||||
systemctl stop seafile-server
|
||||
systemctl disable seafile-server
|
||||
ynh_secure_remove --file=/etc/init.d/seafile-server
|
||||
yunohost service remove seafile-server
|
||||
else
|
||||
ynh_systemd_action --service_name seafile --action stop
|
||||
ynh_systemd_action --service_name seahub --action stop
|
||||
fi
|
||||
sleep 2
|
||||
pkill -f seafile-controller || true
|
||||
pkill -f seaf-server || true
|
||||
|
@ -41,97 +57,117 @@ pkill -f seahub || true
|
|||
# MIGRATION FROM OLD VERSION
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
|
||||
# extract new version
|
||||
test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove "$final_path/seafile-server-$seafile_version"
|
||||
test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove --file="$final_path/seafile-server-$seafile_version"
|
||||
install_source
|
||||
|
||||
# Upgrade dependances
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
install_dependance
|
||||
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
|
||||
# permission to execute update script and expect helper
|
||||
chmod +x expect_scripts/upgrade_*.exp
|
||||
chmod +x expect_scripts/minor-upgrade.exp
|
||||
chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
||||
chmod +x $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
|
||||
|
||||
# do the upgrade ( the ";&" syntax mean when it go in the frist cas how are true it do the next case)
|
||||
# do the upgrade ( the ";&" syntax mean when it go in the first case which is true it do all the next case)
|
||||
case $installed_version in
|
||||
"4.0."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_4.1.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"4.1."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"4.3."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"4.4."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"5.0."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"5.1."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"6.0."* )
|
||||
python3 ../conf/update_sso_conf.py || true
|
||||
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_6.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
|
||||
# Enable manually wiki
|
||||
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
|
||||
;&
|
||||
"6.1."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_6.2.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
;&
|
||||
"6.2."* )
|
||||
# Update seafile by script
|
||||
ynh_print_OFF
|
||||
expect_scripts/upgrade_6.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
|
||||
# Update logrotate to have the last version
|
||||
ynh_use_logrotate $final_path/logs --non-append
|
||||
;&
|
||||
esac
|
||||
|
||||
ynh_print_OFF
|
||||
expect_scripts/minor-upgrade.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
ynh_print_ON
|
||||
|
||||
## Install webdav and logrotate if not installed
|
||||
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
||||
then
|
||||
ynh_script_progression --message="Configuring webdav..."
|
||||
webdav_port=$(ynh_find_port 8080)
|
||||
ynh_app_setting_set seafile webdav_port $webdav_port
|
||||
ynh_app_setting_set --app $app --key webdav_port --value $webdav_port
|
||||
|
||||
# Disallow port that was used by old seafile client
|
||||
ccnet_port=$(ynh_app_setting_get $app ccnet_port)
|
||||
seafile_port=$(ynh_app_setting_get $app seafile_port)
|
||||
ccnet_port=$(ynh_app_setting_get --app $app --key ccnet_port)
|
||||
seafile_port=$(ynh_app_setting_get --app $app --key seafile_port)
|
||||
yunohost firewall disallow Both $ccnet_port
|
||||
yunohost firewall disallow Both $seafile_port
|
||||
|
||||
# Add webdav config
|
||||
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
||||
ynh_replace_string WEBDAV_PORT $webdav_port $final_path/conf/seafdav.conf
|
||||
ynh_replace_string --match_string __WEBDAV_PORT__ --replace_string $webdav_port --target_file $final_path/conf/seafdav.conf
|
||||
|
||||
# Add sso config to unprotect domain.tld/seafdav in /etc/ssowat/conf.json.persistent
|
||||
cp ../conf/add_sso_conf.py $final_path
|
||||
cp ../conf/add_sso_conf_webdav.py $final_path
|
||||
cp ../conf/remove_sso_conf.py $final_path
|
||||
python3 $final_path/add_sso_conf_webdav.py
|
||||
python3 ../conf/add_sso_conf_webdav.py
|
||||
|
||||
# Update seafile config
|
||||
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# Add logrotate
|
||||
ynh_use_logrotate $final_path/logs
|
||||
fi
|
||||
|
||||
# Update seahub config for old version to version 5.0.4
|
||||
|
@ -141,49 +177,69 @@ then
|
|||
fi
|
||||
|
||||
# Fix local warning
|
||||
ynh_replace_string en_US.UTF-8 $LANG $final_path/seafile-server-$seafile_version/seahub.sh
|
||||
ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file $final_path/seafile-server-$seafile_version/seahub.sh
|
||||
|
||||
# Update gunicorn config
|
||||
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf
|
||||
|
||||
# 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 $app --key seahub_port --value $seahub_port
|
||||
ynh_app_setting_set --app $app --key fileserver_port --value $fileserver_port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
||||
# Config nginx
|
||||
config_nginx
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
|
||||
# Update init file
|
||||
cp ../conf/seafile-server /etc/init.d
|
||||
ynh_replace_string SEAHUB_PORT $seahub_port /etc/init.d/seafile-server
|
||||
ynh_replace_string SEAFILE_DIR $final_path /etc/init.d/seafile-server
|
||||
ynh_replace_string SEAFILE_USER $seafile_user /etc/init.d/seafile-server
|
||||
chmod +x /etc/init.d/seafile-server
|
||||
systemctl daemon-reload
|
||||
# Add Seafile Server to startup
|
||||
ynh_script_progression --message="Updating systemd units..."
|
||||
ynh_add_systemd_config --service seafile --template seafile.service
|
||||
ynh_add_systemd_config --service seahub --template seahub.service
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# restore correct permissions
|
||||
chown -R $seafile_user:$seafile_user $final_path
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate $final_path/logs --nonappend
|
||||
|
||||
# register yunohost service
|
||||
ynh_script_progression --message="Register seafile service..."
|
||||
yunohost service add seafile
|
||||
yunohost service add seahub
|
||||
|
||||
# delete seafile cache
|
||||
ynh_secure_remove /tmp/seahub_cache
|
||||
ynh_secure_remove --file=/tmp/seahub_cache
|
||||
|
||||
# restart seafile server
|
||||
ynh_script_progression --message="Starting seafile services..." --weight=3
|
||||
sleep 5
|
||||
system_reload seafile-server start
|
||||
ynh_systemd_action --service_name seafile
|
||||
ynh_systemd_action --service_name seahub
|
||||
|
||||
# remove old version files
|
||||
ynh_script_progression --message="Cleaning system and updating settings..."
|
||||
ls $final_path | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \
|
||||
while read f
|
||||
do
|
||||
ynh_secure_remove $final_path/$f
|
||||
ynh_secure_remove --file=$final_path/$f
|
||||
done
|
||||
|
||||
# store new installed version
|
||||
ynh_app_setting_set $app installed_version $seafile_version
|
||||
ynh_app_setting_set --app $app --key installed_version --value $seafile_version
|
||||
|
||||
# Reload nginx
|
||||
systemctl reload nginx.service
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Add table
Reference in a new issue