mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Full app Update
This commit is contained in:
parent
d20de21fd4
commit
9380ee33c1
12 changed files with 358 additions and 448 deletions
|
@ -8,7 +8,6 @@
|
||||||
admin="john" (USER)
|
admin="john" (USER)
|
||||||
admin_password="Sup3rS3cr3t" (PASSWORD)
|
admin_password="Sup3rS3cr3t" (PASSWORD)
|
||||||
public_site="1" (PUBLIC|public=1|private=0)
|
public_site="1" (PUBLIC|public=1|private=0)
|
||||||
architecture="x86-64"
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
|
|
|
@ -2,7 +2,7 @@ import json
|
||||||
|
|
||||||
with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile:
|
with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile:
|
||||||
data = json.load(jsonFile)
|
data = json.load(jsonFile)
|
||||||
data["unprotected_urls"].append("/seafdav")
|
data["skipped_urls"].append("/seafdav")
|
||||||
|
|
||||||
with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile:
|
with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile:
|
||||||
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
|
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
|
|
@ -1,28 +0,0 @@
|
||||||
SEAFILE_DIR/logs/seaf-server.log
|
|
||||||
{
|
|
||||||
daily
|
|
||||||
missingok
|
|
||||||
rotate 52
|
|
||||||
compress
|
|
||||||
delaycompress
|
|
||||||
notifempty
|
|
||||||
sharedscripts
|
|
||||||
postrotate
|
|
||||||
[ ! -f SEAFILE_DIR/pids/seaf-server.pid ] || kill -USR1 `cat SEAFILE_DIR/pids/seaf-server.pid`
|
|
||||||
endscript
|
|
||||||
}
|
|
||||||
|
|
||||||
SEAFILE_DIR/logs/ccnet.log
|
|
||||||
{
|
|
||||||
daily
|
|
||||||
missingok
|
|
||||||
rotate 52
|
|
||||||
compress
|
|
||||||
delaycompress
|
|
||||||
notifempty
|
|
||||||
sharedscripts
|
|
||||||
postrotate
|
|
||||||
[ ! -f SEAFILE_DIR/pids/ccnet.pid ] || kill -USR1 `cat SEAFILE_DIR/pids/ccnet.pid`
|
|
||||||
endscript
|
|
||||||
}
|
|
||||||
|
|
14
conf/update_sso_conf.py
Normal file
14
conf/update_sso_conf.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile:
|
||||||
|
data = json.load(jsonFile)
|
||||||
|
data["unprotected_urls"].remove("/seafhttp")
|
||||||
|
data["unprotected_urls"].remove("/seafdav")
|
||||||
|
if "skipped_urls" in data:
|
||||||
|
data["skipped_urls"].append("/seafhttp")
|
||||||
|
else:
|
||||||
|
data["skipped_urls"] = ["/seafhttp"]
|
||||||
|
data["skipped_urls"].append("/seafdav")
|
||||||
|
|
||||||
|
with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile:
|
||||||
|
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
|
12
conf/upgrade_6.1.exp
Normal file
12
conf/upgrade_6.1.exp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/expect
|
||||||
|
set timeout 5
|
||||||
|
|
||||||
|
set seafile_dir [lindex $argv 0]
|
||||||
|
set mysql_password [lindex $argv 1]
|
||||||
|
|
||||||
|
spawn $seafile_dir/upgrade/upgrade_5.1_6.0.sh
|
||||||
|
|
||||||
|
expect "to contiune"
|
||||||
|
send "\r";
|
||||||
|
|
||||||
|
interact
|
|
@ -4,6 +4,7 @@
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"url": "https://www.seafile.com",
|
"url": "https://www.seafile.com",
|
||||||
|
"version": "6.1.1",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Open Source Cloud Storage",
|
"en": "Open Source Cloud Storage",
|
||||||
"fr": "Stockage Cloud Open Source"
|
"fr": "Stockage Cloud Open Source"
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.4.0"
|
"yunohost": ">= 2.6.4"
|
||||||
},
|
},
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install": [
|
"install": [
|
||||||
|
@ -76,15 +77,6 @@
|
||||||
"fr": "Est-ce un site public ? Pour utiliser un client sur PC ou l'application mobile, Seafile doit être public"
|
"fr": "Est-ce un site public ? Pour utiliser un client sur PC ou l'application mobile, Seafile doit être public"
|
||||||
},
|
},
|
||||||
"default": "1"
|
"default": "1"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "architecture",
|
|
||||||
"ask": {
|
|
||||||
"en": "What is the server architecture?",
|
|
||||||
"fr": "Quelle est l'architecture du serveur ?"
|
|
||||||
},
|
|
||||||
"choices": ["x86-64", "i386", "rpi"],
|
|
||||||
"default": "x86-64"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,35 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
seafile_version=6.0.9
|
# Retrieve arguments
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
seafile_version=6.1.1
|
||||||
|
|
||||||
## Adapt md5sum while you update app
|
## Adapt md5sum while you update app
|
||||||
x86_64sum="8d1547c51feecaff757eb64381ce154c"
|
x86_64sum="3f887d018bd7eaa8b4e1e7830f365802311686636227f1c08a8c48e89aefc35c"
|
||||||
i386sum="8a0b9e08d9c80790752b435c3e148328"
|
i386sum="6d236c93f5a5f674c52b943428995cfe046965f17f2df9f644e17a704072603b"
|
||||||
armsum="15ca4b69585a990e00474e4cfc4be9eb"
|
armsum="e40a8f3a91a4629428288aaabe4a2d6906dd00afc08faf08916f30b8c5a312e4"
|
||||||
|
|
||||||
init_script() {
|
# Detect the system architecture to download the right tarball
|
||||||
# Exit on command errors and treat unset variables as an error
|
# NOTE: `uname -m` is more accurate and universal than `arch`
|
||||||
set -eu
|
# 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
|
||||||
|
|
||||||
# Source YunoHost helpers
|
get_configuration() {
|
||||||
source /usr/share/yunohost/helpers
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
seafile_user=$(ynh_app_setting_get $app seafile_user)
|
||||||
|
|
||||||
# Retrieve arguments
|
if [[ -z $final_path ]] || [[ -z $seafile_user ]]
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
then
|
||||||
}
|
|
||||||
|
|
||||||
set_configuration() {
|
|
||||||
if [[ -e /var/www/$app ]]
|
if [[ -e /var/www/$app ]]
|
||||||
then
|
then
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
|
@ -30,55 +41,58 @@ set_configuration() {
|
||||||
else
|
else
|
||||||
ynh_die "Error : can't find seafile path"
|
ynh_die "Error : can't find seafile path"
|
||||||
fi
|
fi
|
||||||
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
ynh_app_setting_set $app seafile_user $seafile_user
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
config_nginx() {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
get_source() {
|
get_source() {
|
||||||
if [[ $1 == 'rpi' ]]
|
if [[ $1 == 'arm' ]]
|
||||||
then
|
then
|
||||||
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'
|
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
|
sha256sum=$armsum
|
||||||
elif [[ $1 == 'x86-64' ]]
|
elif [[ $1 == 'x86-64' ]]
|
||||||
then
|
then
|
||||||
wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_x86-64.tar.gz'
|
wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_x86-64.tar.gz'
|
||||||
md5sum=$x86_64sum
|
sha256sum=$x86_64sum
|
||||||
else
|
else
|
||||||
wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_i386.tar.gz'
|
wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_i386.tar.gz'
|
||||||
md5sum=$i386sum
|
sha256sum=$i386sum
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(md5sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $md5sum ]]
|
if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(sha256sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $sha256sum ]]
|
||||||
then
|
then
|
||||||
ynh_die "Error : can't get seafile source"
|
ynh_die "Error : can't get seafile source"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
extract_source() {
|
||||||
# $1 = Variable à vérifier
|
mkdir -p $final_path/seafile-server-$seafile_version
|
||||||
# $2 = Texte à afficher en cas d'erreur
|
tar xzf '/tmp/seafile_src.tar.gz'
|
||||||
test -n "$1" || (echo "$2" >&2 && false)
|
mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
||||||
|
mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
install_dependance() {
|
||||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
ynh_install_app_dependencies python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect ffmpeg python-requests
|
||||||
path="/$path" # Ajoute un / en début de path
|
pip install pillow moviepy
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find a free port and return it
|
ynh_clean_setup () {
|
||||||
#
|
killall seafile-controller
|
||||||
# example: port=$(ynh_find_port 8080)
|
killall seaf-server
|
||||||
#
|
killall ccnet-server
|
||||||
# usage: ynh_find_port begin_port
|
kill $(ps -C python2.7 -o pid,cmd | grep "python2.7 $final_path/seafile-server-$seafile_version/seahub/manage.py" | cut -d' ' -f1)
|
||||||
# | arg: begin_port - port to start to search
|
|
||||||
ynh_find_port () {
|
|
||||||
port=$1
|
|
||||||
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
|
|
||||||
done
|
|
||||||
echo $port
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,70 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
|
# Source YunoHost helpers
|
||||||
# # Import common cmd
|
source /usr/share/yunohost/helpers
|
||||||
# source ./_common.sh
|
|
||||||
#
|
|
||||||
|
|
||||||
######## We implement manually this fonctions
|
# Stop script if errors
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
init_script() {
|
# Import common cmd
|
||||||
# Exit on command errors and treat unset variables as an error
|
source ../settings/scripts/_common.sh
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
}
|
|
||||||
|
|
||||||
set_configuration() {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
######## End of common fonctions
|
|
||||||
|
|
||||||
# Init script
|
|
||||||
init_script
|
|
||||||
|
|
||||||
# Set configuration for user and final path
|
# Set configuration for user and final path
|
||||||
set_configuration
|
get_configuration
|
||||||
|
|
||||||
# The parameter $1 is the backup directory location dedicated to the app
|
# The parameter $1 is the backup directory location dedicated to the app
|
||||||
BACKUP_DIR=$1
|
BACKUP_DIR=$1
|
||||||
|
|
||||||
# The parameter $2 is the id of the app instance ex: strut__2
|
|
||||||
APP=$2
|
|
||||||
|
|
||||||
# retrieve useful param
|
# retrieve useful param
|
||||||
domain=$(ynh_app_setting_get ${APP} domain)
|
domain=$(ynh_app_setting_get ${app} domain)
|
||||||
db_pwd=$(ynh_app_setting_get ${APP} mysqlpwd)
|
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
||||||
|
|
||||||
# Backup app files
|
# # Backup app files
|
||||||
sudo mkdir -p "${BACKUP_DIR}/www"
|
|
||||||
sudo cp -a $final_path/. "${BACKUP_DIR}/www"
|
|
||||||
|
|
||||||
# Backup conf files
|
# mkdir -p "${BACKUP_DIR}/www"
|
||||||
sudo mkdir -p "${BACKUP_DIR}/conf"
|
# cp -a $final_path/. "${BACKUP_DIR}/www"
|
||||||
sudo cp -a /etc/nginx/conf.d/$domain.d/${APP}.conf "${BACKUP_DIR}/conf/${APP}.conf"
|
#
|
||||||
sudo cp -a /etc/logrotate.d/${APP} "${BACKUP_DIR}/conf/${APP}"
|
# # Backup conf files
|
||||||
sudo cp -a /etc/init.d/seafile-server "${BACKUP_DIR}/conf/seafile-server"
|
# mkdir -p "${BACKUP_DIR}/conf"
|
||||||
|
# cp -a /etc/nginx/conf.d/$domain.d/${APP}.conf "${BACKUP_DIR}/conf/${APP}.conf"
|
||||||
|
# cp -a /etc/init.d/seafile-server "${BACKUP_DIR}/conf/seafile-server"
|
||||||
|
#
|
||||||
|
# # Backup data
|
||||||
|
# mkdir -p "${BACKUP_DIR}/data"
|
||||||
|
# cp -a /home/yunohost.app/seafile-data/. "${BACKUP_DIR}/data"
|
||||||
|
|
||||||
# Backup data
|
|
||||||
sudo mkdir -p "${BACKUP_DIR}/data"
|
ynh_backup $final_path
|
||||||
sudo cp -a /home/yunohost.app/seafile-data/. "${BACKUP_DIR}/data"
|
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
|
||||||
|
|
||||||
# Backup mysql
|
# Backup mysql
|
||||||
mysqldump -u ${APP} -p$db_pwd ccnetdb | sudo dd of=${BACKUP_DIR}/ccnetdb.dmp
|
ynh_mysql_dump_db
|
||||||
mysqldump -u ${APP} -p$db_pwd seafiledb | sudo dd of=${BACKUP_DIR}/seafiledb.dmp
|
|
||||||
mysqldump -u ${APP} -p$db_pwd seahubdb | sudo dd of=${BACKUP_DIR}/seahubdb.dmp
|
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
|
185
scripts/install
185
scripts/install
|
@ -1,29 +1,47 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Stop script if errors
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
# Init script
|
|
||||||
init_script
|
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||||
server_name=$YNH_APP_ARG_SERVER_NAME
|
server_name=$YNH_APP_ARG_SERVER_NAME
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||||
is_public=$YNH_APP_ARG_PUBLIC_SITE
|
is_public=$YNH_APP_ARG_PUBLIC_SITE
|
||||||
architecture=$YNH_APP_ARG_ARCHITECTURE
|
|
||||||
seafile_data=/home/yunohost.app/seafile-data
|
seafile_data=/home/yunohost.app/seafile-data
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
seafile_user=www-data
|
seafile_user=www-data
|
||||||
|
|
||||||
# Correct path if it is not correct
|
|
||||||
CHECK_PATH
|
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain or path."
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
ynh_webpath_register $app $domain $path
|
||||||
|
|
||||||
|
# Check Final Path availability
|
||||||
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
|
|
||||||
|
# Find 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
|
||||||
|
|
||||||
# Create special path with / at the end
|
# Create special path with / at the end
|
||||||
if [[ $path == '/' ]]
|
if [[ $path == '/' ]]
|
||||||
|
@ -37,36 +55,19 @@ fi
|
||||||
get_source $architecture $seafile_version
|
get_source $architecture $seafile_version
|
||||||
|
|
||||||
# Retrieve admin email
|
# Retrieve admin email
|
||||||
admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
admin_email=$(yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
sudo apt-get update
|
install_dependance
|
||||||
sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
|
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
test -e $final_path && sudo rm -rf "$final_path"
|
test -e $final_path && rm -rf "$final_path"
|
||||||
test -e $seafile_data && sudo rm -rf "$seafile_data"
|
test -e $seafile_data && rm -rf "$seafile_data"
|
||||||
sudo mkdir -p $final_path
|
mkdir -p $final_path
|
||||||
sudo mkdir -p $final_path/installed
|
mkdir -p $final_path/installed
|
||||||
sudo mkdir -p $final_path/logs
|
mkdir -p $final_path/logs
|
||||||
sudo mkdir -p $final_path/seafile-data
|
mkdir -p $final_path/seafile-data
|
||||||
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
extract_source
|
||||||
sudo tar xzf '/tmp/seafile_src.tar.gz'
|
|
||||||
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
|
||||||
sudo mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
|
|
||||||
|
|
||||||
# Find 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 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 architecture $architecture
|
|
||||||
ynh_app_setting_set $app installed_version $seafile_version
|
|
||||||
|
|
||||||
# init databases
|
# init databases
|
||||||
dbuser=seafile
|
dbuser=seafile
|
||||||
|
@ -77,72 +78,69 @@ ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
|
||||||
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
|
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
|
||||||
|
|
||||||
# Run install script
|
# Run install script
|
||||||
sudo chmod +x ../conf/install.exp
|
chmod +x ../conf/install.exp
|
||||||
sudo chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
||||||
sudo ../conf/install.exp $final_path/seafile-server-$seafile_version $server_name $domain $seafile_data $fileserver_port $db_pwd
|
../conf/install.exp $final_path/seafile-server-$seafile_version $server_name $domain $seafile_data $fileserver_port $db_pwd
|
||||||
|
|
||||||
# Update seafile config
|
# Update seafile config
|
||||||
sudo sed -i "s@http://@https://@g" $final_path/conf/ccnet.conf
|
ynh_replace_string http:// https:// $final_path/conf/ccnet.conf
|
||||||
sudo sed -i "s@:8000@$path@g" $final_path/conf/ccnet.conf
|
ynh_replace_string :8000 $path $final_path/conf/ccnet.conf
|
||||||
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo 'SITE_ROOT = "'$path2'"' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'SITE_ROOT = "'$path2'"' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo 'SERVE_STATIC = False' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'SERVE_STATIC = False' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo 'MEDIA_URL = "'$path2'media/"' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'MEDIA_URL = "'$path2'media/"' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo 'COMPRESS_URL = MEDIA_URL' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo "STATIC_URL = MEDIA_URL + 'assets/'" | sudo tee -a $final_path/conf/seahub_settings.py
|
echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo "LOGIN_URL = '"$path2"accounts/login/'" | sudo tee -a $final_path/conf/seahub_settings.py
|
echo "LOGIN_URL = '"$path2"accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||||
|
|
||||||
# Email configuration
|
# Email configuration
|
||||||
echo 'EMAIL_USE_TLS = False' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'EMAIL_USE_TLS = False' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo 'EMAIL_HOST = "localhost"' | sudo 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'"' | sudo 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 = ""' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'EMAIL_HOST_PASSWORD = ""' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo 'EMAIL_PORT = "25"' | sudo 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'"' | sudo 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'"' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'SERVER_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py
|
||||||
|
|
||||||
# LDAP configuration
|
# LDAP configuration
|
||||||
echo '[LDAP]' | sudo tee -a $final_path/conf/ccnet.conf
|
echo '[LDAP]' | tee -a $final_path/conf/ccnet.conf
|
||||||
echo 'HOST = ldap://localhost:389' | sudo tee -a $final_path/conf/ccnet.conf
|
echo 'HOST = ldap://localhost:389' | tee -a $final_path/conf/ccnet.conf
|
||||||
echo 'BASE = ou=users,dc=yunohost,dc=org' | sudo tee -a $final_path/conf/ccnet.conf
|
echo 'BASE = ou=users,dc=yunohost,dc=org' | tee -a $final_path/conf/ccnet.conf
|
||||||
echo 'LOGIN_ATTR = mail' | sudo tee -a $final_path/conf/ccnet.conf
|
echo 'LOGIN_ATTR = mail' | tee -a $final_path/conf/ccnet.conf
|
||||||
|
|
||||||
# Add Seafile Server to startup
|
# Fix local warning
|
||||||
sudo cp ../conf/seafile-server /etc/init.d
|
ynh_replace_string en_US.UTF-8 $LANG $final_path/seafile-server-$seafile_version/seahub.sh
|
||||||
sudo sed -i "s@SEAHUB_PORT@$seahub_port@g" /etc/init.d/seafile-server
|
|
||||||
sudo sed -i "s@SEAFILE_DIR@$final_path@g" /etc/init.d/seafile-server
|
|
||||||
sudo chmod +x /etc/init.d/seafile-server
|
|
||||||
sudo update-rc.d seafile-server defaults
|
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
||||||
sed -i "s@PATHTOCHANGE1@$path@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@PATHTOCHANGE2@$path2@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@SEAHUB_PORT@$seahub_port@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@SEAFILE_FILESERVER_PORT@$fileserver_port@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@WEBDAV_PORT@$webdav_port@g" ../conf/nginx.conf
|
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
||||||
|
|
||||||
# Add webdav
|
# Add webdav
|
||||||
sudo cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
||||||
sudo sed -i "s@WEBDAV_PORT@$webdav_port@g" $final_path/conf/seafdav.conf
|
ynh_replace_string WEBDAV_PORT $webdav_port $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
|
||||||
|
chmod +x /etc/init.d/seafile-server
|
||||||
|
update-rc.d seafile-server defaults
|
||||||
|
|
||||||
|
# Config nginx
|
||||||
|
config_nginx
|
||||||
|
|
||||||
# Copy first launch script
|
# Copy first launch script
|
||||||
sudo cp ../conf/first_launch.exp $final_path
|
cp ../conf/first_launch.exp $final_path
|
||||||
sudo chmod +x $final_path/first_launch.exp
|
chmod +x $final_path/first_launch.exp
|
||||||
|
|
||||||
# Set permissions to seafile directory
|
# Set permissions to seafile directory
|
||||||
sudo chown -R $seafile_user:$seafile_user $final_path
|
chown -R $seafile_user:$seafile_user $final_path
|
||||||
sudo chown -R $seafile_user:$seafile_user $seafile_data
|
chown -R $seafile_user:$seafile_user $seafile_data
|
||||||
|
|
||||||
# Start seafile, seahub and populate admin account
|
# Start seafile, seahub and populate admin account
|
||||||
sudo su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-$seafile_version/seafile.sh start"
|
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-$seafile_version/seafile.sh start"
|
||||||
sudo su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email $admin_password"
|
su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email $admin_password"
|
||||||
|
|
||||||
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent
|
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent
|
||||||
sudo cp ../conf/add_sso_conf.py $final_path
|
cp ../conf/add_sso_conf.py $final_path
|
||||||
sudo cp ../conf/remove_sso_conf.py $final_path
|
cp ../conf/remove_sso_conf.py $final_path
|
||||||
sudo python $final_path/add_sso_conf.py
|
python $final_path/add_sso_conf.py
|
||||||
|
|
||||||
# unprotect media
|
# unprotect media
|
||||||
ynh_app_setting_set seafile unprotected_uris "/media"
|
ynh_app_setting_set seafile unprotected_uris "/media"
|
||||||
|
@ -155,18 +153,13 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add logrotate
|
# Add logrotate
|
||||||
sudo cp ../conf/logrotate /etc/logrotate.d/seafile
|
ynh_use_logrotate $final_path/logs/seaf-server.log
|
||||||
sudo sed -i "s@SEAFILE_DIR@$final_path@g" /etc/logrotate.d/seafile
|
ynh_use_logrotate $final_path/logs/ccnet.log
|
||||||
sudo service rsyslog restart
|
|
||||||
|
|
||||||
# register yunohost service
|
# register yunohost service
|
||||||
sudo yunohost service add seafile-server
|
yunohost service add seafile-server
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
|
||||||
sudo service nginx reload
|
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
||||||
# Restart seafile
|
# Restart seafile
|
||||||
sudo su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seahub.sh stop"
|
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seahub.sh stop"
|
||||||
sudo service seafile-server stop
|
systemctl stop seafile-server.service
|
||||||
sudo service seafile-server start
|
systemctl start seafile-server.service # || (sleep 2 && systemctl start seafile-server.service)
|
||||||
|
|
|
@ -1,32 +1,46 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Stop script if errors
|
||||||
|
set -u
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
# Init script
|
# Init get Final path
|
||||||
init_script
|
get_configuration
|
||||||
|
|
||||||
sudo service seafile-server stop || true
|
# Retrieve arguments
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
|
systemctl stop seafile-server.service
|
||||||
|
|
||||||
# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent
|
# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent
|
||||||
test -e /var/www/$app/remove_sso_conf.py && sudo python /var/www/$app/remove_sso_conf.py
|
test -e /var/www/$app/remove_sso_conf.py && python /var/www/$app/remove_sso_conf.py
|
||||||
test -e /opt/yunohost/$app/remove_sso_conf.py && sudo python /opt/yunohost/$app/remove_sso_conf.py
|
test -e /opt/yunohost/$app/remove_sso_conf.py && python /opt/yunohost/$app/remove_sso_conf.py
|
||||||
sudo rm -rf /var/www/$app
|
ynh_secure_remove /var/www/$app
|
||||||
sudo rm -rf /opt/yunohost/$app
|
ynh_secure_remove /opt/yunohost/$app
|
||||||
sudo rm -f /etc/init.d/seafile-server
|
ynh_secure_remove /etc/init.d/seafile-server
|
||||||
sudo rm -rf /home/yunohost.app/seafile-data
|
ynh_secure_remove /home/yunohost.app/seafile-data
|
||||||
sudo rm -rf /tmp/seahub_cache
|
ynh_secure_remove /tmp/seahub_cache
|
||||||
|
|
||||||
# Remove databases
|
# Remove databases
|
||||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
ynh_mysql_drop_db ccnetdb
|
||||||
mysql -u root -p$root_pwd -e "DROP DATABASE ccnetdb ; DROP DATABASE seafiledb ; DROP DATABASE seahubdb ; DROP USER seafile@localhost ;" || true
|
ynh_mysql_drop_db seafiledb
|
||||||
|
ynh_mysql_drop_db seahubdb
|
||||||
|
|
||||||
|
# Remove depandance
|
||||||
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
# Remove domain config
|
# Remove domain config
|
||||||
domain=$(ynh_app_setting_get seafile domain)
|
ynh_secure_remove /etc/nginx/conf.d/$domain.d/seafile.conf
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
||||||
|
|
||||||
sudo yunohost service remove seafile-server
|
# Remove logrotate
|
||||||
|
ynh_remove_logrotate
|
||||||
|
|
||||||
# Restart services
|
yunohost service remove seafile-server
|
||||||
sudo service nginx reload
|
|
||||||
sudo yunohost app ssowatconf
|
# Reload nginx
|
||||||
|
systemctl reload nginx.service
|
160
scripts/restore
160
scripts/restore
|
@ -1,145 +1,73 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
|
# Source YunoHost helpers
|
||||||
# # Import common cmd
|
source /usr/share/yunohost/helpers
|
||||||
# source ./_common.sh
|
|
||||||
#
|
|
||||||
|
|
||||||
######## We implement manually this fonctions
|
# Stop script if errors
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
seafile_version=6.0.9
|
# Import common cmd
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
## Adapt md5sum while you update app
|
# Init get Final path
|
||||||
x86_64sum="8d1547c51feecaff757eb64381ce154c"
|
get_configuration
|
||||||
i386sum="8a0b9e08d9c80790752b435c3e148328"
|
|
||||||
armsum="15ca4b69585a990e00474e4cfc4be9eb"
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
set_configuration() {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
get_source() {
|
|
||||||
if [[ $1 == 'rpi' ]]
|
|
||||||
then
|
|
||||||
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
|
|
||||||
wget -q -O '/tmp/seafile_src.tar.gz' 'https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_'$2'_x86-64.tar.gz'
|
|
||||||
md5sum=$x86_64sum
|
|
||||||
else
|
|
||||||
wget -q -O '/tmp/seafile_src.tar.gz' 'https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_'$2'_i386.tar.gz'
|
|
||||||
md5sum=$i386sum
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(md5sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $md5sum ]]
|
|
||||||
then
|
|
||||||
ynh_die "Error : can't get seafile source"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
######## End of common fonctions
|
|
||||||
|
|
||||||
# Init script
|
|
||||||
init_script
|
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
path=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||||
|
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
seafile_user=www-data
|
seafile_user=www-data
|
||||||
|
|
||||||
# The parameter $1 is the backup directory location dedicated to the app
|
|
||||||
BACKUP_DIR=$1
|
BACKUP_DIR=$1
|
||||||
|
|
||||||
# retrieve useful param
|
|
||||||
domain=$(ynh_app_setting_get ${app} domain)
|
|
||||||
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
|
||||||
path=$(ynh_app_setting_get ${app} path)
|
|
||||||
|
|
||||||
# Correct path if it is not correct
|
|
||||||
CHECK_PATH
|
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a ${app} \
|
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain or path."
|
||||||
|| (echo "Path not available: $domain$path" && ynh_die "Error : path not available")
|
|
||||||
|
|
||||||
# Restore dependencies
|
# Restore dependencies
|
||||||
sudo apt-get update
|
install_dependance
|
||||||
sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
|
|
||||||
|
|
||||||
# Restore app files
|
# # Restore app files
|
||||||
final_path=$final_path
|
# final_path=$final_path
|
||||||
sudo mkdir -p $final_path
|
# mkdir -p $final_path
|
||||||
sudo cp -a "${BACKUP_DIR}/www/." $final_path
|
# cp -a "${BACKUP_DIR}/www/." $final_path
|
||||||
sudo chown -R $seafile_user:$seafile_user $final_path
|
# chown -R $seafile_user:$seafile_user $final_path
|
||||||
|
#
|
||||||
|
# # Restore conf files
|
||||||
|
# cp -a "${BACKUP_DIR}/conf/${app}.conf" /etc/nginx/conf.d/$domain.d/${app}.conf
|
||||||
|
# cp -a "${BACKUP_DIR}/conf/${app}" /etc/logrotate.d/${app}
|
||||||
|
# cp -a "${BACKUP_DIR}/conf/seafile-server" /etc/init.d/seafile-server
|
||||||
|
# chmod +x /etc/init.d/seafile-server
|
||||||
|
#
|
||||||
|
# # Restore data
|
||||||
|
# seafile_data=/home/yunohost.app/seafile-data
|
||||||
|
# mkdir -p $seafile_data
|
||||||
|
# cp -a "${BACKUP_DIR}/data/." /home/yunohost.app/seafile-data/.
|
||||||
|
# chown -R $seafile_user:$seafile_user $seafile_data
|
||||||
|
|
||||||
# Restore conf files
|
# Restore all config and data
|
||||||
sudo cp -a "${BACKUP_DIR}/conf/${app}.conf" /etc/nginx/conf.d/$domain.d/${app}.conf
|
ynh_restore
|
||||||
sudo cp -a "${BACKUP_DIR}/conf/${app}" /etc/logrotate.d/${app}
|
|
||||||
sudo cp -a "${BACKUP_DIR}/conf/seafile-server" /etc/init.d/seafile-server
|
|
||||||
sudo chmod +x /etc/init.d/seafile-server
|
|
||||||
|
|
||||||
# Restore data
|
|
||||||
seafile_data=/home/yunohost.app/seafile-data
|
|
||||||
sudo mkdir -p $seafile_data
|
|
||||||
sudo cp -a "${BACKUP_DIR}/data/." /home/yunohost.app/seafile-data/.
|
|
||||||
sudo chown -R $seafile_user:$seafile_user $seafile_data
|
|
||||||
|
|
||||||
# Restore mysql dump
|
# Restore mysql dump
|
||||||
dbuser=seafile
|
dbuser=seafile
|
||||||
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
|
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
|
||||||
ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
|
ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
|
||||||
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
|
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
|
||||||
sudo su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${BACKUP_DIR}/ccnetdb.dmp"
|
su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp"
|
||||||
sudo su -c "mysql -u ${app} -p$db_pwd seafiledb < ${BACKUP_DIR}/seafiledb.dmp"
|
su -c "mysql -u ${app} -p$db_pwd seafiledb < ${YNH_CWD}/seafiledb.dmp"
|
||||||
sudo su -c "mysql -u ${app} -p$db_pwd seahubdb < ${BACKUP_DIR}/seahubdb.dmp"
|
su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
||||||
|
|
||||||
# Restore sso persistent config
|
# Restore sso persistent config
|
||||||
sudo python $final_path/add_sso_conf.py
|
python $final_path/add_sso_conf.py
|
||||||
|
|
||||||
|
# Add logrotate
|
||||||
|
ynh_use_logrotate $final_path/logs/seaf-server.log
|
||||||
|
ynh_use_logrotate $final_path/logs/ccnet.log
|
||||||
|
|
||||||
# Add Seafile to YunoHost's monitored services
|
# Add Seafile to YunoHost's monitored services
|
||||||
sudo yunohost service add seafile-server
|
yunohost service add seafile-server
|
||||||
|
|
||||||
# Reload/restart services
|
# Reload nginx
|
||||||
sudo update-rc.d seafile-server defaults
|
systemctl reload nginx.service
|
||||||
sudo service rsyslog restart
|
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
sudo service nginx reload
|
|
||||||
|
|
||||||
# start seafile
|
# start seafile
|
||||||
sudo service seafile-server start
|
systemctl start seafile-server.service
|
||||||
|
|
129
scripts/upgrade
129
scripts/upgrade
|
@ -1,143 +1,138 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Stop script if errors
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
source ./_common.sh
|
source ./_common.sh
|
||||||
|
|
||||||
# Init script
|
# Init get Final path
|
||||||
init_script
|
get_configuration
|
||||||
|
|
||||||
# Retrieve settings
|
# Retrieve arguments
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
path=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||||
installed_version=$(ynh_app_setting_get $app installed_version)
|
installed_version=$(ynh_app_setting_get $app installed_version)
|
||||||
architecture=$(ynh_app_setting_get $app architecture)
|
root_pwd=$(cat /etc/yunohost/mysql)
|
||||||
path=$(ynh_app_setting_get $app path)
|
|
||||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
||||||
|
|
||||||
# Set configuration for user and final path
|
# Get configuration for user and final path
|
||||||
set_configuration
|
get_configuration
|
||||||
|
|
||||||
# Download new version from sources
|
# Download new version from sources
|
||||||
get_source $architecture $seafile_version
|
get_source $architecture $seafile_version
|
||||||
|
|
||||||
# stop seafile server
|
# stop seafile server
|
||||||
sudo service seafile-server stop
|
systemctl stop seafile-server.service
|
||||||
|
|
||||||
# extract new version
|
# extract new version
|
||||||
test -e $final_path/seafile-server-$seafile_version && sudo rm -rf "$final_path/seafile-server-$seafile_version"
|
test -e $final_path/seafile-server-$seafile_version && rm -rf "$final_path/seafile-server-$seafile_version"
|
||||||
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
extract_source
|
||||||
sudo tar xzf '/tmp/seafile_src.tar.gz'
|
|
||||||
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
|
||||||
sudo mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
|
|
||||||
|
|
||||||
# permission to execute update script and expect helper
|
# permission to execute update script and expect helper
|
||||||
sudo chmod +x ../conf/upgrade_*.exp
|
chmod +x ../conf/upgrade_*.exp
|
||||||
sudo chmod +x ../conf/minor-upgrade.exp
|
chmod +x ../conf/minor-upgrade.exp
|
||||||
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
||||||
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/minor-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 frist cas how are true it do the next case)
|
||||||
case $installed_version in
|
case $installed_version in
|
||||||
"4.0."* )
|
"4.0."* )
|
||||||
# Update seafile by script
|
# Update seafile by script
|
||||||
sudo ../conf/upgrade_4.1.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/upgrade_4.1.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
;&
|
;&
|
||||||
"4.1."* )
|
"4.1."* )
|
||||||
# Update seafile by script
|
# Update seafile by script
|
||||||
sudo ../conf/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
;&
|
;&
|
||||||
"4.3."* )
|
"4.3."* )
|
||||||
# Update seafile by script
|
# Update seafile by script
|
||||||
sudo ../conf/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
;&
|
;&
|
||||||
"4.4."* )
|
"4.4."* )
|
||||||
# Update seafile by script
|
# Update seafile by script
|
||||||
sudo ../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
;&
|
;&
|
||||||
"5.0."* )
|
"5.0."* )
|
||||||
# Update seafile by script
|
# Update seafile by script
|
||||||
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
;&
|
;&
|
||||||
"5.1."* )
|
"5.1."* )
|
||||||
# Update seafile by script
|
# Update seafile by script
|
||||||
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
|
;&
|
||||||
|
"6.0."* )
|
||||||
|
python ../conf/update_sso_conf.py
|
||||||
|
install_dependance
|
||||||
|
|
||||||
|
# Update seafile by script
|
||||||
|
../conf/upgrade_6.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
;&
|
;&
|
||||||
esac
|
esac
|
||||||
|
|
||||||
sudo ../conf/minor-upgrade.exp $final_path/seafile-server-$seafile_version $root_pwd
|
../conf/minor-upgrade.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||||
|
|
||||||
## Install webdav and logrotate if not installed
|
## Install webdav and logrotate if not installed
|
||||||
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
||||||
then
|
then
|
||||||
# findPort
|
webdav_port=$(ynh_find_port 8080)
|
||||||
findPort () {
|
|
||||||
port=$1
|
|
||||||
|
|
||||||
sudo yunohost app checkport $port
|
|
||||||
while [[ ! $? -eq 0 ]]
|
|
||||||
do
|
|
||||||
port=$(($port + 1))
|
|
||||||
sudo yunohost app checkport $port
|
|
||||||
done
|
|
||||||
|
|
||||||
return $port
|
|
||||||
}
|
|
||||||
|
|
||||||
findPort 8080
|
|
||||||
webdav_port=$port
|
|
||||||
ynh_app_setting_set seafile webdav_port $webdav_port
|
ynh_app_setting_set seafile webdav_port $webdav_port
|
||||||
|
|
||||||
# Disallow port that was used by old seafile client
|
# Disallow port that was used by old seafile client
|
||||||
ccnet_port=$(ynh_app_setting_get $app ccnet_port)
|
ccnet_port=$(ynh_app_setting_get $app ccnet_port)
|
||||||
seafile_port=$(ynh_app_setting_get $app seafile_port)
|
seafile_port=$(ynh_app_setting_get $app seafile_port)
|
||||||
sudo yunohost firewall disallow Both $ccnet_port
|
yunohost firewall disallow Both $ccnet_port
|
||||||
sudo yunohost firewall disallow Both $seafile_port
|
yunohost firewall disallow Both $seafile_port
|
||||||
|
|
||||||
# Add webdav to nginx config
|
# Add webdav to nginx config
|
||||||
sed -i "s@WEBDAV_PORT@$webdav_port@g" ../conf/nginx_add_webdav
|
ynh_replace_string WEBDAV_PORT $webdav_port ../conf/nginx_add_webdav
|
||||||
domain=$(ynh_app_setting_get seafile domain)
|
echo $(cat ../conf/nginx_add_webdav) | tee -a /etc/nginx/conf.d/$domain.d/seafile.conf
|
||||||
echo $(cat ../conf/nginx_add_webdav) | sudo tee -a /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
||||||
|
|
||||||
# Add webdav config
|
# Add webdav config
|
||||||
sudo cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
||||||
sudo sed -i "s@WEBDAV_PORT@$webdav_port@g" $final_path/conf/seafdav.conf
|
ynh_replace_string WEBDAV_PORT $webdav_port $final_path/conf/seafdav.conf
|
||||||
|
|
||||||
# Add sso config to unprotect domain.tld/seafdav in /etc/ssowat/conf.json.persistent
|
# Add sso config to unprotect domain.tld/seafdav in /etc/ssowat/conf.json.persistent
|
||||||
sudo cp ../conf/add_sso_conf.py $final_path
|
cp ../conf/add_sso_conf.py $final_path
|
||||||
sudo cp ../conf/add_sso_conf_webdav.py $final_path
|
cp ../conf/add_sso_conf_webdav.py $final_path
|
||||||
sudo cp ../conf/remove_sso_conf.py $final_path
|
cp ../conf/remove_sso_conf.py $final_path
|
||||||
sudo python $final_path/add_sso_conf_webdav.py
|
python $final_path/add_sso_conf_webdav.py
|
||||||
|
|
||||||
# Update seafile config
|
# Update seafile config
|
||||||
echo 'COMPRESS_URL = MEDIA_URL' | sudo tee -a $final_path/conf/seahub_settings.py
|
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py
|
||||||
echo "STATIC_URL = MEDIA_URL + 'assets/'" | sudo tee -a $final_path/conf/seahub_settings.py
|
echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
|
||||||
|
|
||||||
# Add logrotate
|
# Add logrotate
|
||||||
sudo cp ../conf/logrotate /etc/logrotate.d/seafile
|
ynh_use_logrotate $final_path/logs/seaf-server.log
|
||||||
sudo sed -i "s@SEAFILE_DIR@$final_path@g" /etc/logrotate.d/seafile
|
ynh_use_logrotate $final_path/logs/ccnet.log
|
||||||
sudo service rsyslog restart
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update seahub config for old version to version 5.0.4
|
# Update seahub config for old version to version 5.0.4
|
||||||
if [[ $(sudo grep -c "LOGIN_URL" $final_path/conf/seahub_settings.py) == 0 ]]
|
if [[ $(grep -c "LOGIN_URL" $final_path/conf/seahub_settings.py) == 0 ]]
|
||||||
then
|
then
|
||||||
echo "LOGIN_URL = '"$path"/accounts/login/'" | sudo tee -a $final_path/conf/seahub_settings.py
|
echo "LOGIN_URL = '"$path"/accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fix local warning
|
||||||
|
ynh_replace_string en_US.UTF-8 $LANG $final_path/seafile-server-$seafile_version/seahub.sh
|
||||||
|
|
||||||
# restore correct permissions
|
# restore correct permissions
|
||||||
sudo chown -R $seafile_user:$seafile_user $final_path
|
chown -R $seafile_user:$seafile_user $final_path
|
||||||
|
|
||||||
# delete seafile cache
|
# delete seafile cache
|
||||||
sudo rm -rf /tmp/seahub_cache
|
rm -rf /tmp/seahub_cache
|
||||||
|
|
||||||
# restart seafile server
|
# restart seafile server
|
||||||
sudo service seafile-server start
|
systemctl start seafile-server.service
|
||||||
|
|
||||||
# remove old version files
|
# remove old version files
|
||||||
sudo rm -f $final_path/installed/seafile-server_${installed_version}*.tar*
|
rm -f $final_path/installed/seafile-server_${installed_version}*.tar*
|
||||||
sudo rm -f $final_path/seafile-server_${installed_version}_$architecture
|
rm -f $final_path/seafile-server_${installed_version}_$architecture
|
||||||
|
|
||||||
# store new installed version
|
# store new installed version
|
||||||
ynh_app_setting_set $app installed_version $seafile_version
|
ynh_app_setting_set $app installed_version $seafile_version
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload nginx
|
||||||
sudo service nginx reload
|
systemctl reload nginx.service
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue