1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00

Improve install - remove from issue #31

This commit is contained in:
Josué Tille 2018-02-03 11:32:59 +01:00
parent e145ef1e42
commit acca68333c
5 changed files with 109 additions and 80 deletions

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
src_sum="234dd5fa44895e855d11fbf50de9184d057977b10b296f594d2c3758f693eff3"

View file

@ -49,6 +49,10 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
# For the domain and the path we can't use the standard keys "domain" and "path" with the standard function ynh_webpath_register because it create automatically a button on the user pannel.
# The idea is to create a custom key (specia_domain and special_path instead of domain and key).
# By this the ssowatconf fonction don't create a button on the pannel.
# This hack solve the issue : https://github.com/YunoHost-Apps/synapse_ynh/issues/14
ynh_app_setting_set $app special_domain $domain ynh_app_setting_set $app special_domain $domain
ynh_app_setting_set $app special_path $path_url ynh_app_setting_set $app special_path $path_url
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
@ -148,17 +152,23 @@ else
PS1="" PS1=""
cp ../conf/virtualenv_activate $final_path/bin/activate cp ../conf/virtualenv_activate $final_path/bin/activate
ynh_replace_string __FINAL_PATH__ $final_path $final_path/bin/activate ynh_replace_string __FINAL_PATH__ $final_path $final_path/bin/activate
# We set all necessary environement variable to create a python virtualenvironnement.
source $final_path/bin/activate source $final_path/bin/activate
pip install --upgrade pip pip install --upgrade pip
pip install --upgrade setuptools pip install --upgrade setuptools
pip install --upgrade cffi ndg-httpsclient psycopg2 lxml pip install --upgrade cffi ndg-httpsclient psycopg2 lxml
pip install --upgrade https://github.com/matrix-org/synapse/archive/v$upstream_version.tar.gz wget -nv -O synapse_source.tar.gz https://github.com/matrix-org/synapse/archive/v$upstream_version.tar.gz
echo "${src_sum} synapse_source.tar.gz" | sha256sum -c --status \
|| ynh_die "Corrupt source"
pip install --upgrade synapse_source.tar.gz
# Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29 # Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29
test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\ test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\
pip uninstall -y msgpack-python msgpack; \ pip uninstall -y msgpack-python msgpack; \
pip install msgpack-python) pip install msgpack-python)
# This fonction was defined while we call "source $final_path/bin/activate". By this fonction de undo what does "$final_path/bin/activate"
deactivate deactivate
fi fi
@ -191,30 +201,31 @@ ynh_app_setting_set $app turnserver_pwd $turnserver_pwd
# WARRNING : theses command are used in INSTALL, UPGRADE (2 times) # WARRNING : theses command are used in INSTALL, UPGRADE (2 times)
# For any update do it in all files # For any update do it in all files
ynh_backup_if_checksum_is_different /etc/matrix-$app/homeserver.yaml
ynh_backup_if_checksum_is_different /etc/matrix-$app/log.yaml homeserver_config_path="/etc/matrix-$app/homeserver.yaml"
cp ../conf/homeserver.yaml /etc/matrix-$app/homeserver.yaml
cp ../conf/homeserver.yaml "$homeserver_config_path"
cp ../conf/log.yaml /etc/matrix-$app/log.yaml cp ../conf/log.yaml /etc/matrix-$app/log.yaml
ynh_replace_string __APP__ $app /etc/matrix-$app/homeserver.yaml ynh_replace_string __APP__ $app "$homeserver_config_path"
ynh_replace_string __DOMAIN__ $domain /etc/matrix-$app/homeserver.yaml ynh_replace_string __DOMAIN__ $domain "$homeserver_config_path"
ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user /etc/matrix-$app/homeserver.yaml ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user "$homeserver_config_path"
ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd /etc/matrix-$app/homeserver.yaml ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd "$homeserver_config_path"
ynh_replace_string __PORT__ $port /etc/matrix-$app/homeserver.yaml ynh_replace_string __PORT__ $port "$homeserver_config_path"
ynh_replace_string __TLS_PORT__ $synapse_tls_port /etc/matrix-$app/homeserver.yaml ynh_replace_string __TLS_PORT__ $synapse_tls_port "$homeserver_config_path"
ynh_replace_string __TURNSERVER_TLS_PORT__ $turnserver_tls_port /etc/matrix-$app/homeserver.yaml ynh_replace_string __TURNSERVER_TLS_PORT__ $turnserver_tls_port "$homeserver_config_path"
ynh_replace_string __TURNPWD__ $turnserver_pwd /etc/matrix-$app/homeserver.yaml ynh_replace_string __TURNPWD__ $turnserver_pwd "$homeserver_config_path"
ynh_replace_string __APP__ $app /etc/matrix-$app/log.yaml ynh_replace_string __APP__ $app "$homeserver_config_path"
if [ "$is_public" = "0" ] if [ "$is_public" = "0" ]
then then
ynh_replace_string __ALLOWED_ACCESS__ False /etc/matrix-$app/homeserver.yaml ynh_replace_string __ALLOWED_ACCESS__ False "$homeserver_config_path"
else else
ynh_replace_string __ALLOWED_ACCESS__ True /etc/matrix-$app/homeserver.yaml ynh_replace_string __ALLOWED_ACCESS__ True "$homeserver_config_path"
fi fi
ynh_store_file_checksum /etc/matrix-$app/homeserver.yaml ynh_store_file_checksum "$homeserver_config_path"
ynh_store_file_checksum /etc/matrix-$app/log.yaml ynh_store_file_checksum /etc/matrix-$app/log.yaml
#================================================= #=================================================
@ -223,17 +234,19 @@ ynh_store_file_checksum /etc/matrix-$app/log.yaml
# WARRNING : theses command are used in INSTALL, UPGRADE # WARRNING : theses command are used in INSTALL, UPGRADE
# For any update do it in all files # For any update do it in all files
ynh_backup_if_checksum_is_different /etc/matrix-$app/coturn.conf
cp ../conf/turnserver.conf /etc/matrix-$app/coturn.conf
ynh_replace_string __APP__ $app /etc/matrix-$app/coturn.conf coturn_config_path="/etc/matrix-$app/coturn.conf"
ynh_replace_string __TURNPWD__ $turnserver_pwd /etc/matrix-$app/coturn.conf
ynh_replace_string __DOMAIN__ $domain /etc/matrix-$app/coturn.conf
ynh_replace_string __TLS_PORT__ $turnserver_tls_port /etc/matrix-$app/coturn.conf
ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port /etc/matrix-$app/coturn.conf
ynh_replace_string __CLI_PORT__ $cli_port /etc/matrix-$app/coturn.conf
ynh_store_file_checksum /etc/matrix-$app/coturn.conf cp ../conf/turnserver.conf "$coturn_config_path"
ynh_replace_string __APP__ $app "$coturn_config_path"
ynh_replace_string __TURNPWD__ $turnserver_pwd "$coturn_config_path"
ynh_replace_string __DOMAIN__ $domain "$coturn_config_path"
ynh_replace_string __TLS_PORT__ $turnserver_tls_port "$coturn_config_path"
ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port "$coturn_config_path"
ynh_replace_string __CLI_PORT__ $cli_port "$coturn_config_path"
ynh_store_file_checksum "$coturn_config_path"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -248,6 +261,7 @@ ynh_use_logrotate /var/log/matrix-$app
#================================================= #=================================================
# Open access to server without a button the home # Open access to server without a button the home
# The script "add_sso_conf.py" will just add en entry for the path "/_matrix" in the sso conf.json.persistent file in the cathegory "skipped_urls".
cp ../conf/add_sso_conf.py $final_path cp ../conf/add_sso_conf.py $final_path
cp ../conf/remove_sso_conf.py $final_path cp ../conf/remove_sso_conf.py $final_path
python $final_path/add_sso_conf.py python $final_path/add_sso_conf.py
@ -271,7 +285,8 @@ setfacl -R -m user:turnserver:rwX /var/log/matrix-$app
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add matrix-$app yunohost service add matrix-$app -l "/var/log/matrix-$app/homeserver.log"
yunohost service add coturn-$app
#================================================= #=================================================
# RELOAD SERVICES # RELOAD SERVICES

View file

@ -8,9 +8,6 @@
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Don't execute the command witch don't have all variable set
set -u
# Import common cmd # Import common cmd
source ./psql.sh source ./psql.sh
source ./experimental_helper.sh source ./experimental_helper.sh
@ -42,8 +39,8 @@ turnserver_alt_tls_port=$(ynh_app_setting_get $app turnserver_alt_tls_port)
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_remove_systemd_config matrix-$YNH_APP_INSTANCE_NAME ynh_remove_systemd_config matrix-$app
ynh_remove_systemd_config coturn-$YNH_APP_INSTANCE_NAME ynh_remove_systemd_config coturn-$app
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
@ -75,18 +72,18 @@ python $final_path/remove_sso_conf.py
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_remove_app_dependencies || true ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP DIR # REMOVE APP DIR
#================================================= #=================================================
ynh_secure_remove $final_path ynh_secure_remove $final_path
ynh_secure_remove /var/lib/matrix-$YNH_APP_INSTANCE_NAME ynh_secure_remove /var/lib/matrix-$app
ynh_secure_remove /var/log/matrix-$YNH_APP_INSTANCE_NAME ynh_secure_remove /var/log/matrix-$app
ynh_secure_remove /etc/matrix-$YNH_APP_INSTANCE_NAME ynh_secure_remove /etc/matrix-$app
ynh_secure_remove /etc/default/matrix-$YNH_APP_INSTANCE_NAME ynh_secure_remove /etc/default/matrix-$app
ynh_secure_remove /etc/default/coturn-$YNH_APP_INSTANCE_NAME ynh_secure_remove /etc/default/coturn-$app
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -104,7 +101,7 @@ ynh_psql_remove_db $synapse_db_name $synapse_db_user
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_system_user_delete matrix-$YNH_APP_INSTANCE_NAME ynh_system_user_delete $synapse_user
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
@ -116,4 +113,5 @@ ynh_remove_logrotate
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE FROM ADMIN PANEL
#================================================= #=================================================
yunohost service remove matrix-$YNH_APP_INSTANCE_NAME yunohost service remove matrix-$app
yunohost service remove coturn-$app

View file

@ -90,6 +90,7 @@ yunohost firewall allow --no-upnp Both $turnserver_alt_tls_port > /dev/null 2>&1
#================================================= #=================================================
# Open access to server without a button the home # Open access to server without a button the home
# The script "add_sso_conf.py" will just add en entry for the path "/_matrix" in the sso conf.json.persistent file in the cathegory "skipped_urls".
python $final_path/add_sso_conf.py python $final_path/add_sso_conf.py
#================================================= #=================================================
@ -141,7 +142,8 @@ setfacl -R -m user:turnserver:rwX /var/log/matrix-$app
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add matrix-$app yunohost service add matrix-$app -l "/var/log/matrix-$app/homeserver.log"
yunohost service add coturn-$app
#================================================= #=================================================
# RELOAD NGINX, SYNAPSE AND COTURN # RELOAD NGINX, SYNAPSE AND COTURN

View file

@ -243,30 +243,31 @@ then
# WARRNING : theses command are used in INSTALL, UPGRADE (2 times) # WARRNING : theses command are used in INSTALL, UPGRADE (2 times)
# For any update do it in all files # For any update do it in all files
ynh_backup_if_checksum_is_different /etc/matrix-$app/homeserver.yaml
ynh_backup_if_checksum_is_different /etc/matrix-$app/log.yaml homeserver_config_path="/etc/matrix-$app/homeserver.yaml"
cp ../conf/homeserver.yaml /etc/matrix-$app/homeserver.yaml
cp ../conf/homeserver.yaml "$homeserver_config_path"
cp ../conf/log.yaml /etc/matrix-$app/log.yaml cp ../conf/log.yaml /etc/matrix-$app/log.yaml
ynh_replace_string __APP__ $app /etc/matrix-$app/homeserver.yaml ynh_replace_string __APP__ $app "$homeserver_config_path"
ynh_replace_string __DOMAIN__ $domain /etc/matrix-$app/homeserver.yaml ynh_replace_string __DOMAIN__ $domain "$homeserver_config_path"
ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user /etc/matrix-$app/homeserver.yaml ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user "$homeserver_config_path"
ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd /etc/matrix-$app/homeserver.yaml ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd "$homeserver_config_path"
ynh_replace_string __PORT__ $port /etc/matrix-$app/homeserver.yaml ynh_replace_string __PORT__ $port "$homeserver_config_path"
ynh_replace_string __TLS_PORT__ $synapse_tls_port /etc/matrix-$app/homeserver.yaml ynh_replace_string __TLS_PORT__ $synapse_tls_port "$homeserver_config_path"
ynh_replace_string __TURNSERVER_TLS_PORT__ $turnserver_tls_port /etc/matrix-$app/homeserver.yaml ynh_replace_string __TURNSERVER_TLS_PORT__ $turnserver_tls_port "$homeserver_config_path"
ynh_replace_string __TURNPWD__ $turnserver_pwd /etc/matrix-$app/homeserver.yaml ynh_replace_string __TURNPWD__ $turnserver_pwd "$homeserver_config_path"
ynh_replace_string __APP__ $app /etc/matrix-$app/log.yaml ynh_replace_string __APP__ $app "$homeserver_config_path"
if [ "$is_public" = "0" ] if [ "$is_public" = "0" ]
then then
ynh_replace_string __ALLOWED_ACCESS__ False /etc/matrix-$app/homeserver.yaml ynh_replace_string __ALLOWED_ACCESS__ False "$homeserver_config_path"
else else
ynh_replace_string __ALLOWED_ACCESS__ True /etc/matrix-$app/homeserver.yaml ynh_replace_string __ALLOWED_ACCESS__ True "$homeserver_config_path"
fi fi
ynh_store_file_checksum /etc/matrix-$app/homeserver.yaml ynh_store_file_checksum "$homeserver_config_path"
ynh_store_file_checksum /etc/matrix-$app/log.yaml ynh_store_file_checksum /etc/matrix-$app/log.yaml
#================================================= #=================================================
@ -359,17 +360,23 @@ else
PS1="" PS1=""
cp ../conf/virtualenv_activate $final_path/bin/activate cp ../conf/virtualenv_activate $final_path/bin/activate
ynh_replace_string __FINAL_PATH__ $final_path $final_path/bin/activate ynh_replace_string __FINAL_PATH__ $final_path $final_path/bin/activate
# We set all necessary environement variable to create a python virtualenvironnement.
source $final_path/bin/activate source $final_path/bin/activate
pip install --upgrade pip pip install --upgrade pip
pip install --upgrade setuptools pip install --upgrade setuptools
pip install --upgrade cffi ndg-httpsclient psycopg2 lxml pip install --upgrade cffi ndg-httpsclient psycopg2 lxml
pip install --upgrade https://github.com/matrix-org/synapse/archive/v$upstream_version.tar.gz wget -nv -O synapse_source.tar.gz https://github.com/matrix-org/synapse/archive/v$upstream_version.tar.gz
echo "${src_sum} synapse_source.tar.gz" | sha256sum -c --status \
|| ynh_die "Corrupt source"
pip install --upgrade synapse_source.tar.gz
# Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29 # Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29
test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\ test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\
pip uninstall -y msgpack-python msgpack; \ pip uninstall -y msgpack-python msgpack; \
pip install msgpack-python) pip install msgpack-python)
# This fonction was defined while we call "source $final_path/bin/activate". By this fonction de undo what does "$final_path/bin/activate"
deactivate deactivate
fi fi
@ -385,30 +392,33 @@ ynh_add_nginx_config
# WARRNING : theses command are used in INSTALL, UPGRADE (2 times) # WARRNING : theses command are used in INSTALL, UPGRADE (2 times)
# For any update do it in all files # For any update do it in all files
ynh_backup_if_checksum_is_different /etc/matrix-$app/homeserver.yaml homeserver_config_path="/etc/matrix-$app/homeserver.yaml"
ynh_backup_if_checksum_is_different "$homeserver_config_path"
ynh_backup_if_checksum_is_different /etc/matrix-$app/log.yaml ynh_backup_if_checksum_is_different /etc/matrix-$app/log.yaml
cp ../conf/homeserver.yaml /etc/matrix-$app/homeserver.yaml
cp ../conf/homeserver.yaml "$homeserver_config_path"
cp ../conf/log.yaml /etc/matrix-$app/log.yaml cp ../conf/log.yaml /etc/matrix-$app/log.yaml
ynh_replace_string __APP__ $app /etc/matrix-$app/homeserver.yaml ynh_replace_string __APP__ $app "$homeserver_config_path"
ynh_replace_string __DOMAIN__ $domain /etc/matrix-$app/homeserver.yaml ynh_replace_string __DOMAIN__ $domain "$homeserver_config_path"
ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user /etc/matrix-$app/homeserver.yaml ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user "$homeserver_config_path"
ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd /etc/matrix-$app/homeserver.yaml ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd "$homeserver_config_path"
ynh_replace_string __PORT__ $port /etc/matrix-$app/homeserver.yaml ynh_replace_string __PORT__ $port "$homeserver_config_path"
ynh_replace_string __TLS_PORT__ $synapse_tls_port /etc/matrix-$app/homeserver.yaml ynh_replace_string __TLS_PORT__ $synapse_tls_port "$homeserver_config_path"
ynh_replace_string __TURNSERVER_TLS_PORT__ $turnserver_tls_port /etc/matrix-$app/homeserver.yaml ynh_replace_string __TURNSERVER_TLS_PORT__ $turnserver_tls_port "$homeserver_config_path"
ynh_replace_string __TURNPWD__ $turnserver_pwd /etc/matrix-$app/homeserver.yaml ynh_replace_string __TURNPWD__ $turnserver_pwd "$homeserver_config_path"
ynh_replace_string __APP__ $app /etc/matrix-$app/log.yaml ynh_replace_string __APP__ $app "$homeserver_config_path"
if [ "$is_public" = "0" ] if [ "$is_public" = "0" ]
then then
ynh_replace_string __ALLOWED_ACCESS__ False /etc/matrix-$app/homeserver.yaml ynh_replace_string __ALLOWED_ACCESS__ False "$homeserver_config_path"
else else
ynh_replace_string __ALLOWED_ACCESS__ True /etc/matrix-$app/homeserver.yaml ynh_replace_string __ALLOWED_ACCESS__ True "$homeserver_config_path"
fi fi
ynh_store_file_checksum /etc/matrix-$app/homeserver.yaml ynh_store_file_checksum "$homeserver_config_path"
ynh_store_file_checksum /etc/matrix-$app/log.yaml ynh_store_file_checksum /etc/matrix-$app/log.yaml
#================================================= #=================================================
@ -417,17 +427,21 @@ ynh_store_file_checksum /etc/matrix-$app/log.yaml
# WARRNING : theses command are used in INSTALL, UPGRADE # WARRNING : theses command are used in INSTALL, UPGRADE
# For any update do it in all files # For any update do it in all files
ynh_backup_if_checksum_is_different /etc/matrix-$app/coturn.conf
cp ../conf/turnserver.conf /etc/matrix-$app/coturn.conf
ynh_replace_string __APP__ $app /etc/matrix-$app/coturn.conf coturn_config_path="/etc/matrix-$app/coturn.conf"
ynh_replace_string __TURNPWD__ $turnserver_pwd /etc/matrix-$app/coturn.conf
ynh_replace_string __DOMAIN__ $domain /etc/matrix-$app/coturn.conf
ynh_replace_string __TLS_PORT__ $turnserver_tls_port /etc/matrix-$app/coturn.conf
ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port /etc/matrix-$app/coturn.conf
ynh_replace_string __CLI_PORT__ $cli_port /etc/matrix-$app/coturn.conf
ynh_store_file_checksum /etc/matrix-$app/coturn.conf ynh_backup_if_checksum_is_different "$coturn_config_path"
cp ../conf/turnserver.conf "$coturn_config_path"
ynh_replace_string __APP__ $app "$coturn_config_path"
ynh_replace_string __TURNPWD__ $turnserver_pwd "$coturn_config_path"
ynh_replace_string __DOMAIN__ $domain "$coturn_config_path"
ynh_replace_string __TLS_PORT__ $turnserver_tls_port "$coturn_config_path"
ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port "$coturn_config_path"
ynh_replace_string __CLI_PORT__ $cli_port "$coturn_config_path"
ynh_store_file_checksum "$coturn_config_path"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION