1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gotosocial_ynh.git synced 2024-09-03 19:16:06 +02:00

Merge pull request #3 from OniriCorpe/fix_scripts

Fix scripts
This commit is contained in:
OniriCorpe 2022-03-15 04:10:55 +01:00 committed by GitHub
commit b9d7b1c94a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 150 deletions

View file

@ -5,7 +5,7 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="goto.domain.tld"
admin="xana" admin="xana"
email="user@example.com" email="user@example.com"
password="1Strong-Password" password="1Strong-Password"
@ -20,7 +20,7 @@
upgrade=1 upgrade=1
upgrade=0 from_commit=CommitHash upgrade=0 from_commit=CommitHash
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=0
port_already_use=0 port_already_use=0
change_url=0 change_url=0
;;; Options ;;; Options
@ -29,4 +29,4 @@ Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=CommitHash ; commit=CommitHash
name=Name and date of the commit. name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&password=pass&port=666&

View file

@ -167,7 +167,7 @@ web-asset-base-dir: "./web/assets/"
# Bool. Do we want people to be able to just submit sign up requests, or do we want invite only? # Bool. Do we want people to be able to just submit sign up requests, or do we want invite only?
# Options: [true, false] # Options: [true, false]
# Default: true # Default: true
accounts-registration-open: __REGISTRATION__ accounts-registration-open: __REGISTRATION_OPEN__
# Bool. Do sign up requests require approval from an admin/moderator before an account can sign in/use the server? # Bool. Do sign up requests require approval from an admin/moderator before an account can sign in/use the server?
# Options: [true, false] # Options: [true, false]

View file

@ -6,7 +6,7 @@
"en": "An ActivityPub social network server, written in Golang.", "en": "An ActivityPub social network server, written in Golang.",
"fr": "Un serveur de réseau social basé sur ActivityPub écrit en Golang." "fr": "Un serveur de réseau social basé sur ActivityPub écrit en Golang."
}, },
"version": "0.2.1~ynh1", "version": "0.2.1~ynh2",
"url": "https://github.com/superseriousbusiness/gotosocial", "url": "https://github.com/superseriousbusiness/gotosocial",
"upstream": { "upstream": {
"license": " AGPL-3.0-only", "license": " AGPL-3.0-only",
@ -22,7 +22,7 @@
"email": "" "email": ""
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.3" "yunohost": ">= 4.3.1.8"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
@ -66,7 +66,7 @@
} }
}, },
{ {
"name": "registration", "name": "registration_open",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Open registration?", "en": "Open registration?",

View file

@ -24,19 +24,22 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." --weight=1 ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) 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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." --weight=1 ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs ### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that ### to be backuped and not an actual copy of any file. The actual backup that
@ -79,14 +82,10 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/etc/$app/"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the PostgreSQL database..." --weight=5 ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql ynh_psql_dump_db --database="$db_name" > db.sql
@ -94,4 +93,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --weight=1 ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -26,10 +26,12 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
email=$YNH_APP_ARG_EMAIL email=$YNH_APP_ARG_EMAIL
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
registration=$YNH_APP_ARG_REGISTRATION
registration_open=$YNH_APP_ARG_REGISTRATION_OPEN
registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL
registration_reason=$YNH_APP_ARG_REGISTRATION_REASON registration_reason=$YNH_APP_ARG_REGISTRATION_REASON
@ -71,12 +73,16 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path_url --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=password --value=$password ynh_app_setting_set --app=$app --key=password --value=$password
ynh_app_setting_set --app=$app --key=registration --value=$registration
ynh_app_setting_set --app=$app --key=registration_open --value=$registration_open
ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval
ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason
@ -89,21 +95,11 @@ ynh_script_progression --message="Finding an available port..." --weight=1
### Use these lines if you have to open a port for the application ### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port. ### `ynh_find_port` will find the first available port starting from the given port.
### If you're not using these lines:
### - Remove the section "CLOSE A PORT" in the remove script
# Find an available port # Find an available port
port=$(ynh_find_port --port=8095) port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
# Optional: Expose this port publicly
# (N.B.: you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
# Open the port
# ynh_script_progression --message="Configuring firewall..." --weight=1
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -111,11 +107,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=5
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. ### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
### Those deb packages will be installed as dependencies of this package. ### Those deb packages will be installed as dependencies of this package.
### If you're not using this helper:
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
### - Remove the variable "pkg_dependencies" in _common.sh
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -151,7 +142,6 @@ ynh_script_progression --message="Setting up source files..." --weight=1
architecture=$YNH_ARCH architecture=$YNH_ARCH
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --source_id=$architecture ynh_setup_source --dest_dir="$final_path" --source_id=$architecture
@ -187,9 +177,6 @@ ynh_script_progression --message="Creating a data directory..." --weight=1
### Use these lines if you need to create a directory to store "persistent files" for the application. ### Use these lines if you need to create a directory to store "persistent files" for the application.
### Usually this directory is used to store uploaded files or any file that won't be updated during ### Usually this directory is used to store uploaded files or any file that won't be updated during
### an upgrade and that won't be deleted during app removal ### an upgrade and that won't be deleted during app removal
### If you're not using these lines:
### - Remove the section "BACKUP THE DATA DIR" in the backup script
### - As well as the section "RESTORE THE DATA DIRECTORY" in the restore script
datadir=/home/yunohost.app/$app datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir ynh_app_setting_set --app=$app --key=datadir --value=$datadir
@ -247,12 +234,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1
### It can be used for apps that use sysvinit (with adaptation) or systemd. ### It can be used for apps that use sysvinit (with adaptation) or systemd.
### Have a look at the app to be sure this app needs a systemd script. ### Have a look at the app to be sure this app needs a systemd script.
### `ynh_systemd_config` will use the file conf/systemd.service ### `ynh_systemd_config` will use the file conf/systemd.service
### If you're not using these lines:
### - You can remove those files in conf/.
### - Remove the section "BACKUP SYSTEMD" in the backup script
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
### - As well as the section "RESTORE SYSTEMD" in the restore script
### - And the section "SETUP SYSTEMD" in the upgrade script
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -287,11 +268,6 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. ### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app. ### Use this helper only if there is effectively a log file for this app.
### If you're not using this helper:
### - Remove the section "BACKUP LOGROTATE" in the backup script
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
@ -304,11 +280,6 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
### `yunohost service add` integrates a service in YunoHost. It then gets ### `yunohost service add` integrates a service in YunoHost. It then gets
### displayed in the admin interface and through the others `yunohost service` commands. ### displayed in the admin interface and through the others `yunohost service` commands.
### (N.B.: this line only makes sense if the app adds a service to the system!) ### (N.B.: this line only makes sense if the app adds a service to the system!)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log"
@ -331,7 +302,7 @@ yunohost service add $app --description="Gotosocial server" --log="/var/log/$app
#================================================= #=================================================
# CREATE ADMIN USER # CREATE ADMIN USER
#================================================= #=================================================
ynh_script_progression --message="Creating admin user..." --weight=1 ynh_script_progression --message="Creating gotosocial admin user..." --weight=1
"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" "$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password"
@ -346,11 +317,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
### `ynh_systemd_action` is used to start a systemd service for an app. ### `ynh_systemd_action` is used to start a systemd service for an app.
### Only needed if you have configure a systemd service ### Only needed if you have configure a systemd service
### If you're not using these lines:
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
### - As well as the section "START SYSTEMD SERVICE" in the restore script
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"

View file

@ -21,6 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -67,6 +68,14 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE APP DATA DIR
#=================================================
ynh_script_progression --message="Removing app data directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$datadir"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -100,12 +109,6 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." --weight=1 ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"

View file

@ -28,11 +28,20 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
path_url=$(ynh_app_setting_get --app=$app --key=path_url)
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
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
registration_open=$(ynh_app_setting_get --app=$app --key=registration_open)
registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval)
registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
@ -122,11 +131,8 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" mkdir -p /var/log/$app
ynh_restore_file --origin_path="/etc/$app/"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD

View file

@ -12,16 +12,25 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
path_url=$(ynh_app_setting_get --app=$app --key=path_url)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) 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)
registration_open=$(ynh_app_setting_get --app=$app --key=registration_open)
registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval)
registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -38,7 +47,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)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -54,70 +63,14 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
# of what you may want to do in some cases (e.g. a setting was not defined on
# some legacy installs and you therefore want to initiaze stuff during upgrade)
#
# If db_name doesn't exist, create it
#if [ -z "$db_name" ]; then
# db_name=$(ynh_sanitize_dbid --db_name=$app)
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#fi
# If final_path doesn't exist, create it
#if [ -z "$final_path" ]; then
# final_path=/var/www/$app
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#fi
### If nobody installed your app before 4.1,
### then you may safely remove these lines
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
fi
# Create a permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
fi
#Switch variables name
psql_db=$(ynh_app_setting_get --app=$app --key=psql_db)
if [ -n "$psql_db" ]
then
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_app_setting_delete --app=$app --key=psql_db
ynh_app_setting_delete --app=$app --key=psqlpwd
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -128,10 +81,12 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..."
architecture=$YNH_ARCH
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path" --source_id=$architecture --keep="config.yaml"
fi fi
# FIXME: this should be managed by the core in the future # FIXME: this should be managed by the core in the future
@ -147,7 +102,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
@ -155,7 +110,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -168,20 +123,20 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..."
### Same as during install ### Same as during install
### ###
### The file will automatically be backed-up if it's found to be manually modified (because ### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum) ### ynh_add_config keeps track of the file's checksum)
ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml"
# FIXME: this should be handled by the core in the future # FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400, # You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config # for example if the app is expected to be able to modify its own config
chmod 400 "$final_path/some_config_file" chmod 400 "$final_path/config.yaml"
chown $app:$app "$final_path/some_config_file" chown $app:$app "$final_path/config.yaml"
### For more complex cases where you want to replace stuff using regexes, ### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) ### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
@ -193,7 +148,7 @@ chown $app:$app "$final_path/some_config_file"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -203,7 +158,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
@ -211,21 +166,21 @@ ynh_use_logrotate --non-append
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -233,4 +188,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed"