1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mautrix_facebook_ynh.git synced 2024-09-03 19:36:33 +02:00

More example_ynh

This commit is contained in:
yalh76 2022-09-04 23:58:34 +02:00
parent 0b0318f557
commit a96678e79d
8 changed files with 29 additions and 29 deletions

View file

@ -18,7 +18,7 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets="https://github.com/mautrix/facebook/archive/$version.tar.gz" assets="https://github.com/$repo/archive/$version.tar.gz"
# Later down the script, we assume the version has only digits and dots # Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out. # Sometimes the release name starts with a "v", so let's filter it out.

View file

View file

@ -47,7 +47,7 @@ ynh_backup --src_path="$final_path"
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup --src_path="/var/log/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD

View file

@ -81,7 +81,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=97 ynh_script_progression --message="Installing dependencies..." --weight=97
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -131,7 +131,7 @@ chown $app:$app "$final_path/config.yaml"
#================================================= #=================================================
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=1 ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
mkdir -p /var/log/$app mkdir -p /var/log/$app
# Configure Mautrix-Bridge # Configure Mautrix-Bridge
@ -146,9 +146,7 @@ $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
ynh_script_progression --message="Registering Synapse app-service" --weight=1 ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml $final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $synapse_registration_path to the app_service_config_files list
chown -R $app:$app "$final_path" chown -R $app:$app "$final_path"
ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml" ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml"
@ -171,7 +169,7 @@ ynh_script_progression --message="Configuring log rotation..." --weight=3
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile "/var/log/$app/$app.log" ynh_use_logrotate --logfile "/var/log/$app/$app.log"
chown $app:$app -R /var/log/$app chown -R $app:$app /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -186,7 +184,7 @@ yunohost service add $app --description="$app daemon for bridging FB and Matrix
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
# Wait until the synapse user is created # Wait until the synapse user is created
sleep 30 sleep 30
# # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) # # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)

View file

@ -17,11 +17,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
botname=$(ynh_app_setting_get --app=$app --key=botname) botname=$(ynh_app_setting_get --app=$app --key=botname)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
server_name=$(ynh_app_setting_get --app=$app --key=server_name) server_name=$(ynh_app_setting_get --app=$app --key=server_name)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -89,7 +86,7 @@ ynh_script_progression --message="Removing various files..." --weight=6
# Remove a directory securely # Remove a directory securely
ynh_secure_remove --file="$synapse_registration_path/$app.yaml" ynh_secure_remove --file="$synapse_registration_path/$app.yaml"
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"

View file

@ -73,7 +73,7 @@ chown -R $app:$app "$final_path"
ynh_script_progression --message="Reinstalling dependencies..." --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
@ -88,17 +88,19 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=1 ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
ynh_restore_file --origin_path="/var/log/$app"
python3 -m venv $final_path python3 -m venv $final_path
export HOME=$final_path export HOME=$final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel $final_path/bin/pip3 install --upgrade pip setuptools wheel
$final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $synapse_registration_path to the app_service_config_files list
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -113,8 +115,7 @@ systemctl enable $app.service --quiet
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_use_logrotate --logfile "/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
chown $app:$app -R /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -129,7 +130,7 @@ yunohost service add $app --description="$app daemon for bridging FB and Matrix
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
# Wait until the synapse user is created # Wait until the synapse user is created
sleep 30 sleep 30
# # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) # # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)

View file

@ -41,7 +41,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -95,7 +95,7 @@ chown -R $app:$app "$final_path"
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -112,21 +112,25 @@ chown $app:$app "$final_path/config.yaml"
#================================================= #=================================================
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE # UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Upgrading Mautrix-Bridge..." --weight=2 ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2
mkdir -p /var/log/$app
# Configure Mautrix-Bridge
python3 -m venv $final_path python3 -m venv $final_path
export HOME=$final_path export HOME=$final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel $final_path/bin/pip3 install --upgrade pip setuptools wheel
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
$final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $synapse_registration_path to the app_service_config_files list
# Set permissions on app files # Set permissions on app files
chown -R $app:$app "$final_path" chown -R $app:$app "$final_path"
ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD