Upgrade to 7.1 and add support for memcached

This commit is contained in:
Josué Tille 2020-04-28 13:57:07 +02:00
parent 5ca79c9d96
commit 6e2975f454
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
8 changed files with 76 additions and 44 deletions

1
conf/create_admin.json Normal file
View file

@ -0,0 +1 @@
{"email": "__ADMIN__", "password": "__PASSWORD__"}

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://download.seadrive.org/seafile-server_7.0.5_x86-64.tar.gz
SOURCE_SUM=7eb8814f1bc8ee78c80741fa08cbdce2b5ea8895a87730bde2a1b32d031e8f53
SOURCE_URL=https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_7.1.3_x86-64.tar.gz
SOURCE_SUM=41e1042984c923636e6bb7c2249bb9b784e42d796303450fe60d05855abce15f
# (Optional) Program to check the integrity (sha256sum, md5sum...)
# default: sha256
SOURCE_SUM_PRG=sha256sum

View file

@ -4,7 +4,7 @@
"packaging_format": 1,
"license": "AGPL-3.0,Apache-2.0,MIT,GPL-2.0",
"url": "https://www.seafile.com",
"version": "7.0.5~ynh1",
"version": "7.1.3~ynh1",
"description": {
"en": "Open Source Cloud Storage",
"fr": "Stockage Cloud Open Source"
@ -23,7 +23,7 @@
"mysql"
],
"requirements": {
"yunohost": ">= 3.5.2.2"
"yunohost": ">= 4.0"
},
"arguments": {
"install": [

View file

@ -20,18 +20,17 @@ install_source() {
}
install_dependance() {
if [ "$(lsb_release --codename --short)" == "stretch" ]; then
ynh_install_app_dependencies python2.7 python-pip libpython2.7 python-setuptools python-ldap python-urllib3 python-simplejson python-imaging python-mysqldb python-flup expect python-requests python-dev ffmpeg python-memcache \
libjpeg62-turbo-dev zlib1g-dev # For building pillow
else
ynh_install_app_dependencies python2.7 python-pip libpython2.7 python-setuptools python-ldap python-urllib3 python-simplejson python-pil python-mysqldb python-flup expect python-requests python-dev ffmpeg python-memcache \
libjpeg62-turbo-dev zlib1g-dev # For building pillow
fi
ynh_install_app_dependencies python3 python3-setuptools python3-pip python3-requests python3-dev \
expect ffmpeg \
memcached libmemcached-dev \
libjpeg62-turbo-dev zlib1g-dev # For building pillow
ynh_add_swap 2000
# We need to do that because we can have some issue about the permission access to the pip cache without this
set_permission
# Note that we install imageio to force the dependance, without this imageio 2.8 is installed and it need python3.5
sudo -u $seafile_user pip install --user --upgrade Pillow 'moviepy<1.0' 'imageio<2.8' certifi idna
sudo -u $seafile_user pip3 install --user --upgrade Pillow pylibmc captcha jinja2 sqlalchemy psd-tools \
django-pylibmc django-simple-captcha python3-ldap \
pylibmc django-pylibmc # Memcached support
ynh_del_swap
}

View file

@ -19,8 +19,8 @@ send "$server_name\r";
expect "What is the ip or domain of the server?"
send "$domain\r";
expect "Where do you want to put your seafile data?"
send "$seafile_data\r";
# expect "Where do you want to put your seafile data?"
# send "$seafile_data\r";
expect "Which port do you want to use for the seafile fileserver?"
send "$fileserver_port\r";

View file

@ -0,0 +1,11 @@
#!/usr/bin/expect
set timeout 5
set seafile_dir [lindex $argv 0]
spawn $seafile_dir/upgrade/upgrade_7.0_7.1.sh
expect "to contiune"
send "\r";
interact

View file

@ -71,7 +71,7 @@ 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
mkdir -p $seafile_data
# Create User
ynh_script_progression --message="Configuring system user..."
@ -81,10 +81,6 @@ ynh_system_user_create --username $seafile_user --home_dir $final_path
ynh_script_progression --message="Installing dependencies..." --weight=7
install_dependance
# Clean data directory
ynh_script_progression --message="Cleaning data directory..."
test -e $seafile_data && ynh_secure_remove --file="$seafile_data"
# Download new version from sources
ynh_script_progression --message="Installing sources files..." --weight=7
install_source
@ -102,6 +98,7 @@ ynh_script_progression --message="Configuring application..." --weight=3
chmod +x expect_scripts/install.exp
chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
expect_scripts/install.exp "$final_path/seafile-server-$seafile_version" "$server_name" "$domain" "$seafile_data" "$fileserver_port" "$db_pwd"
echo $seafile_data > $final_path/ccnet/seafile.ini
# Update seafile config
ynh_replace_string --match_string http:// --replace_string https:// --target_file $final_path/conf/ccnet.conf
@ -140,11 +137,28 @@ echo 'LOGIN_ATTR = mail' | tee -a $final_path/conf/ccnet.conf
# Enable manually wiki
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
# Enable memcached
cat >> $final_path/conf/seahub_settings.py <<EOF
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}
EOF
# Configure admin info
# It will be used the first start
admin_email=$(ynh_user_get_info --username $admin --key 'mail')
cp ../conf/create_admin.json $final_path/conf/admin.txt
ynh_replace_string --match_string __ADMIN__ --replace_string $admin_email --target_file $final_path/conf/admin.txt
ynh_replace_special_string --match_string __PASSWORD__ --replace_string $admin_password --target_file $final_path/conf/admin.txt
# Fix local warning
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 = \"127\.0\.0\.1:[[:digit:]]+\"@bind = \"127.0.0.1:$seahub_port\"@g" $final_path/conf/gunicorn.conf
sed --in-place -r "s@bind = \"127\.0\.0\.1:[[:digit:]]+\"@bind = \"127.0.0.1:$seahub_port\"@g" $final_path/conf/gunicorn.conf.py
# Add webdav
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
@ -164,22 +178,13 @@ cp expect_scripts/first_launch.exp $final_path
chmod +x $final_path/first_launch.exp
# Set permissions to seafile directory
chown -R $seafile_user:$seafile_user $final_path
chown -R $seafile_user:$seafile_user $seafile_data
set_permission
# Sometime we have a current effect. We try to lunch seafile when not all permissions are already set.
# So wait untils all permissions are cleanly set
sleep 5
ynh_debug_exec ls /opt/yunohost/seafile/ccnet
# 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 --match_string __ADMIN_PASSWORD__ --replace_string "$admin_password" --target_file $final_path/first_launch.exp
admin_email=$(ynh_user_get_info --username $admin --key 'mail')
su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email"
ynh_secure_remove --file="$final_path/first_launch.exp"
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -208,29 +213,20 @@ ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile $final_path/logs
ln -s $final_path/logs /var/log/seafile
# Add fail2ban
ynh_script_progression --message="Configuring fail2ban..." --weight=10
ynh_add_fail2ban_config --use_template --others_var 'final_path'
# register yunohost service
yunohost service add seafile
yunohost service add seahub
ynh_script_progression --message="Stoping services..." --weight=3
# Kill all services launched for initialisation
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seafile.sh stop"
su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seahub.sh stop"
sleep 2
# We kill all process lunched by the script
pkill -f seafile-controller || true
pkill -f seaf-server || true
# Start service
ynh_script_progression --message="Starting seafile services..." --weight=3
ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd"
sleep 2
# Add fail2ban
ynh_script_progression --message="Configuring fail2ban..." --weight=10
ynh_add_fail2ban_config --use_template --others_var 'final_path'
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -158,6 +158,31 @@ case $installed_version in
ynh_print_warn --message "To be able to continue to use the SSO you probybly need to migrate your account. You can use the command 'yunohost app action run seafile migrate_user_email_to_mail_email' to migrate all of theses account. Note that after this migratation you need to reconfigure all your client with the official email of the user."
;&
"7.0"* )
# Fix file comment
$final_path/seafile-server-$seafile_version/seahub.sh python-env seahub/manage.py migrate_file_comment
# TODO
# Check that last version >= 7.0. If not install and upgrade to 7.0 before !!
# Enable memcached
cat > $final_path/conf/seahub_settings.py <<EOF
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}
EOF
# Update seafile by script
expect_scripts/upgrade_7.1.exp $final_path/seafile-server-$seafile_version
;&
esac
expect_scripts/minor-upgrade.exp $final_path/seafile-server-$seafile_version
@ -202,7 +227,7 @@ fi
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
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf.py
# 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