mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
Rework maintenance scripts
This commit is contained in:
parent
a3c9dbeac0
commit
f1dd82feec
5 changed files with 40 additions and 23 deletions
|
@ -161,6 +161,7 @@ set_permissions() {
|
|||
|
||||
chmod 770 $code_dir/Coturn_config_rotate.sh
|
||||
chmod 700 $code_dir/update_synapse_for_appservice.sh
|
||||
chmod 700 $code_dir/set_admin_user.sh
|
||||
|
||||
find $data_dir \( \! -perm -o= \
|
||||
-o \! -user $app \
|
||||
|
|
|
@ -254,6 +254,7 @@ ynh_use_logrotate --logfile "/var/log/matrix-$app"
|
|||
|
||||
ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$code_dir/Coturn_config_rotate.sh"
|
||||
ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destination="$code_dir/update_synapse_for_appservice.sh"
|
||||
ynh_add_config --template=../sources/set_admin_user.sh --destination=$code_dir/set_admin_user.sh
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -339,7 +339,7 @@ fi
|
|||
# MIGRATION 12 : update system user and drop yunohost user
|
||||
#=================================================
|
||||
|
||||
if grep -q matrix-$app /etc/passwd; then
|
||||
if grep -q "^matrix-$app" /etc/passwd; then
|
||||
ynh_system_user_delete --username=matrix-$app
|
||||
yunohost user delete $app || true
|
||||
ynh_system_user_create --username=$app --home_dir=$code_dir
|
||||
|
@ -440,6 +440,7 @@ configure_coturn
|
|||
|
||||
ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$code_dir/Coturn_config_rotate.sh"
|
||||
ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destination="$code_dir/update_synapse_for_appservice.sh"
|
||||
ynh_add_config --template=../sources/set_admin_user.sh --destination=$code_dir/set_admin_user.sh
|
||||
|
||||
# Ensure app-service folder has exists and the config file exit (Migration)
|
||||
mkdir -p /etc/matrix-$app/app-service
|
||||
|
|
|
@ -2,34 +2,27 @@
|
|||
|
||||
set -eu
|
||||
|
||||
app_instance=__APP__
|
||||
app=__APP__
|
||||
|
||||
pushd /etc/yunohost/apps/$app/conf
|
||||
source /usr/share/yunohost/helpers
|
||||
source ../scripts/_common.sh
|
||||
|
||||
coturn_config_path="/etc/matrix-$app_instance/coturn.conf"
|
||||
public_ip4="$(curl ip.yunohost.org)" || true
|
||||
public_ip6="$(curl ipv6.yunohost.org)" || true
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port_cli=$(ynh_app_setting_get --app=$app --key=port_cli)
|
||||
turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd)
|
||||
port_turnserver_tls=$(ynh_app_setting_get --app=$app --key=port_turnserver_tls)
|
||||
port_turnserver_alt_tls=$(ynh_app_setting_get --app=$app --key=port_turnserver_alt_tls)
|
||||
|
||||
old_config_line=$(egrep "^external-ip=.*\$" $coturn_config_path)
|
||||
perl -i -pe 's/(^external-ip=.*\n)*//g' $coturn_config_path
|
||||
previous_checksum=$(ynh_app_setting_get --app=$app --key=checksum__etc_matrix-synapse_coturn.conf)
|
||||
configure_coturn
|
||||
new_checksum=$(ynh_app_setting_get --app=$app --key=checksum__etc_matrix-synapse_coturn.conf)
|
||||
|
||||
if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4"
|
||||
setfacl -R -m user:turnserver:rX /etc/matrix-$app
|
||||
|
||||
if [ "$previous_checksum" != "$new_checksum" ]
|
||||
then
|
||||
echo "external-ip=$public_ip4" >> "$coturn_config_path"
|
||||
fi
|
||||
|
||||
if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6"
|
||||
then
|
||||
echo "external-ip=$public_ip6" >> "$coturn_config_path"
|
||||
fi
|
||||
|
||||
new_config_line=$(egrep "^external-ip=.*\$" "/etc/matrix-$app_instance/coturn.conf")
|
||||
|
||||
setfacl -R -m user:turnserver:rX /etc/matrix-$app_instance
|
||||
|
||||
if [ "$old_config_line" != "$new_config_line" ]
|
||||
then
|
||||
systemctl restart $app_instance-coturn.service
|
||||
systemctl restart $app-coturn.service
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
21
sources/set_admin_user.sh
Normal file
21
sources/set_admin_user.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=__APP__
|
||||
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
|
||||
if [ -z ${1:-} ]; then
|
||||
echo "Usage: set_admin_user.sh user_to_set_as_admin"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ynh_psql_execute_as_root --database=$db_name --sql="UPDATE users SET admin = 1 WHERE name = '@$1:$server_name'"
|
||||
|
||||
exit 0
|
Loading…
Add table
Reference in a new issue