diff --git a/conf/config.yaml b/conf/config.yaml index 094440a..9cde08d 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -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 ##### diff --git a/conf/nginx.conf b/conf/nginx.conf index db3e9e6..a6db09c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -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; diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..4f3619a --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,164 @@ +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 configuration" + +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" +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 = "boolean" + +[gotosocial.accounts.approval_required] +ask.en = "Approval required?" +ask.fr = "Validation requise ?" +bind = "accounts-approval-required:__FINALPATH__/config.yaml" +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 = "boolean" + +[gotosocial.accounts.reason_required] +ask.en = "Reason required?" +ask.fr = "Motif requis ?" +bind = "accounts-reason-required:__FINALPATH__/config.yaml" +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 = "boolean" + +################# +#### 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" diff --git a/scripts/_common.sh b/scripts/_common.sh index d5c690b..4452969 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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 #================================================= diff --git a/scripts/install b/scripts/install index ecff842..cd7f545 100755 --- a/scripts/install +++ b/scripts/install @@ -24,48 +24,44 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +app=$YNH_APP_INSTANCE_NAME + domain=$YNH_APP_ARG_DOMAIN path_url="/" +client_max_body_size="100M" + admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL password=$YNH_APP_ARG_PASSWORD -registration_open=$YNH_APP_ARG_REGISTRATION_OPEN -registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL -registration_reason=$YNH_APP_ARG_REGISTRATION_REASON +# Config stuff: -### 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 +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 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 #================================================= @@ -78,6 +74,8 @@ 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=client_max_body_size --value=$client_max_body_size + 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 @@ -86,6 +84,18 @@ ynh_app_setting_set --app=$app --key=registration_open --value=$registration_ope 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,9 +103,6 @@ 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 @@ -105,9 +112,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= 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 #================================================= @@ -150,7 +154,7 @@ ynh_setup_source --dest_dir="$final_path" --source_id=$architecture # 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" @@ -164,21 +168,11 @@ 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 @@ -199,18 +193,6 @@ chown -R $app:www-data "$datadir" #================================================= 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 @@ -219,47 +201,14 @@ ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" 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" - #================================================= # 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 +216,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,28 +224,8 @@ 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) - #================================================= # CREATE ADMIN USER #================================================= @@ -316,9 +242,6 @@ 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" @@ -328,7 +251,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" #================================================= diff --git a/scripts/restore b/scripts/restore index c23fd76..ed15ecd 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,15 +34,29 @@ 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) +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) +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) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +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 diff --git a/scripts/upgrade b/scripts/upgrade index 3630a1b..fd800cb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,15 +22,29 @@ 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) +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=$(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) + 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) +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 @@ -67,6 +81,48 @@ ynh_script_progression --message="Stopping a systemd service..." 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") + # 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 #================================================= @@ -115,12 +171,6 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -#================================================= -# SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -139,13 +189,6 @@ ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" 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" - #================================================= # SETUP SYSTEMD #=================================================