mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
Fix issues on upgrade of major debian version
This commit is contained in:
parent
2d14c10c53
commit
f7a860dbbd
4 changed files with 59 additions and 75 deletions
|
@ -1 +1,50 @@
|
||||||
dependances="coturn build-essential python3-dev libffi-dev python3-pip python3-setuptools sqlite3 libssl-dev python3-venv libxml2-dev libxslt1-dev python3-lxml libjpeg-dev libpq-dev postgresql acl"
|
dependances="coturn build-essential python3-dev libffi-dev python3-pip python3-setuptools sqlite3 libssl-dev python3-venv libxml2-dev libxslt1-dev python3-lxml libjpeg-dev libpq-dev postgresql acl"
|
||||||
|
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
|
||||||
|
|
||||||
|
install_sources() {
|
||||||
|
# Install/upgrade synapse in virtualenv
|
||||||
|
|
||||||
|
# Clean venv is it was on python2.7 or python3 with old version in case major upgrade of debian
|
||||||
|
if [ ! -e $final_path/bin/python3 ] || [ ! -e $final_path/lib/python$python_version ]; then
|
||||||
|
ynh_secure_remove --file=$final_path
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $final_path
|
||||||
|
|
||||||
|
if [ -n "$(uname -m | grep arm)" ]
|
||||||
|
then
|
||||||
|
# Clean old file, sometimes it could make some big issues if we don't do this!!
|
||||||
|
ynh_secure_remove --file=$final_path/bin
|
||||||
|
ynh_secure_remove --file=$final_path/lib
|
||||||
|
ynh_secure_remove --file=$final_path/include
|
||||||
|
ynh_secure_remove --file=$final_path/share
|
||||||
|
|
||||||
|
ynh_setup_source --dest_dir=$final_path/ --source_id="armv7_$(lsb_release --codename --short)"
|
||||||
|
|
||||||
|
# Fix multi-instance support
|
||||||
|
for f in $(ls $final_path/bin); do
|
||||||
|
if ! [[ $f =~ "__" ]]; then
|
||||||
|
ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$final_path --target_file=$final_path/bin/$f
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Install virtualenv if it don't exist
|
||||||
|
test -e $final_path/bin/python3 || python3 -m venv $final_path
|
||||||
|
|
||||||
|
# Install synapse in virtualenv
|
||||||
|
ynh_replace_string --match_string=__FINAL_PATH__ --replace_string=$final_path --target_file=$final_path/bin/activate
|
||||||
|
|
||||||
|
# We set all necessary environement variable to create a python virtualenvironnement.
|
||||||
|
set +u;
|
||||||
|
source $final_path/bin/activate
|
||||||
|
set -u;
|
||||||
|
pip3 install --upgrade setuptools wheel
|
||||||
|
pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2
|
||||||
|
pip3 install --upgrade 'Twisted>=20.3.0' matrix-synapse==$upstream_version matrix-synapse-ldap3
|
||||||
|
|
||||||
|
# This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does
|
||||||
|
set +u;
|
||||||
|
deactivate
|
||||||
|
set -u;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -175,40 +175,9 @@ ynh_script_progression --message="Setting up source files..." --weight=50
|
||||||
mkdir -p /var/lib/matrix-$app
|
mkdir -p /var/lib/matrix-$app
|
||||||
mkdir -p /var/log/matrix-$app
|
mkdir -p /var/log/matrix-$app
|
||||||
mkdir -p /etc/matrix-$app/conf.d
|
mkdir -p /etc/matrix-$app/conf.d
|
||||||
mkdir -p $final_path
|
|
||||||
|
|
||||||
# Install synapse in virtualenv
|
# Install synapse in virtualenv
|
||||||
|
install_sources
|
||||||
# WARNING : theses command are used in INSTALL, UPGRADE (2 times)
|
|
||||||
# For any update do it in all files
|
|
||||||
if [ -n "$(uname -m | grep arm)" ]
|
|
||||||
then
|
|
||||||
ynh_setup_source --dest_dir=$final_path/ --source_id="armv7_$(lsb_release --codename --short)"
|
|
||||||
|
|
||||||
# Fix multi-instance support
|
|
||||||
for f in $(ls $final_path/bin); do
|
|
||||||
if ! [[ $f =~ "__" ]]; then
|
|
||||||
ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$final_path --target_file=$final_path/bin/$f
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
# Install virtualenv if it don't exist
|
|
||||||
test -e $final_path/bin/python3 || python3 -m venv $final_path
|
|
||||||
|
|
||||||
# Install synapse in virtualenv
|
|
||||||
cp ../conf/virtualenv_activate $final_path/bin/activate
|
|
||||||
ynh_replace_string --match_string=__FINAL_PATH__ --replace_string=$final_path --target_file=$final_path/bin/activate
|
|
||||||
|
|
||||||
# We set all necessary environement variable to create a python virtualenvironnement.
|
|
||||||
source $final_path/bin/activate
|
|
||||||
pip3 install --upgrade pip
|
|
||||||
pip3 install --upgrade setuptools wheel
|
|
||||||
pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2
|
|
||||||
pip3 install --upgrade matrix-synapse==$upstream_version matrix-synapse-ldap3
|
|
||||||
|
|
||||||
# This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does
|
|
||||||
deactivate
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE SMALL CAS SERVER
|
# CREATE SMALL CAS SERVER
|
||||||
|
@ -228,14 +197,17 @@ chown $synapse_user:root -R $final_www_path
|
||||||
ynh_script_progression --message="Creating synapse config..." --weight=3
|
ynh_script_progression --message="Creating synapse config..." --weight=3
|
||||||
|
|
||||||
# Go in virtualenvironnement
|
# Go in virtualenvironnement
|
||||||
PS1=${PS1:-}
|
set +u;
|
||||||
source $final_path/bin/activate
|
source $final_path/bin/activate
|
||||||
|
set -u;
|
||||||
|
|
||||||
# Generate config
|
# Generate config
|
||||||
python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $server_name --report-stats=no -c homeserver.yml
|
python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $server_name --report-stats=no -c homeserver.yml
|
||||||
|
|
||||||
# This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does
|
# This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does
|
||||||
|
set +u;
|
||||||
deactivate
|
deactivate
|
||||||
|
set -u;
|
||||||
|
|
||||||
# Get random values from config
|
# Get random values from config
|
||||||
ynh_print_OFF
|
ynh_print_OFF
|
||||||
|
|
|
@ -69,6 +69,10 @@ test ! -d $final_path \
|
||||||
ynh_script_progression --message="Restoring directory and configuration..." --weight=10
|
ynh_script_progression --message="Restoring directory and configuration..." --weight=10
|
||||||
ynh_restore
|
ynh_restore
|
||||||
|
|
||||||
|
# Check that the good python version is installed
|
||||||
|
# If not upgrade the source
|
||||||
|
install_sources
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -143,48 +143,7 @@ ynh_install_app_dependencies $dependances
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||||
|
install_sources
|
||||||
# Install/upgrade synapse in virtualenv
|
|
||||||
|
|
||||||
# Clean venv is it was on python2.7
|
|
||||||
test -e $final_path/bin/python3 || ynh_secure_remove --file=$final_path
|
|
||||||
|
|
||||||
# WARNING : these commands are used in INSTALL, UPGRADE
|
|
||||||
# For any update do it in all files
|
|
||||||
|
|
||||||
if [ -n "$(uname -m | grep arm)" ]
|
|
||||||
then
|
|
||||||
# Clean old file, sometimes it could make some big issues if we don't do this!!
|
|
||||||
ynh_secure_remove --file=$final_path/bin
|
|
||||||
ynh_secure_remove --file=$final_path/lib
|
|
||||||
ynh_secure_remove --file=$final_path/include
|
|
||||||
ynh_secure_remove --file=$final_path/share
|
|
||||||
|
|
||||||
ynh_setup_source --dest_dir=$final_path/ --source_id="armv7_$(lsb_release --codename --short)"
|
|
||||||
|
|
||||||
# Fix multi-instance support
|
|
||||||
for f in $(ls $final_path/bin); do
|
|
||||||
if ! [[ $f =~ "__" ]]; then
|
|
||||||
ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$final_path --target_file=$final_path/bin/$f
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
# Install virtualenv if it don't exist
|
|
||||||
test -e $final_path/bin/python3 || python3 -m venv $final_path
|
|
||||||
|
|
||||||
# Install synapse in virtualenv
|
|
||||||
cp ../conf/virtualenv_activate $final_path/bin/activate
|
|
||||||
ynh_replace_string --match_string=__FINAL_PATH__ --replace_string=$final_path --target_file=$final_path/bin/activate
|
|
||||||
|
|
||||||
# We set all necessary environement variable to create a python virtualenvironnement.
|
|
||||||
source $final_path/bin/activate
|
|
||||||
pip3 install --upgrade setuptools wheel
|
|
||||||
pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2
|
|
||||||
pip3 install --upgrade 'Twisted>=20.3.0' matrix-synapse==$upstream_version matrix-synapse-ldap3
|
|
||||||
|
|
||||||
# This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does
|
|
||||||
deactivate
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue