mirror of
https://github.com/YunoHost-Apps/garage_ynh.git
synced 2024-09-03 18:36:32 +02:00
Merge branch 'testing' into version-2
This commit is contained in:
commit
f9025b970b
19 changed files with 86 additions and 522 deletions
|
@ -47,13 +47,17 @@ Garage is designed for storage clusters composed of nodes running at different p
|
|||
* This application consider that the weight of the node is the size reserved to garage in G
|
||||
* This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage.
|
||||
|
||||
# How to run commands for Garage
|
||||
1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory.
|
||||
2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`.
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: <https://garagehq.deuxfleurs.fr/>
|
||||
* Official user documentation: <https://garagehq.deuxfleurs.fr/documentation/quick-start/>
|
||||
* Official admin documentation: <https://garagehq.deuxfleurs.fr/documentation/quick-start/>
|
||||
* Upstream app code repository: <https://git.deuxfleurs.fr/Deuxfleurs/garage>
|
||||
* YunoHost documentation for this app: <https://yunohost.org/app_garage>
|
||||
* YunoHost Store: <https://apps.yunohost.org/app/garage>
|
||||
* Report a bug: <https://github.com/YunoHost-Apps/garage_ynh/issues>
|
||||
|
||||
## Developer info
|
||||
|
|
|
@ -47,13 +47,17 @@ Garage is designed for storage clusters composed of nodes running at different p
|
|||
* This application consider that the weight of the node is the size reserved to garage in G
|
||||
* This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage.
|
||||
|
||||
# How to run commands for Garage
|
||||
1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory.
|
||||
2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`.
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l’app : <https://garagehq.deuxfleurs.fr/>
|
||||
* Documentation officielle utilisateur : <https://garagehq.deuxfleurs.fr/documentation/quick-start/>
|
||||
* Documentation officielle de l’admin : <https://garagehq.deuxfleurs.fr/documentation/quick-start/>
|
||||
* Dépôt de code officiel de l’app : <https://git.deuxfleurs.fr/Deuxfleurs/garage>
|
||||
* Documentation YunoHost pour cette app : <https://yunohost.org/app_garage>
|
||||
* YunoHost Store: <https://apps.yunohost.org/app/garage>
|
||||
* Signaler un bug : <https://github.com/YunoHost-Apps/garage_ynh/issues>
|
||||
|
||||
## Informations pour les développeurs
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
if [ "$VIRTUALISATION" = "true" ]
|
||||
|
||||
# If we're inside a container
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
data_dir=__DATA_DIR__
|
||||
format=$1
|
||||
|
|
|
@ -8,5 +8,4 @@ app=__APP__
|
|||
[[ "$action" == "pre" ]] || exit 0
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="$pending_dir/../nginx/etc/nginx/conf.d/$domain.conf"
|
|
@ -17,16 +17,16 @@ StandardError=inherit
|
|||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
# .. but this should be a good baseline
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
__VIRT_PROTECTION__PrivateTmp=yes
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__PrivateTmp=yes
|
||||
#PrivateDevices=yes
|
||||
# RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
#DevicePolicy=closed
|
||||
__VIRT_PROTECTION__ProtectSystem=full
|
||||
__VIRT_PROTECTION__ProtectControlGroups=yes
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectSystem=full
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectControlGroups=yes
|
||||
#ProtectKernelModules=yes
|
||||
__VIRT_PROTECTION__ProtectKernelTunables=yes
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/bin/bash
|
||||
if [ "$VIRTUALISATION" = "true" ]
|
||||
|
||||
# If we're inside a container
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
data_dir=__DATA_DIR__
|
||||
data_dir=__DATA_DIR__
|
||||
nbd=$(cat $data_dir/nbd_index)
|
||||
umount /dev/nbd$nbd
|
||||
qemu-nbd --disconnect /dev/nbd$nbd
|
||||
|
|
|
@ -1,295 +0,0 @@
|
|||
|
||||
## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button
|
||||
## Those panels let user configure some params on their apps using a friendly interface,
|
||||
## and remove the need to manually edit files from the command line.
|
||||
|
||||
## From a packager perspective, this .toml is coupled to the scripts/config script,
|
||||
## which may be used to define custom getters/setters. However, most use cases
|
||||
## should be covered automagically by the core, thus it may not be necessary
|
||||
## to define a scripts/config at all!
|
||||
|
||||
## -----------------------------------------------------------------------------
|
||||
## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and
|
||||
## do not overwhelm the admin with tons of misunderstandable or advanced settings.
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
## The top level describe the entire config panels screen.
|
||||
|
||||
## The version is a required property.
|
||||
## Here a small reminder to associate config panel version with YunoHost version
|
||||
## | Config | YNH | Config panel small change log |
|
||||
## | ------ | --- | ------------------------------------------------------- |
|
||||
## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 |
|
||||
## | 1.0 | 4.3.x | The new config panel system with 'bind' property |
|
||||
version = "1.0"
|
||||
|
||||
## (optional) i18n property let you internationalize questions, however this feature
|
||||
## is only available in core configuration panel (like yunohost domain config).
|
||||
## So in app config panel this key is ignored for now, but you can internationalize
|
||||
## by using a lang dictionary (see property name bellow)
|
||||
# i18n = "prefix_translation_key"
|
||||
|
||||
################################################################################
|
||||
#### ABOUT PANELS
|
||||
################################################################################
|
||||
|
||||
## The next level describes web admin panels
|
||||
## You have to choose an ID for each panel, in this example the ID is "main"
|
||||
## Keep in mind this ID will be used in CLI to refer to your question, so choose
|
||||
## something short and meaningfull.
|
||||
## In the webadmin, each panel corresponds to a distinct tab / form
|
||||
[main]
|
||||
|
||||
## Define the label for your panel
|
||||
## Internationalization works similarly to the 'description' and 'ask' questions in the manifest
|
||||
# name.en = "Main configuration"
|
||||
# name.fr = "Configuration principale"
|
||||
|
||||
## (optional) If you need to trigger a service reload-or-restart after the user
|
||||
## change a question in this panel, you can add your service in the list.
|
||||
services = ["__APP__"]
|
||||
# or services = ["nginx", "__APP__"] to also reload-or-restart nginx
|
||||
|
||||
## (optional) This help properties is a short help displayed on the same line
|
||||
## than the panel title but not displayed in the tab.
|
||||
# help = ""
|
||||
|
||||
############################################################################
|
||||
#### ABOUT SECTIONS
|
||||
############################################################################
|
||||
|
||||
## A panel is composed of one or several sections.
|
||||
##
|
||||
## Sections are meant to group questions together when they correspond to
|
||||
## a same subtopic. This impacts the rendering in terms of CLI prompts
|
||||
## and HTML forms
|
||||
##
|
||||
## You should choose an ID for your section, and prefix it with the panel ID
|
||||
## (Be sure to not make a typo in the panel ID, which would implicitly create
|
||||
## an other entire panel)
|
||||
##
|
||||
## We use the context of pepettes_ynh as an example,
|
||||
## which is a simple donation form app written in python,
|
||||
## and for which the admin will want to edit the configuration
|
||||
[main.customization]
|
||||
|
||||
## (optional) Defining a proper title for sections is not mandatory
|
||||
## and depends on the exact rendering you're aiming for the CLI / webadmin
|
||||
name = ""
|
||||
|
||||
## (optional) This help properties is a short help displayed on the same line
|
||||
## than the section title, meant to provide additional details
|
||||
# help = ""
|
||||
|
||||
## (optional) As for panel, you can specify to trigger a service
|
||||
## reload-or-restart after the user change a question in this section.
|
||||
## This property is added to the panel property, it doesn't deactivate it.
|
||||
## So no need to replicate, the service list from panel services property.
|
||||
# services = []
|
||||
|
||||
## (optional) By default all questions are optionals, but you can specify a
|
||||
## default behaviour for question in the section
|
||||
##optional = false
|
||||
|
||||
## (optional) It's also possible with the 'visible' property to only
|
||||
## display the section depending on the user's answers to previous questions.
|
||||
##
|
||||
## Be careful that the 'visible' property should only refer to **previous** questions
|
||||
## Hence, it should not make sense to have a "visible" property on the very first section.
|
||||
##
|
||||
## Also, keep in mind that this feature only works in the webadmin and not in CLI
|
||||
## (therefore a user could be prompted in CLI for a question that may not be relevant)
|
||||
# visible = true
|
||||
|
||||
########################################################################
|
||||
#### ABOUT QUESTIONS
|
||||
########################################################################
|
||||
|
||||
## A section is compound of one or several questions.
|
||||
|
||||
## ---------------------------------------------------------------------
|
||||
## IMPORTANT: as for panel and section you have to choose an ID, but this
|
||||
## one should be unique in all this document, even if the question is in
|
||||
## an other panel.
|
||||
## ---------------------------------------------------------------------
|
||||
|
||||
## You can use same questions types and properties than in manifest.yml
|
||||
## install part. However, in YNH 4.3, a lot of change has been made to
|
||||
## extend availables questions types list.
|
||||
## See: TODO DOC LINK
|
||||
|
||||
[main.customization.weight]
|
||||
|
||||
## (required) The ask property is equivalent to the ask property in
|
||||
## the manifest. However, in config panels, questions are displayed on the
|
||||
## left side and therefore have less space to be rendered. Therefore,
|
||||
## it is better to use a short question, and use the "help" property to
|
||||
## provide additional details if necessary.
|
||||
ask.en = "allocated space"
|
||||
|
||||
## (required) The type property indicates how the question should be
|
||||
## displayed, validated and managed. Some types have specific properties.
|
||||
##
|
||||
## Types available: string, boolean, number, range, text, password, path
|
||||
## email, url, date, time, color, select, domain, user, tags, file.
|
||||
##
|
||||
## For a complete list with specific properties, see: TODO DOC LINK
|
||||
type = "number"
|
||||
|
||||
########################################################################
|
||||
#### ABOUT THE BIND PROPERTY
|
||||
########################################################################
|
||||
|
||||
## (recommended) 'bind' property is a powerful feature that let you
|
||||
## configure how and where the data will be read, validated and written.
|
||||
|
||||
## By default, 'bind property is in "settings" mode, it means it will
|
||||
## **only** read and write the value in application settings file.
|
||||
## bind = "settings"
|
||||
|
||||
## However, settings usually correspond to key/values in actual app configurations
|
||||
## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost
|
||||
## will automagically find a line with "KEY=VALUE" in FILENAME
|
||||
## (with the adequate separator between KEY and VALUE)
|
||||
##
|
||||
## YunoHost will then use this value for the read/get operation.
|
||||
## During write/set operations, YunoHost will overwrite the value
|
||||
## in **both** FILENAME and in the app's settings.yml
|
||||
|
||||
## Configuration file format supported: yaml, toml, json, ini, env, php,
|
||||
## python. The feature probably works with others formats, but should be tested carefully.
|
||||
|
||||
## Note that this feature only works with relatively simple cases
|
||||
## such as `KEY: VALUE`, but won't properly work with
|
||||
## complex data structures like multilin array/lists or dictionnaries.
|
||||
## It also doesn't work with XML format, custom config function call, php define(), ...
|
||||
|
||||
## More info on TODO
|
||||
# bind = ":/var/www/__APP__/settings.py"
|
||||
|
||||
|
||||
## By default, bind = ":FILENAME" will use the question ID as KEY
|
||||
## ... but the question ID may sometime not be the exact KEY name in the configuration file.
|
||||
##
|
||||
## In particular, in pepettes, the python variable is 'name' and not 'project_name'
|
||||
## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 )
|
||||
##
|
||||
## In that case, the key name can be specified before the column ':'
|
||||
|
||||
bind = "name:/var/www/__APP__/settings.py"
|
||||
|
||||
## ---------------------------------------------------------------------
|
||||
## IMPORTANT: other 'bind' mode exists:
|
||||
##
|
||||
## bind = "FILENAME" (with no column character before FILENAME)
|
||||
## may be used to bind to the **entire file content** (instead of a single KEY/VALUE)
|
||||
## This could be used to expose an entire configuration file, or binary files such as images
|
||||
## For example:
|
||||
## bind = "/var/www/__APP__/img/logo.png"
|
||||
##
|
||||
## bind = "null" can be used to disable reading / writing in settings.
|
||||
## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting
|
||||
## In this mode, you are expected to define custom getter/setters/validators in scripts/config:
|
||||
##
|
||||
## getter: get__QUESTIONID()
|
||||
## setter: set__QUESTIONID()
|
||||
## validator: validate__QUESTIONID()
|
||||
##
|
||||
## You can also specify a common getter / setter / validator, with the
|
||||
## function 'bind' mode, for example here it will try to run
|
||||
## get__array_settings() first.
|
||||
# bind = "array_settings()"
|
||||
## ---------------------------------------------------------------------
|
||||
|
||||
## ---------------------------------------------------------------------
|
||||
## IMPORTANT: with the exception of bind=null questions,
|
||||
## question IDs should almost **always** correspond to an app setting
|
||||
## initialized / reused during install/upgrade.
|
||||
## Not doing so may result in inconsistencies between the config panel mechanism
|
||||
## and the use of ynh_add_config
|
||||
## ---------------------------------------------------------------------
|
||||
|
||||
########################################################################
|
||||
#### OTHER GENERIC PROPERTY FOR QUESTIONS
|
||||
########################################################################
|
||||
|
||||
## (optional) An help text for the question
|
||||
help = "Fill the name of the project which will received donation"
|
||||
|
||||
## (optional) An example display as placeholder in web form
|
||||
# example = "YunoHost"
|
||||
|
||||
## (optional) set to true in order to redact the value in operation logs
|
||||
# redact = false
|
||||
|
||||
## (optional) A validation pattern
|
||||
## ---------------------------------------------------------------------
|
||||
## IMPORTANT: your pattern should be between simple quote, not double.
|
||||
## ---------------------------------------------------------------------
|
||||
pattern.regexp = '^\w{3,30}$'
|
||||
pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted"
|
||||
|
||||
## Note: visible and optional properties are also available for questions
|
||||
|
||||
|
||||
[main.customization.contact_url]
|
||||
ask = "Contact url"
|
||||
type = "url"
|
||||
example = "mailto: contact@example.org"
|
||||
help = "mailto: accepted"
|
||||
pattern.regexp = '^mailto:[^@]+@[^@]+|https://$'
|
||||
pattern.error = "Should be https or mailto:"
|
||||
bind = ":/var/www/__APP__/settings.py"
|
||||
|
||||
[main.customization.logo]
|
||||
ask = "Logo"
|
||||
type = "file"
|
||||
accept = ".png"
|
||||
help = "Fill with an already resized logo"
|
||||
bind = "__FINALPATH__/img/logo.png"
|
||||
|
||||
[main.customization.favicon]
|
||||
ask = "Favicon"
|
||||
type = "file"
|
||||
accept = ".png"
|
||||
help = "Fill with an already sized favicon"
|
||||
bind = "__FINALPATH__/img/favicon.png"
|
||||
|
||||
|
||||
[main.stripe]
|
||||
name = "Stripe general info"
|
||||
optional = false
|
||||
|
||||
# The next alert is overwrited with a getter from the config script
|
||||
[main.stripe.amount]
|
||||
ask = "Donation in the month : XX €
|
||||
type = "alert"
|
||||
style = "success"
|
||||
|
||||
[main.stripe.publishable_key]
|
||||
ask = "Publishable key"
|
||||
type = "string"
|
||||
redact = true
|
||||
help = "Indicate here the stripe publishable key"
|
||||
bind = ":/var/www/__APP__/settings.py"
|
||||
|
||||
[main.stripe.secret_key]
|
||||
ask = "Secret key"
|
||||
type = "string"
|
||||
redact = true
|
||||
help = "Indicate here the stripe secret key"
|
||||
bind = ":/var/www/__APP__/settings.py"
|
||||
|
||||
[main.stripe.prices]
|
||||
ask = "Prices ID"
|
||||
type = "tags"
|
||||
help = """\
|
||||
Indicates here the prices ID of donation products you created in stripe interfaces. \
|
||||
Go on [Stripe products](https://dashboard.stripe.com/products) to create those donation products. \
|
||||
Fill it tag with 'FREQUENCY/CURRENCY/PRICE_ID' \
|
||||
FREQUENCY: 'one_time' or 'recuring' \
|
||||
CURRENCY: 'EUR' or 'USD' \
|
||||
PRICE_ID: ID from stripe interfaces starting with 'price_' \
|
||||
"""
|
||||
pattern.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$'
|
||||
pattern.error = "Please respect the format describe in help text for each price ID"
|
|
@ -6,3 +6,7 @@
|
|||
* This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it.
|
||||
* This application consider that the weight of the node is the size reserved to garage in G
|
||||
* This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage.
|
||||
|
||||
# How to run commands for Garage
|
||||
1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory.
|
||||
2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`.
|
||||
|
|
|
@ -17,7 +17,7 @@ userdoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/"
|
|||
code = "https://git.deuxfleurs.fr/Deuxfleurs/garage"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.1.19"
|
||||
yunohost = ">= 11.2"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
|
@ -80,4 +80,4 @@ ram.runtime = "50M"
|
|||
main.url = "/"
|
||||
|
||||
[resources.apt]
|
||||
packages = "qemu-utils e2fsprogs"
|
||||
packages = "qemu-utils, e2fsprogs"
|
||||
|
|
|
@ -3,41 +3,23 @@
|
|||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
pkg_dependencies_virtualisation="qemu-utils e2fsprogs"
|
||||
|
||||
GARAGE_VERSION="0.8.2"
|
||||
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
system_is_inside_container="true"
|
||||
# used to comment systemd isolation to allow mount disk
|
||||
comment_if_system_is_inside_container="#"
|
||||
else
|
||||
system_is_inside_container="false"
|
||||
comment_if_system_is_inside_container=""
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
|
||||
GARAGE_VERSION="0.8.0"
|
||||
|
||||
# inspired by restic helper
|
||||
install_garage () {
|
||||
architecture=$(uname -m)
|
||||
arch=''
|
||||
case $architecture in
|
||||
i386|i686)
|
||||
arch="i686"
|
||||
;;
|
||||
x86_64)
|
||||
arch=x86_64
|
||||
;;
|
||||
armv*)
|
||||
arch=armv6l
|
||||
;;
|
||||
aarch64)
|
||||
arch=aarch64
|
||||
;;
|
||||
*)
|
||||
echo
|
||||
ynh_die --message="Unsupported architecture \"$architecture\""
|
||||
;;
|
||||
esac
|
||||
wget https://garagehq.deuxfleurs.fr/_releases/v$GARAGE_VERSION/$arch-unknown-linux-musl/garage -O garage 2>&1 >/dev/null
|
||||
chmod +x garage
|
||||
}
|
||||
|
||||
garage_connect() {
|
||||
local command="$1"
|
||||
local peer="$2"
|
||||
|
@ -74,51 +56,6 @@ apply_layout() {
|
|||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
ynh_send_readme_to_admin() {
|
||||
local app_message="${1:-...No specific information...}"
|
||||
local recipients="${2:-root}"
|
||||
|
||||
# Retrieve the email of users
|
||||
find_mails () {
|
||||
local list_mails="$1"
|
||||
local mail
|
||||
local recipients=" "
|
||||
# Read each mail in argument
|
||||
for mail in $list_mails
|
||||
do
|
||||
# Keep root or a real email address as it is
|
||||
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
|
||||
then
|
||||
recipients="$recipients $mail"
|
||||
else
|
||||
# But replace an user name without a domain after by its email
|
||||
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
|
||||
then
|
||||
recipients="$recipients $mail"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$recipients"
|
||||
}
|
||||
recipients=$(find_mails "$recipients")
|
||||
|
||||
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
|
||||
|
||||
local mail_message="This is an automated message from your beloved YunoHost server.
|
||||
Specific information for the application $app.
|
||||
$app_message"
|
||||
|
||||
# Define binary to use for mail command
|
||||
if [ -e /usr/bin/bsd-mailx ]
|
||||
then
|
||||
local mail_bin=/usr/bin/bsd-mailx
|
||||
else
|
||||
local mail_bin=/usr/bin/mail.mailutils
|
||||
fi
|
||||
|
||||
# Send the email to the recipients
|
||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||
}
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -10,63 +10,23 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#REMOVEME? rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
||||
#REMOVEME? port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
||||
#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||
#REMOVEME? bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
||||
|
||||
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||
### to be backuped and not an actual copy of any file. The actual backup that
|
||||
### creates and fill the archive with the files happens in the core after this
|
||||
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
#ynh_backup --src_path="$data_dir/data" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
|
@ -87,9 +47,6 @@ ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
|||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
|
||||
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
|
@ -30,7 +30,7 @@ ynh_change_url_nginx_config
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --time
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
|
|
|
@ -16,9 +16,8 @@ ynh_abort_if_errors
|
|||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
node_id=$(ynh_app_setting_get $app node_id)
|
||||
virtualisation=$(ynh_app_setting_get $app virtualisation)
|
||||
datadir=$(ynh_app_setting_get $app datadir)
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
nbd_index=$(cat $datadir/nbd_index)
|
||||
fi
|
||||
|
@ -29,7 +28,7 @@ get__weight() {
|
|||
}
|
||||
|
||||
set__weight() {
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
systemctl stop $app
|
||||
old_weight="$(ynh_app_setting_get --app=$app --key=weight)"
|
||||
|
|
|
@ -46,11 +46,10 @@ ynh_app_setting_set --app=$app --key=virtualisation --value=$virtualisation
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret
|
||||
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
||||
ynh_app_setting_set --app=$app --key=weight --value=$weight
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
|
@ -84,7 +83,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="mount_disk.sh" --destination="$install_dir/mount_disk.sh"
|
||||
ynh_add_config --template="umount_disk.sh" --destination="$install_dir/umount_disk.sh"
|
||||
|
@ -131,6 +130,7 @@ ynh_script_progression --message="adding regen-conf hook..." --weight=1
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action="reload"
|
||||
|
||||
ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
||||
yunohost tools regen-conf nginx
|
||||
|
||||
#=================================================
|
||||
|
@ -169,7 +169,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
#=================================================
|
||||
# CONFIGURE GARAGE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring garage..." --weight=1
|
||||
ynh_script_progression --message="Configuring garage..."
|
||||
|
||||
garage_command="$install_dir/garage -c $install_dir/garage.toml"
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ then
|
|||
ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough"
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
@ -39,14 +38,14 @@ fi
|
|||
# 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
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
@ -54,22 +53,23 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
#=================================================
|
||||
# REMOVE VIRTUAL DISK
|
||||
#=================================================
|
||||
ynh_script_progression --message="umount virtual disk..." --weight=1
|
||||
ynh_script_progression --message="umount virtual disk..."
|
||||
|
||||
# Remove the app directory securely
|
||||
$install_dir/umount_disk.sh
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -78,20 +78,10 @@ fi
|
|||
# Remove the app directory securely
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DATA DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||
#REMOVEME? ynh_secure_remove --file="$data_dir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX HOOK
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -100,30 +90,12 @@ ynh_remove_nginx_config
|
|||
ynh_replace_string --replace_string="server_name $domain" --match_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
#REMOVEME? ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
@ -131,16 +103,9 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
#REMOVEME? ynh_system_user_delete --username=$app
|
||||
|
||||
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
||||
yunohost tools regen-conf nginx
|
||||
ynh_systemd_action --service_name=nginx --action="reload"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
|
@ -24,27 +24,17 @@ chown -R $app:$app "$install_dir"
|
|||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
ynh_script_progression --message="Restoring the data directory..."
|
||||
|
||||
mkdir -p "$data_dir/data"
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
export VIRTUALISATION=true
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
||||
# to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size.
|
||||
qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G
|
||||
$install_dir/mount_disk.sh true
|
||||
fi
|
||||
|
||||
|
||||
# # 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 -
|
||||
# this will be treated as a security issue.
|
||||
chmod 750 "$data_dir"
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R $app:$app "$data_dir"
|
||||
|
@ -54,25 +44,26 @@ chown -R $app:$app "$data_dir"
|
|||
#=================================================
|
||||
|
||||
# Open the port
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
||||
ynh_script_progression --message="Configuring firewall..."
|
||||
ynh_exec_warn_less yunohost firewall allow TCP $port
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
#add wildcard subdomain
|
||||
|
||||
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
||||
yunohost tools regen-conf nginx
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action="reload"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
@ -80,21 +71,21 @@ systemctl enable $app.service --quiet
|
|||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
#recreate log folder
|
||||
mkdir /var/log/$app
|
||||
|
@ -122,7 +113,7 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
|
@ -12,19 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#REMOVEME? rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
||||
#REMOVEME? port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
||||
#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||
#REMOVEME? bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
if [ "$virtualisation" = "true" ] ;
|
||||
then
|
||||
|
@ -44,7 +32,7 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
|
@ -79,7 +67,7 @@ chown -R $app:$app "$install_dir"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
@ -87,7 +75,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
@ -97,22 +85,33 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
### Same as during install
|
||||
###
|
||||
### The file will automatically be backed-up if it's found to be manually modified (because
|
||||
### ynh_add_config keeps track of the file's checksum)
|
||||
ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
|
|
2
sources/extra_files/app/.gitignore
vendored
2
sources/extra_files/app/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
Loading…
Add table
Reference in a new issue