mirror of
https://github.com/YunoHost-Apps/gotosocial_ynh.git
synced 2024-09-03 19:16:06 +02:00
commit
e2e753bb37
13 changed files with 396 additions and 242 deletions
|
@ -24,7 +24,7 @@ With GoToSocial, you can keep in touch with your friends, post, read, and share
|
|||
Documentation is at [docs.gotosocial.org](https://docs.gotosocial.org).
|
||||
|
||||
|
||||
**Shipped version:** 0.2.1~ynh3
|
||||
**Shipped version:** 0.2.1~ynh4
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Avec GoToSocial, vous pouvez rester en contact avec vos amis, publier, lire et p
|
|||
Vous pouvez consulter la documentation à l'adresse : [docs.gotosocial.org](https://docs.gotosocial.org).
|
||||
|
||||
|
||||
**Version incluse :** 0.2.1~ynh3
|
||||
**Version incluse :** 0.2.1~ynh4
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
setup_private=0
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=0 from_commit=CommitHash
|
||||
upgrade=1 from_commit=460048e78df8a195b1eca5994a4699079954b312
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=1
|
||||
|
@ -27,6 +27,5 @@
|
|||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&password=pass&port=666&
|
||||
; commit=460048e78df8a195b1eca5994a4699079954b312
|
||||
name=0.2.1~ynh3
|
||||
|
|
|
@ -188,22 +188,22 @@ accounts-reason-required: __REGISTRATION_REASON__
|
|||
# Int. Maximum allowed image upload size in bytes.
|
||||
# Examples: [2097152, 10485760]
|
||||
# Default: 2097152 -- aka 2MB
|
||||
media-image-max-size: 2097152
|
||||
media-image-max-size: __MEDIA_IMAGE_MAX_SIZE__
|
||||
|
||||
# Int. Maximum allowed video upload size in bytes.
|
||||
# Examples: [2097152, 10485760]
|
||||
# Default: 10485760 -- aka 10MB
|
||||
media-video-max-size: 10485760
|
||||
media-video-max-size: __MEDIA_VIDEO_MAX_SIZE__
|
||||
|
||||
# Int. Minimum amount of characters required as an image or video description.
|
||||
# Examples: [500, 1000, 1500]
|
||||
# Default: 0 (not required)
|
||||
media-description-min-chars: 0
|
||||
media-description-min-chars: __MEDIA_DESCRIPTION_MIN_CHARS__
|
||||
|
||||
# Int. Maximum amount of characters permitted in an image or video description.
|
||||
# Examples: [500, 1000, 1500]
|
||||
# Default: 500
|
||||
media-description-max-chars: 500
|
||||
media-description-max-chars: __MEDIA_DESCRIPTION_MAX_CHARS__
|
||||
|
||||
# Int. Number of days to cache media from remote instances before they are removed from the cache.
|
||||
# A job will run every day at midnight to clean up any remote media older than the given amount of days.
|
||||
|
@ -214,7 +214,7 @@ media-description-max-chars: 500
|
|||
# If this is set to 0, then media from remote instances will be cached indefinitely.
|
||||
# Examples: [30, 60, 7, 0]
|
||||
# Default: 30
|
||||
media-remote-cache-days: 30
|
||||
media-remote-cache-days: __MEDIA_REMOTE_CACHE_DAYS__
|
||||
|
||||
##########################
|
||||
##### STORAGE CONFIG #####
|
||||
|
@ -245,31 +245,31 @@ storage-local-base-path: "__DATADIR__"
|
|||
# Note that going way higher than the default might break federation.
|
||||
# Examples: [140, 500, 5000]
|
||||
# Default: 5000
|
||||
statuses-max-chars: 5000
|
||||
statuses-max-chars: __STATUSES_MAX_CHARS__
|
||||
|
||||
# Int. Maximum amount of characters allowed in the CW/subject header of a status.
|
||||
# Note that going way higher than the default might break federation.
|
||||
# Examples: [100, 200]
|
||||
# Default: 100
|
||||
statuses-cw-max-chars: 100
|
||||
statuses-cw-max-chars: __STATUSES_CW_MAX_CHARS__
|
||||
|
||||
# Int. Maximum amount of options to permit when creating a new poll.
|
||||
# Note that going way higher than the default might break federation.
|
||||
# Examples: [4, 6, 10]
|
||||
# Default: 6
|
||||
statuses-poll-max-options: 6
|
||||
statuses-poll-max-options: __STATUSES_POLL_MAX_OPTIONS__
|
||||
|
||||
# Int. Maximum amount of characters to permit per poll option when creating a new poll.
|
||||
# Note that going way higher than the default might break federation.
|
||||
# Examples: [50, 100, 150]
|
||||
# Default: 50
|
||||
statuses-poll-option-max-chars: 50
|
||||
statuses-poll-option-max-chars: __STATUSES_POLL_OPTION_MAX_CHARS__
|
||||
|
||||
# Int. Maximum amount of media files that can be attached to a new status.
|
||||
# Note that going way higher than the default might break federation.
|
||||
# Examples: [4, 6, 10]
|
||||
# Default: 6
|
||||
statuses-media-max-files: 6
|
||||
statuses-media-max-files: __STATUSES_MEDIA_MAX_FILES__
|
||||
|
||||
##############################
|
||||
##### LETSENCRYPT CONFIG #####
|
||||
|
@ -372,12 +372,12 @@ oidc-scopes:
|
|||
# If this is not set, smtp will not be used to send emails, and you can ignore the other settings.
|
||||
# Examples: ["mail.example.org", "localhost"]
|
||||
# Default: ""
|
||||
smtp-host: ""
|
||||
smtp-host: "localhost"
|
||||
|
||||
# Int. Port to use to connect to the smtp server.
|
||||
# Examples: []
|
||||
# Default: 0
|
||||
smtp-port: 0
|
||||
smtp-port: 25
|
||||
|
||||
# String. Username to use when authenticating with the smtp server.
|
||||
# This should have been provided to you by your smtp host.
|
||||
|
@ -395,7 +395,7 @@ smtp-password: ""
|
|||
# String. 'From' address for sent emails.
|
||||
# Examples: ["mail@example.org"]
|
||||
# Default: ""
|
||||
smtp-from: ""
|
||||
smtp-from: "GoToSocial@__DOMAIN__"
|
||||
|
||||
#########################
|
||||
##### SYSLOG CONFIG #####
|
||||
|
|
|
@ -9,7 +9,7 @@ location __PATH__/ {
|
|||
|
||||
proxy_pass http://localhost:__PORT__;
|
||||
|
||||
client_max_body_size 50M;
|
||||
client_max_body_size __CLIENT_MAX_BODY_SIZE__;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
|
167
config_panel.toml
Normal file
167
config_panel.toml
Normal file
|
@ -0,0 +1,167 @@
|
|||
version = "1.0"
|
||||
|
||||
[gotosocial]
|
||||
|
||||
services = ["__APP__"]
|
||||
|
||||
name = "GoToSocial configuration panel"
|
||||
|
||||
help = "Here you can easily configure some things about your GoToSocial instance."
|
||||
|
||||
####################
|
||||
#### ACCOUNTS CONFIG
|
||||
####################
|
||||
|
||||
[gotosocial.accounts]
|
||||
|
||||
name = "Accounts config"
|
||||
|
||||
help = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts."
|
||||
|
||||
[gotosocial.accounts.registration_open]
|
||||
ask.en = "Open registrations?"
|
||||
ask.fr = "Inscriptions ouvertes ?"
|
||||
bind = "accounts-registration-open:__FINALPATH__/config.yaml"
|
||||
choices = ["true", "false"]
|
||||
default = "false"
|
||||
help.en = "Do we want people to be able to just submit sign up requests, or do we want invite only?"
|
||||
help.fr = "Voulez-vous que les gens puissent simplement envoyer des demandes d'inscription, ou voulez-vous qu'iels doivent être invité-e-s ?"
|
||||
type = "select"
|
||||
|
||||
[gotosocial.accounts.approval_required]
|
||||
ask.en = "Approval required?"
|
||||
ask.fr = "Validation requise ?"
|
||||
bind = "accounts-approval-required:__FINALPATH__/config.yaml"
|
||||
choices = ["true", "false"]
|
||||
default = "true"
|
||||
help.en = "Do sign up requests require approval from an admin/moderator before an account can sign in/use the server?"
|
||||
help.fr = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter/utiliser le serveur ?"
|
||||
type = "select"
|
||||
|
||||
[gotosocial.accounts.reason_required]
|
||||
ask.en = "Reason required?"
|
||||
ask.fr = "Motif requis ?"
|
||||
bind = "accounts-reason-required:__FINALPATH__/config.yaml"
|
||||
choices = ["true", "false"]
|
||||
default = "true"
|
||||
help.en = "Are sign up requests required to submit a reason for the request (eg., an explanation of why they want to join the instance)?"
|
||||
help.fr = "Les demandes d'inscription doivent-elles être motivées (par exemple, par une explication de la raison pour laquelle la personne souhaite rejoindre l'instance) ?"
|
||||
type = "select"
|
||||
|
||||
#################
|
||||
#### MEDIA CONFIG
|
||||
#################
|
||||
|
||||
[gotosocial.media]
|
||||
name = "Media config"
|
||||
|
||||
help = "Config pertaining to user media uploads (videos, image, image descriptions)."
|
||||
|
||||
[gotosocial.media.media_image_max_size]
|
||||
ask.en = "Maximum allowed image upload size in bytes."
|
||||
ask.fr = "Taille maximale autorisée pour le téléchargement d'images, en octets."
|
||||
bind = "media-image-max-size:__FINALPATH__/config.yaml"
|
||||
default = "2097152"
|
||||
help.en = "Default: 2097152 -- aka 2MB"
|
||||
help.fr = "Valeur par défaut : 2097152 (soit 2 Mo)"
|
||||
type = "number"
|
||||
|
||||
[gotosocial.media.media_video_max_size]
|
||||
ask.en = "Maximum allowed video upload size in bytes."
|
||||
ask.fr = "Taille maximale autorisée pour le téléchargement de vidéos, en octets."
|
||||
bind = "media-video-max-size:__FINALPATH__/config.yaml"
|
||||
default = "10485760"
|
||||
help.en = "Default: 10485760 -- aka 10MB"
|
||||
help.fr = "Valeur par défaut : 10485760 (soit 10 Mo)"
|
||||
type = "number"
|
||||
|
||||
[gotosocial.media.media_description_min_chars]
|
||||
ask.en = "Minimum amount of characters required as an image or video description."
|
||||
ask.fr = "Nombre minimum de caractères requis pour la description d'une image ou d'une vidéo."
|
||||
bind = "media-description-min-chars:__FINALPATH__/config.yaml"
|
||||
default = "0"
|
||||
help.en = "Default: 0 (not required)"
|
||||
help.fr = "Valeur par défaut : 0 (non obligatoire)"
|
||||
type = "number"
|
||||
|
||||
[gotosocial.media.media_description_max_chars]
|
||||
ask.en = "Maximum amount of characters permitted in an image or video description."
|
||||
ask.fr = "Nombre maximum de caractères requis pour la description d'une image ou d'une vidéo."
|
||||
bind = "media-description-max-chars:__FINALPATH__/config.yaml"
|
||||
default = "500"
|
||||
help.en = "Default: 500"
|
||||
help.fr = "Valeur par défaut : 500"
|
||||
type = "number"
|
||||
|
||||
[gotosocial.media.media_remote_cache_days]
|
||||
ask.en = "Number of days to cache media from remote instances before they are removed from the cache."
|
||||
ask.fr = "Nombre de jours de mise en cache des médias des instances distantes avant qu'ils ne soient retirés du cache."
|
||||
bind = "media-remote-cache-days:__FINALPATH__/config.yaml"
|
||||
default = "30"
|
||||
help.en = """\
|
||||
Default: 30\
|
||||
A job will run every day at midnight to clean up any remote media older than the given amount of days. \
|
||||
When remote media is removed from the cache, it is deleted from storage but the database entries for the media are kept so that it can be fetched again if requested by a user.\
|
||||
If this is set to 0, then media from remote instances will be cached indefinitely.\
|
||||
"""
|
||||
help.fr = """\
|
||||
Valeur par défaut : 30\
|
||||
Une tâche est exécutée tous les soirs à minuit pour nettoyer les médias distants datant de plus d'un certain nombre de jours.\
|
||||
Lorsque le média distant est supprimé du cache, il est supprimé du stockage mais les entrées de la base de données pour le média sont conservées afin qu'il puisse être récupéré si un utilisateur le demande.\
|
||||
Si la valeur 0 est attribuée à ce paramètre, les médias des instances distantes sont mis en cache indéfiniment.\
|
||||
"""
|
||||
type = "number"
|
||||
|
||||
###################
|
||||
### STATUSES CONFIG
|
||||
###################
|
||||
|
||||
[gotosocial.statuses]
|
||||
name = "Status config"
|
||||
|
||||
help = "Config pertaining to the creation of statuses/posts, and permitted limits."
|
||||
|
||||
[gotosocial.statuses.statuses_max_chars]
|
||||
ask.en = "Maximum amount of characters permitted for a new status."
|
||||
ask.fr = "Nombre maximal de caractères autorisés pour un nouveau statut."
|
||||
bind = "statuses-max-chars:__FINALPATH__/config.yaml"
|
||||
default = "5000"
|
||||
help.en = "Default: 5000. Note that going way higher than the default might break federation."
|
||||
help.fr = "Valeur par défaut : 5000. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération."
|
||||
type = "number"
|
||||
|
||||
[gotosocial.statuses.statuses_cw_max_chars]
|
||||
ask.en = "Maximum amount of characters allowed in the CW/subject header of a status."
|
||||
ask.fr = "Nombre maximum de caractères autorisés dans l'en-tête CW/sujet d'un statut."
|
||||
bind = "statuses-cw-max-chars:__FINALPATH__/config.yaml"
|
||||
default = "100"
|
||||
help.en = "Default: 100. Note that going way higher than the default might break federation."
|
||||
help.fr = "Valeur par défaut : 100. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération."
|
||||
type = "number"
|
||||
|
||||
[gotosocial.statuses.statuses_poll_max_options]
|
||||
ask.en = "Maximum amount of options to permit when creating a new poll."
|
||||
ask.fr = "Nombre maximum d'options autorisées lors de la création d'un nouveau sondage."
|
||||
bind = "statuses-poll-max-options:__FINALPATH__/config.yaml"
|
||||
default = "6"
|
||||
help.en = "Default: 6. Note that going way higher than the default might break federation."
|
||||
help.fr = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération."
|
||||
type = "number"
|
||||
|
||||
[gotosocial.statuses.statuses_poll_option_max_chars]
|
||||
ask.en = "Maximum amount of characters to permit per poll option when creating a new poll."
|
||||
ask.fr = "Nombre maximal de caractères autorisés par option de sondage lors de la création d'un nouveau sondage."
|
||||
bind = "statuses-poll-option-max-chars:__FINALPATH__/config.yaml"
|
||||
default = "50"
|
||||
help.en = "Default: 50. Note that going way higher than the default might break federation."
|
||||
help.fr = "Valeur par défaut : 50. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération."
|
||||
type = "number"
|
||||
|
||||
[gotosocial.statuses.statuses_media_max_files]
|
||||
ask.en = "Maximum amount of media files that can be attached to a new status."
|
||||
ask.fr = "Quantité maximale de fichiers multimédias qui peuvent être joints à un nouveau statut."
|
||||
bind = "statuses-media-max-files:__FINALPATH__/config.yaml"
|
||||
default = "6"
|
||||
help.en = "Default: 6. Note that going way higher than the default might break federation."
|
||||
help.fr = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération."
|
||||
type = "number"
|
|
@ -6,7 +6,7 @@
|
|||
"en": "An ActivityPub social network server, written in Golang.",
|
||||
"fr": "Un serveur de réseau social basé sur ActivityPub écrit en Golang."
|
||||
},
|
||||
"version": "0.2.1~ynh3",
|
||||
"version": "0.2.1~ynh4",
|
||||
"url": "https://github.com/superseriousbusiness/gotosocial",
|
||||
"upstream": {
|
||||
"license": " AGPL-3.0-only",
|
||||
|
|
|
@ -31,6 +31,11 @@ detect_arch(){
|
|||
echo $architecture
|
||||
}
|
||||
|
||||
# custom function to change bash bool 0/1 to false/true
|
||||
convert_bool(){
|
||||
(("$1")) && echo "true" || echo "false"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -26,15 +26,15 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
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)
|
||||
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
|
||||
|
|
213
scripts/install
213
scripts/install
|
@ -24,67 +24,77 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
domain="$YNH_APP_ARG_DOMAIN"
|
||||
path_url="/"
|
||||
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
email=$YNH_APP_ARG_EMAIL
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
client_max_body_size="100M"
|
||||
|
||||
registration_open=$YNH_APP_ARG_REGISTRATION_OPEN
|
||||
registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL
|
||||
registration_reason=$YNH_APP_ARG_REGISTRATION_REASON
|
||||
admin="$YNH_APP_ARG_ADMIN"
|
||||
email="$YNH_APP_ARG_EMAIL"
|
||||
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
|
||||
# Config stuff:
|
||||
|
||||
registration_open=$(convert_bool "$YNH_APP_ARG_REGISTRATION_OPEN")
|
||||
registration_approval=$(convert_bool "$YNH_APP_ARG_REGISTRATION_APPROVAL")
|
||||
registration_reason=$(convert_bool "$YNH_APP_ARG_REGISTRATION_REASON")
|
||||
|
||||
media_image_max_size="2097152"
|
||||
media_video_max_size="10485760"
|
||||
media_description_min_chars="0"
|
||||
media_description_max_chars="500"
|
||||
media_remote_cache_days="30"
|
||||
|
||||
statuses_max_chars="5000"
|
||||
statuses_cw_max_chars="100"
|
||||
statuses_poll_max_options="6"
|
||||
statuses_poll_option_max_chars="50"
|
||||
statuses_media_max_files="6"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
### About --weight and --time
|
||||
### ynh_script_progression will show to your final users the progression of each scripts.
|
||||
### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
|
||||
### is a packager option, it will show you the execution time since the previous call.
|
||||
### This option should be removed before releasing your app.
|
||||
### Use the execution time, given by --time, to estimate the weight of a step.
|
||||
### A common way to do it is to set a weight equal to the execution time in second +1.
|
||||
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
|
||||
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app"
|
||||
final_path=/var/www/$app
|
||||
final_path="/var/www/$app"
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
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=final_path --value="$final_path"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path_url --value=$path_url
|
||||
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
|
||||
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=email --value=$email
|
||||
ynh_app_setting_set --app=$app --key=password --value=$password
|
||||
ynh_app_setting_set --app="$app" --key=client_max_body_size --value="$client_max_body_size"
|
||||
|
||||
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_reason --value=$registration_reason
|
||||
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=password --value="$password"
|
||||
|
||||
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_reason --value="$registration_reason"
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=media_image_max_size --value="$media_image_max_size"
|
||||
ynh_app_setting_set --app="$app" --key=media_video_max_size --value="$media_video_max_size"
|
||||
ynh_app_setting_set --app="$app" --key=media_description_min_chars --value="$media_description_min_chars"
|
||||
ynh_app_setting_set --app="$app" --key=media_description_max_chars --value="$media_description_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=media_remote_cache_days --value="$media_remote_cache_days"
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=statuses_max_chars --value="$statuses_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_cw_max_chars --value="$statuses_cw_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_poll_max_options --value="$statuses_poll_max_options"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_poll_option_max_chars --value="$statuses_poll_option_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$statuses_media_max_files"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -93,22 +103,16 @@ ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_r
|
|||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||
|
||||
### 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.
|
||||
|
||||
# Find an available port
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=5
|
||||
|
||||
### `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.
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -116,20 +120,21 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||
db_user="$db_name"
|
||||
db_pwd=$(ynh_string_random --length=30)
|
||||
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_set --app="$app" --key=db_name --value="$db_name"
|
||||
ynh_app_setting_set --app="$app" --key=db_user --value="$db_user"
|
||||
ynh_app_setting_set --app="$app" --key=db_pwd --value="$db_pwd"
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -144,17 +149,17 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
|||
architecture=$(detect_arch)
|
||||
|
||||
# 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"
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
# such that the appropriate users (e.g. maybe www-data) can access
|
||||
# files in some cases.
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _
|
||||
# this will be treated as a security issue.
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chown -R "$app:www-data" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -164,25 +169,15 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
#
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
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.
|
||||
### 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
|
||||
|
||||
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"
|
||||
|
||||
mkdir -p $datadir
|
||||
mkdir -p "$datadir"
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
|
@ -192,74 +187,29 @@ mkdir -p $datadir
|
|||
# this will be treated as a security issue.
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
chown -R "$app:www-data" "$datadir"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
### You can add specific configuration files.
|
||||
###
|
||||
### Typically, put your template conf file in ../conf/your_config_file
|
||||
### The template may contain strings such as __FOO__ or __FOO_BAR__,
|
||||
### which will automatically be replaced by the values of $foo and $foo_bar
|
||||
###
|
||||
### ynh_add_config will also keep track of the config file's checksum,
|
||||
### which later during upgrade may allow to automatically backup the config file
|
||||
### if it's found that the file was manually modified
|
||||
###
|
||||
### Check the documentation of `ynh_add_config` for more info.
|
||||
|
||||
ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml"
|
||||
|
||||
# FIXME: this should be handled by the core in the future
|
||||
# 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
|
||||
chmod 400 "$final_path/config.yaml"
|
||||
chown $app:$app "$final_path/config.yaml"
|
||||
|
||||
### 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)
|
||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||
###
|
||||
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file"
|
||||
### ynh_store_file_checksum --file="$final_path/some_config_file"
|
||||
chown "$app:$app" "$final_path/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
### `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
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
|
||||
### Use these lines only if the app installation needs to be finalized through
|
||||
### web forms. We generally don't want to ask the final user,
|
||||
### so we're going to use curl to automatically fill the fields and submit the
|
||||
### forms.
|
||||
|
||||
# Set the app as temporarily public for curl call
|
||||
ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
||||
# Making the app public for curl
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
# Installation with curl
|
||||
ynh_script_progression --message="Finalizing installation..." --weight=1
|
||||
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||
|
||||
# Remove the public access
|
||||
ynh_permission_update --permission="main" --remove="visitors"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -267,9 +217,6 @@ ynh_permission_update --permission="main" --remove="visitors"
|
|||
#=================================================
|
||||
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.
|
||||
### Use this helper only if there is effectively a log file for this app.
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
|
@ -278,27 +225,7 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||
### 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!)
|
||||
|
||||
yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log"
|
||||
|
||||
### Additional options starting with 3.8:
|
||||
###
|
||||
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
|
||||
### which will then be checked by YunoHost's diagnosis system
|
||||
### (N.B. DO NOT USE THIS is the port is only internal!!!)
|
||||
###
|
||||
### --test_status "some command" a custom command to check the status of the service
|
||||
### (only relevant if 'systemctl status' doesn't do a good job)
|
||||
###
|
||||
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
|
||||
###
|
||||
### Re-calling 'yunohost service add' during the upgrade script is the right way
|
||||
### to proceed if you later realize that you need to enable some flags that
|
||||
### weren't enabled on old installs (be careful it'll override the existing
|
||||
### service though so you should re-provide all relevant flags when doing so)
|
||||
yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# CREATE ADMIN USER
|
||||
|
@ -316,11 +243,8 @@ ynh_script_progression --message="Creating gotosocial admin user..." --weight=1
|
|||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
### `ynh_systemd_action` is used to start a systemd service for an app.
|
||||
### Only needed if you have configure 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"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
|
@ -328,7 +252,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
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)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||
db_user=$(ynh_app_setting_get --app="$app" --key=db_user)
|
||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app="$app" --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -30,10 +30,10 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
#=================================================
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -50,7 +50,7 @@ ynh_remove_systemd_config
|
|||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=5
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
|
@ -99,7 +99,7 @@ ynh_remove_logrotate
|
|||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_script_progression --message="Closing port $port..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP "$port"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -120,7 +120,7 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
ynh_system_user_delete --username="$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -26,30 +26,44 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
|
||||
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)
|
||||
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)
|
||||
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
|
||||
|
||||
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
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)
|
||||
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)
|
||||
|
||||
media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size)
|
||||
media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size)
|
||||
media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars)
|
||||
media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars)
|
||||
media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days)
|
||||
|
||||
statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars)
|
||||
statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars)
|
||||
statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options)
|
||||
statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars)
|
||||
statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path \
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
|
@ -67,7 +81,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the 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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
|
@ -84,7 +98,7 @@ ynh_restore_file --origin_path="$final_path"
|
|||
# this will be treated as a security issue.
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chown -R "$app:www-data" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
|
@ -93,7 +107,7 @@ ynh_script_progression --message="Restoring the data directory..." --weight=5
|
|||
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p $datadir
|
||||
mkdir -p "$datadir"
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
|
@ -103,7 +117,7 @@ mkdir -p $datadir
|
|||
# this will be treated as a security issue.
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
chown -R "$app:www-data" "$datadir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -113,7 +127,7 @@ chown -R $app:www-data "$datadir"
|
|||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
|
@ -121,18 +135,18 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database=$db_name
|
||||
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database="$db_name"
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
mkdir -p /var/log/$app
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
@ -140,21 +154,21 @@ mkdir -p /var/log/$app
|
|||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
systemctl enable "$app.service" --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
|
|
112
scripts/upgrade
112
scripts/upgrade
|
@ -14,23 +14,37 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_script_progression --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)
|
||||
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)
|
||||
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_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
datadir=$(ynh_app_setting_get --app="$app" --key=datadir)
|
||||
|
||||
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)
|
||||
|
||||
media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size)
|
||||
media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size)
|
||||
media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars)
|
||||
media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars)
|
||||
media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days)
|
||||
|
||||
statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars)
|
||||
statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars)
|
||||
statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options)
|
||||
statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars)
|
||||
statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -65,7 +79,52 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
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..."
|
||||
|
||||
# Upgrade from <0.2.1~ynh4:
|
||||
if ynh_compare_current_package_version --comparison lt --version 0.2.1~ynh4
|
||||
then
|
||||
# declaration of new parameters
|
||||
client_max_body_size="100M"
|
||||
media_image_max_size="2097152"
|
||||
media_video_max_size="10485760"
|
||||
media_description_min_chars="0"
|
||||
media_description_max_chars="500"
|
||||
media_remote_cache_days="30"
|
||||
statuses_max_chars="5000"
|
||||
statuses_cw_max_chars="100"
|
||||
statuses_poll_max_options="6"
|
||||
statuses_poll_option_max_chars="50"
|
||||
statuses_media_max_files="6"
|
||||
# conversion of old parameters
|
||||
registration_open=$(convert_bool "$registration_open")
|
||||
registration_approval=$(convert_bool "$registration_approval")
|
||||
registration_reason=$(convert_bool "$registration_reason")
|
||||
# fix db_user existence
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
|
||||
# registration of new parameters
|
||||
ynh_app_setting_set --app="$app" --key=client_max_body_size --value="$client_max_body_size"
|
||||
ynh_app_setting_set --app="$app" --key=media_image_max_size --value="$media_image_max_size"
|
||||
ynh_app_setting_set --app="$app" --key=media_video_max_size --value="$media_video_max_size"
|
||||
ynh_app_setting_set --app="$app" --key=media_description_min_chars --value="$media_description_min_chars"
|
||||
ynh_app_setting_set --app="$app" --key=media_description_max_chars --value="$media_description_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=media_remote_cache_days --value="$media_remote_cache_days"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_max_chars --value="$statuses_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_cw_max_chars --value="$statuses_cw_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_poll_max_options --value="$statuses_poll_max_options"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_poll_option_max_chars --value="$statuses_poll_option_max_chars"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$statuses_media_max_files"
|
||||
# registration of converted parameters
|
||||
ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$registration_open"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$registration_approval"
|
||||
ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$registration_reason"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -73,7 +132,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -87,7 +146,7 @@ then
|
|||
architecture=$(detect_arch)
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$architecture --keep="config.yaml"
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" --keep="config.yaml"
|
||||
fi
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
|
@ -98,7 +157,7 @@ fi
|
|||
# this will be treated as a security issue.
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
chown -R "$app:www-data" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -113,13 +172,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
|
@ -137,14 +190,7 @@ ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml"
|
|||
# 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
|
||||
chmod 400 "$final_path/config.yaml"
|
||||
chown $app:$app "$final_path/config.yaml"
|
||||
|
||||
### 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)
|
||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||
###
|
||||
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file"
|
||||
### ynh_store_file_checksum --file="$final_path/some_config_file"
|
||||
chown "$app:$app" "$final_path/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -169,14 +215,14 @@ ynh_use_logrotate --non-append
|
|||
#=================================================
|
||||
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
|
||||
#=================================================
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue