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

Fix shell check

This commit is contained in:
Josué Tille 2024-04-27 01:21:40 +02:00
parent abe4a95b00
commit e0f63659f9
No known key found for this signature in database
GPG key ID: 5F259226AD51F2F5
5 changed files with 62 additions and 60 deletions

View file

@ -6,51 +6,51 @@ install_sources() {
# Install/upgrade synapse in virtualenv # Install/upgrade synapse in virtualenv
# Clean venv is it was on python2.7 or python3 with old version in case major upgrade of debian # Clean venv is it was on python2.7 or python3 with old version in case major upgrade of debian
if [ ! -e $code_dir/bin/python3 ] || [ ! -e $code_dir/lib/python$python_version ]; then if [ ! -e "$code_dir"/bin/python3 ] || [ ! -e "$code_dir/lib/python$python_version" ]; then
ynh_secure_remove --file=$code_dir/bin ynh_secure_remove --file="$code_dir"/bin
ynh_secure_remove --file=$code_dir/lib ynh_secure_remove --file="$code_dir"/lib
ynh_secure_remove --file=$code_dir/lib64 ynh_secure_remove --file="$code_dir"/lib64
ynh_secure_remove --file=$code_dir/include ynh_secure_remove --file="$code_dir"/include
ynh_secure_remove --file=$code_dir/share ynh_secure_remove --file="$code_dir"/share
ynh_secure_remove --file=$code_dir/pyvenv.cfg ynh_secure_remove --file="$code_dir"/pyvenv.cfg
fi fi
mkdir -p $code_dir mkdir -p "$code_dir"
chown $app:root -R $code_dir chown "$app":root -R "$code_dir"
if [ -n "$(uname -m | grep arm)" ] if [ -n "$(uname -m | grep arm)" ]
then then
# Clean old file, sometimes it could make some big issues if we don't do this!! # Clean old file, sometimes it could make some big issues if we don't do this!!
ynh_secure_remove --file=$code_dir/bin ynh_secure_remove --file="$code_dir"/bin
ynh_secure_remove --file=$code_dir/lib ynh_secure_remove --file="$code_dir"/lib
ynh_secure_remove --file=$code_dir/include ynh_secure_remove --file="$code_dir"/include
ynh_secure_remove --file=$code_dir/share ynh_secure_remove --file="$code_dir"/share
ynh_setup_source --dest_dir=$code_dir/ --source_id="synapse_prebuilt_armv7_$(lsb_release --codename --short)" ynh_setup_source --dest_dir="$code_dir"/ --source_id="synapse_prebuilt_armv7_$(lsb_release --codename --short)"
# Fix multi-instance support # Fix multi-instance support
for f in $(ls $code_dir/bin); do for f in $(ls "$code_dir"/bin); do
if ! [[ $f =~ "__" ]]; then if ! [[ $f =~ "__" ]]; then
ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$code_dir --target_file=$code_dir/bin/$f ynh_replace_special_string --match_string='#!/opt/yunohost/matrix-synapse' --replace_string='#!'$code_dir --target_file="$code_dir"/bin/"$f"
fi fi
done done
else else
# Install virtualenv if it don't exist # Install virtualenv if it don't exist
test -e $code_dir/bin/python3 || python3 -m venv $code_dir test -e "$code_dir"/bin/python3 || python3 -m venv "$code_dir"
# Install synapse in virtualenv # Install synapse in virtualenv
local pip3=$code_dir/bin/pip3 local pip3="$code_dir"/bin/pip3
$pip3 install --upgrade setuptools wheel pip cffi $pip3 install --upgrade setuptools wheel pip cffi
$pip3 install --upgrade -r $YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt $pip3 install --upgrade -r "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt"
fi fi
# Apply patch for LDAP auth if needed # Apply patch for LDAP auth if needed
# Note that we put patch into scripts dir because /source are not stored and can't be used on restore # Note that we put patch into scripts dir because /source are not stored and can't be used on restore
if ! grep -F -q '# LDAP Filter anonymous user Applied' $code_dir/lib/python$python_version/site-packages/ldap_auth_provider.py; then if ! grep -F -q '# LDAP Filter anonymous user Applied' "$code_dir/lib/python$python_version/site-packages/ldap_auth_provider.py"; then
pushd $code_dir/lib/python$python_version/site-packages pushd "$code_dir/lib/python$python_version/site-packages"
patch < $YNH_APP_BASEDIR/scripts/patch/ldap_auth_filter_anonymous_user.patch patch < "$YNH_APP_BASEDIR"/scripts/patch/ldap_auth_filter_anonymous_user.patch
popd popd
fi fi
} }
@ -58,8 +58,10 @@ install_sources() {
configure_coturn() { configure_coturn() {
# Get public IP and set as external IP for coturn # Get public IP and set as external IP for coturn
# note : '|| true' is used to ignore the errors if we can't get the public ipv4 or ipv6 # note : '|| true' is used to ignore the errors if we can't get the public ipv4 or ipv6
local public_ip4="$(curl -s ip.yunohost.org)" || true local public_ip4
local public_ip6="$(curl -s ipv6.yunohost.org)" || true local public_ip6
public_ip4="$(curl -s ip.yunohost.org)" || true
public_ip6="$(curl -s ipv6.yunohost.org)" || true
local turn_external_ip="" local turn_external_ip=""
if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4"
@ -80,7 +82,7 @@ configure_nginx() {
if yunohost --output-as plain domain list | grep -q "^$server_name$" if yunohost --output-as plain domain list | grep -q "^$server_name$"
then then
local e2e_enabled_by_default_client_config local e2e_enabled_by_default_client_config
if [ $e2e_enabled_by_default == "off" ]; then if [ "$e2e_enabled_by_default" == "off" ]; then
e2e_enabled_by_default_client_config=false e2e_enabled_by_default_client_config=false
else else
e2e_enabled_by_default_client_config=true e2e_enabled_by_default_client_config=true

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
if systemctl is-active $app.service --quiet; then if systemctl is-active "$app".service --quiet; then
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'" ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'"
fi fi

View file

@ -10,7 +10,7 @@ source ./_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# We stop the service # We stop the service
ynh_systemd_action --service_name=$app.service --action=stop ynh_systemd_action --service_name="$app".service --action=stop
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -43,8 +43,8 @@ set_permissions
#================================================= #=================================================
ynh_script_progression --message="Restarting Synapse services..." --weight=5 ynh_script_progression --message="Restarting Synapse services..." --weight=5
ynh_systemd_action --service_name=$app-coturn.service --action=restart ynh_systemd_action --service_name="$app"-coturn.service --action=restart
ynh_systemd_action --service_name=$app.service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 ynh_systemd_action --service_name="$app".service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300
if ! yunohost --output-as plain domain list | grep -q "^$server_name"'$'; then if ! yunohost --output-as plain domain list | grep -q "^$server_name"'$'; then
ynh_print_warn "Note yunohost won't be able to manage the required config for $server_name. So please add the needed DNS config as described on the documentation" ynh_print_warn "Note yunohost won't be able to manage the required config for $server_name. So please add the needed DNS config as described on the documentation"

View file

@ -37,4 +37,4 @@ ynh_app_config_apply() {
#================================================= #=================================================
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT # SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
#================================================= #=================================================
ynh_app_config_run $1 ynh_app_config_run "$1"

View file

@ -13,8 +13,8 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
if [ "$server_name" == "Same than the domain" ]; then if [ "$server_name" == "Same than the domain" ]; then
server_name=$domain server_name="$domain"
ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app="$app" --key=server_name --value="$server_name"
fi fi
#================================================= #=================================================
@ -43,10 +43,10 @@ ynh_app_setting_set --app="$app" --key=enable_registration --value="$enable_regi
# Check datadir empty # Check datadir empty
#================================================= #=================================================
if [ -n "$(ls -A $data_dir)" ]; then if [ -n "$(ls -A "$data_dir")" ]; then
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')" old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path" ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path"
mkdir -p $old_data_dir_path mkdir -p "$old_data_dir_path"
mv -t "$old_data_dir_path" "$data_dir"/* mv -t "$old_data_dir_path" "$data_dir"/*
fi fi
@ -71,7 +71,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message='Configuring system groups' ynh_script_progression --message='Configuring system groups'
adduser $app ssl-cert adduser "$app" ssl-cert
adduser turnserver ssl-cert adduser turnserver ssl-cert
#================================================= #=================================================
@ -91,10 +91,10 @@ ynh_script_progression --message="Setting up source files..." --weight=50
# WARNING : theses command are used in INSTALL, UPGRADE # WARNING : theses command are used in INSTALL, UPGRADE
# For any update do it in all files # For any update do it in all files
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 /etc/matrix-$app/app-service mkdir -p /etc/matrix-"$app"/app-service
touch /etc/matrix-$app/conf.d/app_service.yaml touch /etc/matrix-"$app"/conf.d/app_service.yaml
# Install synapse in virtualenv # Install synapse in virtualenv
install_sources install_sources
@ -105,9 +105,9 @@ install_sources
# WARNING : theses command are used in INSTALL, UPGRADE # WARNING : theses command are used in INSTALL, UPGRADE
# For any update do it in all files # For any update do it in all files
cp ../sources/cas_server.php $install_dir/ cp ../sources/cas_server.php "$install_dir"/
chmod u=rwX,g=rX,o= -R $install_dir chmod u=rwX,g=rX,o= -R "$install_dir"
chown $app:$app -R $install_dir chown "$app:$app" -R "$install_dir"
#================================================= #=================================================
# CREATE SYNAPSE CONFIG # CREATE SYNAPSE CONFIG
@ -116,17 +116,17 @@ chown $app:$app -R $install_dir
ynh_script_progression --message="Creating Synapse config..." --weight=3 ynh_script_progression --message="Creating Synapse config..." --weight=3
# Generate config # Generate config
$code_dir/bin/python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --server-name $server_name --report-stats=no -c homeserver.yml $code_dir/bin/python -m synapse.app.homeserver --keys-directory /etc/matrix-"$app"/ --generate-config --server-name "$server_name" --report-stats=no -c homeserver.yml
# Get random values from config # Get random values from config
registration_shared_secret=$(egrep "^registration_shared_secret:" homeserver.yml | cut -d'"' -f2) registration_shared_secret="$(grep -E "^registration_shared_secret:" homeserver.yml | cut -d'"' -f2)"
form_secret=$(egrep "^form_secret:" homeserver.yml | cut -d'"' -f2) form_secret="$(grep -E "^form_secret:" homeserver.yml | cut -d'"' -f2)"
macaroon_secret_key=$(egrep "^macaroon_secret_key:" homeserver.yml | cut -d'"' -f2) macaroon_secret_key="$(grep -E "^macaroon_secret_key:" homeserver.yml | cut -d'"' -f2)"
# store in yunohost settings # store in yunohost settings
ynh_app_setting_set --app=$app --key=registration_shared_secret --value="$registration_shared_secret" ynh_app_setting_set --app="$app" --key=registration_shared_secret --value="$registration_shared_secret"
ynh_app_setting_set --app=$app --key=form_secret --value="$form_secret" ynh_app_setting_set --app="$app" --key=form_secret --value="$form_secret"
ynh_app_setting_set --app=$app --key=macaroon_secret_key --value="$macaroon_secret_key" ynh_app_setting_set --app="$app" --key=macaroon_secret_key --value="$macaroon_secret_key"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -134,10 +134,10 @@ ynh_app_setting_set --app=$app --key=macaroon_secret_key --value="$macaroon_secr
ynh_script_progression --message="Configuring a systemd service..." --weight=2 ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create systemd service for synapse and turnserver # Create systemd service for synapse and turnserver
ynh_add_systemd_config --service=$app --template=synapse.service ynh_add_systemd_config --service="$app" --template=synapse.service
cp ../conf/default_coturn /etc/matrix-$app/coturn_env cp ../conf/default_coturn /etc/matrix-"$app"/coturn_env
ynh_add_systemd_config --service=$app-coturn --template=synapse-coturn.service ynh_add_systemd_config --service="$app"-coturn --template=synapse-coturn.service
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -182,7 +182,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/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/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 ynh_add_config --template=../sources/set_admin_user.sh --destination="$code_dir"/set_admin_user.sh
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -193,7 +193,7 @@ ynh_add_config --template=../sources/set_admin_user.sh --destination=$code_dir/s
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
if yunohost --output-as plain domain list | grep -q "^$server_name$"; then if yunohost --output-as plain domain list | grep -q "^$server_name$"; then
ynh_""permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ ynh_""permission_create --permission=server_client_infos --url="$server_name"/.well-known/matrix \
--label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \ --label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \
--auth_header=false --protected=true --auth_header=false --protected=true
else else
@ -206,8 +206,8 @@ fi
# WARNING : theses command are used in INSTALL, UPGRADE # WARNING : theses command are used in INSTALL, UPGRADE
# For any update do it in all files # For any update do it in all files
ynh_replace_string __APP__ $app ../hooks/post_cert_update ynh_replace_string __APP__ "$app" ../hooks/post_cert_update
ynh_replace_string __DOMAIN__ $domain ../hooks/post_cert_update ynh_replace_string __DOMAIN__ "$domain" ../hooks/post_cert_update
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
@ -220,16 +220,16 @@ set_permissions data
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add $app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls --description 'Main matrix server service.' yunohost service add "$app" --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports "$port_synapse_tls" --description 'Main matrix server service.'
yunohost service add $app-coturn --needs_exposed_ports $port_turnserver_tls --description 'Turn server for matrix server. Used for audio and video call.' yunohost service add "$app"-coturn --needs_exposed_ports "$port_turnserver_tls" --description 'Turn server for matrix server. Used for audio and video call.'
#================================================= #=================================================
# RELOAD SERVICES # RELOAD SERVICES
#================================================= #=================================================
ynh_script_progression --message="Restarting Synapse services..." --weight=11 ynh_script_progression --message="Restarting Synapse services..." --weight=11
ynh_systemd_action --service_name=$app-coturn.service --action=restart ynh_systemd_action --service_name="$app"-coturn.service --action=restart
ynh_systemd_action --service_name=$app.service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 ynh_systemd_action --service_name="$app".service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN