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

Merge pull request #11 from YunoHost-Apps/update-ynh

Update ynh
This commit is contained in:
Clément 2020-04-14 21:35:58 +02:00 committed by GitHub
commit f63c07e630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 164 deletions

View file

@ -22,6 +22,8 @@ location __PATH__/ {
proxy_buffering off;
fastcgi_param REMOTE_USER $remote_user;
client_max_body_size 50M;
more_set_input_headers 'Authorization: $http_authorization';
proxy_set_header Authorization $http_authorization;
# Force https
if ($scheme = http) {

View file

@ -6,7 +6,7 @@
"en": "A simple server for sending and receiving messages.",
"fr": "Un simple serveur pour envoyer et recevoir des messages."
},
"version": "2.0.10~ynh1",
"version": "2.0.10~ynh2",
"url": "http://gotify.net",
"license": "MIT",
"maintainer": {
@ -14,7 +14,7 @@
"email": "plopoyop@gmail.com"
},
"requirements": {
"yunohost": ">= 2.7.14"
"yunohost": ">= 3.7.0"
},
"multi_instance": true,
"services": [

View file

@ -19,7 +19,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -32,21 +32,21 @@ db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backing up the main app directory..."
ynh_script_progression --message="Backing up the main app directory..." --weight=30
ynh_backup "$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL database..."
ynh_script_progression --message="Backing up the MySQL database..." --weight=20
ynh_mysql_dump_db "$db_name" > db.sql
@ -56,4 +56,4 @@ ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
ynh_backup "/etc/systemd/system/$app.service"
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)" --last

View file

@ -27,22 +27,12 @@ admin=$YNH_APP_ARG_ADMIN
is_public=1
password=$YNH_APP_ARG_PASSWORD
### If it's a multi-instance app, meaning it can be installed several times independently
### The id of the app as stated in the manifest is available as $YNH_APP_ID
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
### The app instance name is available as $YNH_APP_INSTANCE_NAME
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
### The app instance name is probably what interests you most, since this is
### guaranteed to be unique. This is a good unique identifier to define installation path,
### db names, ...
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
ynh_script_progression --message="Validating installation parameters..."
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -58,7 +48,7 @@ ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Storing installation settings..."
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
@ -72,30 +62,15 @@ ynh_app_setting_set $app password $password
# FIND AND OPEN A PORT
#=================================================
### 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.
### If you're not using these lines:
### - Remove the section "CLOSE A PORT" in the remove script
# Find a free port
port=$(ynh_find_port 8080)
# Open this port
# yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_print_info "Creating a MySQL database..."
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
### The password will be stored as 'mysqlpwd' into the app settings,
### and will be available as $db_pwd
### If you're not using these lines:
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
ynh_script_progression --message="Creating a MySQL database..." --weight=20
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
@ -104,11 +79,7 @@ ynh_mysql_setup_db $db_name $db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_script_progression --message="Setting up source files..." --weight=6
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
@ -117,9 +88,7 @@ ynh_setup_source "$final_path" $architecture
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
ynh_script_progression --message="Configuring nginx web server..." --weight=2
# Create a dedicated nginx config
ynh_add_nginx_config
@ -127,7 +96,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create $app
@ -137,27 +106,14 @@ ynh_system_user_create $app
# SETUP SYSTEMD
#=================================================
### `ynh_systemd_config` is used to configure a systemd script for an app.
### 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.
### `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
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info "Create config file..."
ynh_script_progression --message="Create config file..." --weight=1
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
cp ../conf/config.yml "$final_path/config.yml"
ynh_replace_string "__APP__" $app "$final_path/config.yml"
ynh_replace_string "__PORT__" $port "$final_path/config.yml"
@ -171,10 +127,6 @@ ynh_replace_string "__DOMAIN__" $domain "$final_path/config.yml"
# STORE THE CONFIG FILE CHECKSUM
#=================================================
### `ynh_store_file_checksum` is used to store the checksum of a file.
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/config.yml"
@ -184,69 +136,31 @@ ynh_store_file_checksum "$final_path/config.yml"
# SECURE FILES AND DIRECTORIES
#=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# Set permissions to app files
chown -R root: $final_path
mkdir $final_path/data
chown $app $final_path/data
#=================================================
# SETUP LOGROTATE
#=================================================
### `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.
### 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)
# ynh_use_logrotate
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
### You'll find the service in the 'services' section of YunoHost admin panel.
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
yunohost service add $app
#--log "/var/log/FILE.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Make app public if necessary
# if [ $is_public -eq 1 ]
# then
# # unprotected_uris allows SSO credentials to be passed anyway.
# ynh_app_setting_set $app unprotected_uris "/"
# fi
# websocket must be open
# ynh_app_setting_set $app unprotected_uris "/stream"
ynh_app_setting_set $app unprotected_uris "/"
ynh_permission_update --permission "main" --add visitors
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_script_progression --message="Reloading nginx web server..." --weight=1
systemctl reload nginx
systemctl start $app
# yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_print_info "Installation of $app completed"
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get $app final_path)
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app
then
echo "Remove $app service"
ynh_script_progression --message="Remove $app service" --weight=1
yunohost service remove $app
fi
@ -46,7 +46,7 @@ ynh_remove_systemd_config
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_print_info "Removing the MySQL database"
ynh_script_progression --message="Removing the MySQL database..." --weight=10
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_user $db_name
@ -54,7 +54,7 @@ ynh_mysql_remove_db $db_user $db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
ynh_script_progression --message="Removing app main directory..." --weight=30
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -62,51 +62,19 @@ ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx web server configuration"
ynh_script_progression --message="Removing nginx web server configuration..." --weight=5
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
# Remove the app-specific logrotate config
# ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
# if yunohost firewall list | grep -q "\- $port$"
# then
# echo "Close port $port" >&2
# yunohost firewall disallow TCP $port 2>&1
# fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
#=================================================
# Remove a cron file
# ynh_secure_remove "/etc/cron.d/$app"
# Remove a directory securely
# ynh_secure_remove "/etc/$app/"
# Remove the log files
# ynh_secure_remove "/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user
ynh_system_user_delete $app
ynh_print_info "Removal of $app completed"
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -19,7 +19,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading settings..."
ynh_script_progression --message="Loading settings.."
app=$YNH_APP_INSTANCE_NAME
@ -31,7 +31,7 @@ db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
ynh_script_progression --message="Validating restoration parameters.." --weight=1
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
@ -43,21 +43,21 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Restoring nginx configuration..."
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory.." --weight=1
ynh_restore_file "$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_print_info "Restoring the MySQL database..."
ynh_script_progression --message="Restoring the MySQL database.." --weight=20
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
@ -66,7 +66,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
ynh_script_progression --message="Recreating the dedicated system user.." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create $app
@ -86,12 +86,11 @@ chown -R $app: $final_path/data/
#=================================================
yunohost service add $app
# --log "/var/log/$app/APP.log"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restoring service..."
ynh_script_progression --message="Restoring service..." --weight=10
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
@ -99,8 +98,8 @@ systemctl start $app
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_script_progression --message="Reloading nginx web server ..." --weight=1
systemctl reload nginx
ynh_print_info "Restoration completed for $app"
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading settings.." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -29,7 +29,7 @@ password=$(ynh_app_setting_get $app password)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
ynh_script_progression --message="Ensuring downward compatibility.." --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
@ -55,7 +55,7 @@ fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..."
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
# Backup the current version of the app
ynh_backup_before_upgrade
@ -78,7 +78,7 @@ path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
ynh_script_progression --message="Upgrading source files..." --weight=6
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" $architecture
@ -86,7 +86,7 @@ ynh_setup_source "$final_path" $architecture
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
# Create a dedicated nginx config
if [ "$path_url" != "/" ]
@ -99,7 +99,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2
# Create a dedicated user (if not existing)
ynh_system_user_create $app
@ -151,22 +151,27 @@ chown -R $app: $final_path/data
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
ynh_script_progression --message="Configuring SSOwat..." --weight=1
ynh_app_setting_set $app unprotected_uris "/"
unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris)
if [ ! -z "$unprotected_uris" ]; then
ynh_app_setting_delete --app=$app --key=unprotected_uris
fi
ynh_permission_update --permission "main" --add visitors
#=================================================
# RELOAD SERVICE
#=================================================
ynh_print_info "Reloading service..."
ynh_script_progression --message="Reloading service..." --weight=1
systemctl restart $app
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_script_progression --message="Reloading nginx web server..." --weight=1
systemctl reload nginx
ynh_print_info "Upgrade of $app completed"
ynh_script_progression --message="Upgrade of $app completed" --last