mirror of
https://github.com/YunoHost-Apps/garage_ynh.git
synced 2024-09-03 18:36:32 +02:00
v2
This commit is contained in:
parent
78b8464aa1
commit
dc3d70d531
11 changed files with 271 additions and 198 deletions
|
@ -1,5 +1,5 @@
|
||||||
metadata_dir = "/opt/yunohost/__APP__/metadata"
|
metadata_dir = "/opt/yunohost/__APP__/metadata"
|
||||||
data_dir = "__DATADIR__/data"
|
data_dir = "__DATA_DIR__/data"
|
||||||
|
|
||||||
block_size = 1048576
|
block_size = 1048576
|
||||||
block_manager_background_tranquility = 2
|
block_manager_background_tranquility = 2
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [ "$VIRTUALISATION" = "true" ]
|
if [ "$VIRTUALISATION" = "true" ]
|
||||||
then
|
then
|
||||||
datadir=__DATADIR__
|
data_dir=__DATA_DIR__
|
||||||
format=$1
|
format=$1
|
||||||
i=0
|
i=0
|
||||||
while fdisk -l /dev/nbd$i 1> /dev/null 2> /dev/null
|
while fdisk -l /dev/nbd$i 1> /dev/null 2> /dev/null
|
||||||
do
|
do
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
done
|
done
|
||||||
echo $i > $datadir/nbd_index
|
echo $i > $data_dir/nbd_index
|
||||||
modprobe nbd max_part=$(( i + 1 ))
|
modprobe nbd max_part=$(( i + 1 ))
|
||||||
qemu-nbd --connect /dev/nbd$i $datadir/garage_data.qcow2
|
qemu-nbd --connect /dev/nbd$i $data_dir/garage_data.qcow2
|
||||||
if [[ "$format" = "true" ]]
|
if [[ "$format" = "true" ]]
|
||||||
then
|
then
|
||||||
echo "formatting /dev/nbd$i"
|
echo "formatting /dev/nbd$i"
|
||||||
mkfs.ext4 /dev/nbd$i
|
mkfs.ext4 /dev/nbd$i
|
||||||
fi
|
fi
|
||||||
mkdir -p $datadir/data
|
mkdir -p $data_dir/data
|
||||||
chown __APP__:__APP__ $datadir/data
|
chown __APP__:__APP__ $data_dir/data
|
||||||
mount /dev/nbd$i $datadir/data/
|
mount /dev/nbd$i $data_dir/data/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ Wants=network-online.target
|
||||||
[Service]
|
[Service]
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1'
|
Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1'
|
||||||
ExecStartPre=+__FINALPATH__/mount_disk.sh
|
ExecStartPre=+__INSTALL_DIR__/mount_disk.sh
|
||||||
ExecStart=__FINALPATH__/garage -c __FINALPATH__/garage.toml server
|
ExecStart=__INSTALL_DIR__/garage -c __INSTALL_DIR__/garage.toml server
|
||||||
ExecStopPost=+__FINALPATH__/umount_disk.sh
|
ExecStopPost=+__INSTALL_DIR__/umount_disk.sh
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [ "$VIRTUALISATION" = "true" ]
|
if [ "$VIRTUALISATION" = "true" ]
|
||||||
then
|
then
|
||||||
datadir=__DATADIR__
|
data_dir=__DATA_DIR__
|
||||||
nbd=$(cat $datadir/nbd_index)
|
nbd=$(cat $data_dir/nbd_index)
|
||||||
umount /dev/nbd$nbd
|
umount /dev/nbd$nbd
|
||||||
qemu-nbd --disconnect /dev/nbd$nbd
|
qemu-nbd --disconnect /dev/nbd$nbd
|
||||||
fi
|
fi
|
||||||
|
|
71
manifest.toml
Normal file
71
manifest.toml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "garage"
|
||||||
|
name = "Garage"
|
||||||
|
description.en = "S3 storage"
|
||||||
|
description.fr = "stockage S3"
|
||||||
|
|
||||||
|
version = "0.8.0~ynh4"
|
||||||
|
|
||||||
|
maintainers = ["oiseauroch"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "AGPL-3.0-only"
|
||||||
|
website = "https://garagehq.deuxfleurs.fr/"
|
||||||
|
admindoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/"
|
||||||
|
userdoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/"
|
||||||
|
code = "https://git.deuxfleurs.fr/Deuxfleurs/garage"
|
||||||
|
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||||
|
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 4.3.0"
|
||||||
|
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||||
|
multi_instance = true
|
||||||
|
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
|
||||||
|
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
|
||||||
|
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||||
|
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "domain"
|
||||||
|
full_domain = true
|
||||||
|
|
||||||
|
[install.rpc_secret]
|
||||||
|
ask.en = "UUID of the network (rpc-secret) "
|
||||||
|
ask.fr = "UUID de l'ilot (rpc-secret)"
|
||||||
|
type = "string"
|
||||||
|
optional = true
|
||||||
|
example = "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec"
|
||||||
|
|
||||||
|
[install.bootstrap_peers]
|
||||||
|
ask.en = "friend server id"
|
||||||
|
ask.fr = "serveur ami"
|
||||||
|
type = "string"
|
||||||
|
example = "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@127.0.0.1:3901"
|
||||||
|
optional = true
|
||||||
|
|
||||||
|
[install.weight]
|
||||||
|
ask.en = "number of G to allow"
|
||||||
|
ask.fr = "nombre de G à allouer"
|
||||||
|
type = "string"
|
||||||
|
|
||||||
|
[install.datadir]
|
||||||
|
ask.en = "data location"
|
||||||
|
ask.fr = "dossier de stockage des données"
|
||||||
|
type = "string"
|
||||||
|
default = "/home/yunohost.app/__APP_NAME__/data"
|
||||||
|
exemple = "/opt/yunohost/garage/data"
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.data_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
|
@ -14,29 +14,29 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Loading installation settings..."
|
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
#REMOVEME? rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
||||||
port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
#REMOVEME? port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
||||||
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
#REMOVEME? bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
||||||
|
|
||||||
final_path=/opt/yunohost/$app
|
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -51,13 +51,13 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATA DIR
|
# BACKUP THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#ynh_backup --src_path="$datadir/data" --is_big
|
#ynh_backup --src_path="$data_dir/data" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -13,58 +13,58 @@ source /usr/share/yunohost/helpers
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
new_path=$YNH_APP_NEW_PATH
|
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
|
|
||||||
# Add settings here as needed by your application
|
# Add settings here as needed by your application
|
||||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? #db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
#db_user=$db_name
|
#db_user=$db_name
|
||||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
#REMOVEME? #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
|
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
change_domain=0
|
#REMOVEME? change_domain=0
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||||
then
|
then
|
||||||
change_domain=1
|
#REMOVEME? change_domain=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_path=0
|
#REMOVEME? change_path=0
|
||||||
if [ "$old_path" != "$new_path" ]
|
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||||
then
|
then
|
||||||
change_path=1
|
#REMOVEME? change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -81,28 +81,30 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
|
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
# Change the path in the NGINX config file
|
# Change the path in the NGINX config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original NGINX config file if modified
|
# Make a backup of the original NGINX config file if modified
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for NGINX helper
|
# Set global variables for NGINX helper
|
||||||
domain="$old_domain"
|
#REMOVEME? domain="$old_domain"
|
||||||
path_url="$new_path"
|
#REMOVEME? path="$new_path"
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
#REMOVEME? ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for NGINX
|
# Change the domain for NGINX
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -123,9 +125,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
114
scripts/install
114
scripts/install
|
@ -13,35 +13,35 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
||||||
rpc_secret=$YNH_APP_ARG_RPC_SECRET
|
#REMOVEME? rpc_secret=$YNH_APP_ARG_RPC_SECRET
|
||||||
bootstrap_peers=$YNH_APP_ARG_BOOTSTRAP_PEERS
|
#REMOVEME? bootstrap_peers=$YNH_APP_ARG_BOOTSTRAP_PEERS
|
||||||
datadir=$YNH_APP_ARG_DATADIR
|
#REMOVEME? data_dir=$YNH_APP_ARG_DATA_DIR
|
||||||
weight=$YNH_APP_ARG_WEIGHT
|
#REMOVEME? weight=$YNH_APP_ARG_WEIGHT
|
||||||
|
|
||||||
|
|
||||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
### 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 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 instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2"...)
|
||||||
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
#REMOVEME? ### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
#REMOVEME? ### - 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
|
#REMOVEME? ### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
### - ynhexample__{N} for the subsequent installations, with N=3,4...
|
### - ynhexample__{N} for the subsequent installations, with N=3,4...
|
||||||
### The app instance name is probably what interests you most, since this is
|
### 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,
|
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
### db names...
|
### db names...
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
@ -54,12 +54,12 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
### Use the execution time, given by , to estimate the weight of a step.
|
### Use the execution time, given by , 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.
|
### 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.
|
### 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
|
#REMOVEME? 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 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"
|
### 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=/opt/yunohost/$app
|
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
if [[ -n "$rpc_secret" ]]
|
if [[ -n "$rpc_secret" ]]
|
||||||
then
|
then
|
||||||
|
@ -72,13 +72,13 @@ then
|
||||||
echo "$bootstrap_peers" | grep -E '[0-9a-f]{64}@((\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}):[0-9]{1,4}' || ynh_die --message="friend server id must have id with the following form : 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@192.168.1.1:1234 or 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@example.tld:1234"
|
echo "$bootstrap_peers" | grep -E '[0-9a-f]{64}@((\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}):[0-9]{1,4}' || ynh_die --message="friend server id must have id with the following form : 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@192.168.1.1:1234 or 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@example.tld:1234"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$datadir" = "/home/yunohost.app/__APP_NAME__/data" ]
|
if [ "$data_dir" = "/home/yunohost.app/__APP_NAME__/data" ]
|
||||||
then
|
then
|
||||||
datadir="/home/yunohost.app/$app/data"
|
data_dir="/home/yunohost.app/$app/data"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url="/"
|
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path="/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOOKING FOR VIRTUALISATION
|
# LOOKING FOR VIRTUALISATION
|
||||||
|
@ -102,11 +102,11 @@ ynh_app_setting_set --app=$app --key=virtualisation --value=$virtualisation
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret
|
ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
||||||
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
||||||
ynh_app_setting_set --app=$app --key=weight --value=$weight
|
ynh_app_setting_set --app=$app --key=weight --value=$weight
|
||||||
|
|
||||||
|
@ -119,16 +119,16 @@ ynh_app_setting_set --app=$app --key=weight --value=$weight
|
||||||
ynh_script_progression --message="Finding available ports..." --weight=1
|
ynh_script_progression --message="Finding available ports..." --weight=1
|
||||||
|
|
||||||
### Use these lines if you have to open a port for the application
|
### Use these lines if you have to open a port for the application
|
||||||
### `ynh_find_port` will find the first available port starting from the given port.
|
#REMOVEME? ### `ynh_find_port` will find the first available port starting from the given port.
|
||||||
### If you're not using these lines:
|
### If you're not using these lines:
|
||||||
### - Remove the section "CLOSE A PORT" in the remove script
|
### - Remove the section "CLOSE A PORT" in the remove script
|
||||||
|
|
||||||
# Find an available port
|
# Find an available port
|
||||||
|
|
||||||
port=$(ynh_find_port --port=4000)
|
#REMOVEME? port=$(ynh_find_port --port=4000)
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
port_api=$(ynh_find_port --port=5000)
|
#REMOVEME? port_api=$(ynh_find_port --port=5000)
|
||||||
ynh_app_setting_set --app=$app --key=port_api --value=$port_api
|
#REMOVEME? ynh_app_setting_set --app=$app --key=port_api --value=$port_api
|
||||||
|
|
||||||
|
|
||||||
# Optional: Expose this port publicly
|
# Optional: Expose this port publicly
|
||||||
|
@ -142,9 +142,9 @@ ynh_app_setting_set --app=$app --key=port_api --value=$port_api
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
#REMOVEME? ### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||||
### Those deb packages will be installed as dependencies of this package.
|
### Those deb packages will be installed as dependencies of this package.
|
||||||
### If you're not using this helper:
|
### If you're not using this helper:
|
||||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||||
|
@ -153,15 +153,15 @@ ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
if [ "$virtualisation" = "true" ]
|
if [ "$virtualisation" = "true" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
||||||
fi
|
fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -172,11 +172,11 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
### downloaded from an upstream source, like a git repository.
|
### downloaded from an upstream source, like a git repository.
|
||||||
### `ynh_setup_source` use the file conf/app.src
|
### `ynh_setup_source` use the file conf/app.src
|
||||||
|
|
||||||
mkdir -p $final_path
|
mkdir -p $install_dir
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
pushd $final_path
|
pushd $install_dir
|
||||||
install_garage
|
install_garage
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
@ -186,9 +186,9 @@ popd
|
||||||
# files in some cases.
|
# 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.
|
# this will be treated as a security issue.
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -219,23 +219,23 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
###
|
###
|
||||||
### Check the documentation of `ynh_add_config` for more info.
|
### Check the documentation of `ynh_add_config` for more info.
|
||||||
|
|
||||||
ynh_add_config --template="mount_disk.sh" --destination="$final_path/mount_disk.sh"
|
ynh_add_config --template="mount_disk.sh" --destination="$install_dir/mount_disk.sh"
|
||||||
ynh_add_config --template="umount_disk.sh" --destination="$final_path/umount_disk.sh"
|
ynh_add_config --template="umount_disk.sh" --destination="$install_dir/umount_disk.sh"
|
||||||
ynh_add_config --template="garage.toml" --destination="$final_path/garage.toml"
|
ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml"
|
||||||
chmod +x "$final_path/mount_disk.sh" "$final_path/umount_disk.sh"
|
chmod +x "$install_dir/mount_disk.sh" "$install_dir/umount_disk.sh"
|
||||||
|
|
||||||
# FIXME: this should be handled by the core in the future
|
# FIXME: this should be handled by the core in the future
|
||||||
# You may need to use chmod 600 instead of 400,
|
# You may need to use chmod 600 instead of 400,
|
||||||
# for example if the app is expected to be able to modify its own config
|
# for example if the app is expected to be able to modify its own config
|
||||||
chmod 600 "$final_path/garage.toml"
|
chmod 600 "$install_dir/garage.toml"
|
||||||
chown $app:$app "$final_path/garage.toml"
|
chown $app:$app "$install_dir/garage.toml"
|
||||||
|
|
||||||
### For more complex cases where you want to replace stuff using regexes,
|
### For more complex cases where you want to replace stuff using regexes,
|
||||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
### 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_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||||
### ynh_store_file_checksum --file="$final_path/some_config_file"
|
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -254,9 +254,9 @@ fi
|
||||||
### - Remove the section "RESTORE THE DATA DIRECTORY" in the restore script
|
### - Remove the section "RESTORE THE DATA DIRECTORY" in the restore script
|
||||||
### - As well as the section "REMOVE DATA DIR" in the remove script
|
### - As well as the section "REMOVE DATA DIR" in the remove script
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
||||||
|
|
||||||
mkdir -p $datadir/data
|
mkdir -p $data_dir/data
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# create data partition
|
# create data partition
|
||||||
|
@ -265,8 +265,8 @@ mkdir -p $datadir/data
|
||||||
if [ "$virtualisation" = "true" ]
|
if [ "$virtualisation" = "true" ]
|
||||||
then
|
then
|
||||||
# to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size.
|
# 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 $datadir/garage_data.qcow2 "$weight"G
|
qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G
|
||||||
VIRTUALISATION=true $final_path/mount_disk.sh true
|
VIRTUALISATION=true $install_dir/mount_disk.sh true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# FIXME: this should be managed by the core in the future
|
# FIXME: this should be managed by the core in the future
|
||||||
|
@ -275,13 +275,13 @@ fi
|
||||||
# files in some cases.
|
# 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.
|
# this will be treated as a security issue.
|
||||||
chmod 750 "$datadir"
|
chmod 750 "$data_dir"
|
||||||
chmod -R o-rwx "$datadir"
|
chmod -R o-rwx "$data_dir"
|
||||||
chown -R $app:$app "$datadir"
|
chown -R $app:$app "$data_dir"
|
||||||
|
|
||||||
if [ "$virtualisation" = "true" ]
|
if [ "$virtualisation" = "true" ]
|
||||||
then
|
then
|
||||||
VIRTUALISATION=true $final_path/umount_disk.sh
|
VIRTUALISATION=true $install_dir/umount_disk.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -387,18 +387,18 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||||
|
|
||||||
# Everyone can access the app.
|
# Everyone can access the app.
|
||||||
# The "main" permission is automatically created before the install script.
|
# The "main" permission is automatically created before the install script.
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -406,7 +406,7 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring garage..." --weight=1
|
ynh_script_progression --message="Configuring garage..." --weight=1
|
||||||
|
|
||||||
garage_command="$final_path/garage -c $final_path/garage.toml"
|
garage_command="$install_dir/garage -c $install_dir/garage.toml"
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
# sometimes server need some time to start
|
# sometimes server need some time to start
|
||||||
|
|
|
@ -12,20 +12,20 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
#REMOVEME? rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
||||||
port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
#REMOVEME? port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
||||||
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
#REMOVEME? bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
||||||
node_id=$(ynh_app_setting_get --app=$app --key=node_id)
|
#REMOVEME? node_id=$(ynh_app_setting_get --app=$app --key=node_id)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
#REMOVEME? virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
||||||
if [ "$virtualisation" = "true" ]
|
if [ "$virtualisation" = "true" ]
|
||||||
then
|
then
|
||||||
export VIRTUALISTATION=true
|
export VIRTUALISTATION=true
|
||||||
|
@ -33,9 +33,9 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NODE CONFIGURATION
|
# REMOVE NODE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
$final_path/garage -c $final_path/garage.toml layout remove "$node_id"
|
$install_dir/garage -c $install_dir/garage.toml layout remove "$node_id"
|
||||||
|
|
||||||
apply_layout "$final_path/garage -c $final_path/garage.toml "
|
apply_layout "$install_dir/garage -c $install_dir/garage.toml "
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
then
|
then
|
||||||
ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough"
|
ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough"
|
||||||
|
@ -80,21 +80,21 @@ then
|
||||||
ynh_script_progression --message="umount virtual disk..." --weight=1
|
ynh_script_progression --message="umount virtual disk..." --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
$final_path/umount_disk.sh
|
$install_dir/umount_disk.sh
|
||||||
fi
|
fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DATA DIR
|
# REMOVE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||||
ynh_secure_remove --file="$datadir"
|
#REMOVEME? ynh_secure_remove --file="$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX HOOK
|
# REMOVE NGINX HOOK
|
||||||
|
@ -115,10 +115,10 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
#REMOVEME? ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
|
@ -146,10 +146,10 @@ ynh_secure_remove --file="/var/log/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
#REMOVEME? ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
|
||||||
yunohost tools regen-conf nginx
|
yunohost tools regen-conf nginx
|
||||||
|
|
|
@ -14,53 +14,53 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
#REMOVEME? virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
||||||
bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
#REMOVEME? bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
node_id=$(ynh_app_setting_get --app=$app --key=node_id)
|
#REMOVEME? node_id=$(ynh_app_setting_get --app=$app --key=node_id)
|
||||||
weight=$(ynh_app_setting_get --app=$app --key=weight)
|
#REMOVEME? weight=$(ynh_app_setting_get --app=$app --key=weight)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
test ! -d $final_path \
|
#REMOVEME? test ! -d $install_dir \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $install_dir "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# 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..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
# FIXME: this should be managed by the core in the future
|
# FIXME: this should be managed by the core in the future
|
||||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||||
|
@ -68,25 +68,25 @@ ynh_restore_file --origin_path="$final_path"
|
||||||
# files in some cases.
|
# 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.
|
# this will be treated as a security issue.
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||||
|
|
||||||
mkdir -p "$datadir/data"
|
mkdir -p "$data_dir/data"
|
||||||
|
|
||||||
if [ "$virtualisation" = "true" ]
|
if [ "$virtualisation" = "true" ]
|
||||||
then
|
then
|
||||||
export VIRTUALISATION=true
|
export VIRTUALISATION=true
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
#REMOVEME? 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.
|
# 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 $datadir/garage_data.qcow2 "$weight"G
|
qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G
|
||||||
$final_path/mount_disk.sh true
|
$install_dir/mount_disk.sh true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,9 +96,9 @@ fi
|
||||||
# files in some cases.
|
# 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.
|
# this will be treated as a security issue.
|
||||||
chmod 750 "$datadir"
|
chmod 750 "$data_dir"
|
||||||
chmod -R o-rwx "$datadir"
|
chmod -R o-rwx "$data_dir"
|
||||||
chown -R $app:$app "$datadir"
|
chown -R $app:$app "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
@ -159,7 +159,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
garage_command="$final_path/garage -c $final_path/garage.toml"
|
garage_command="$install_dir/garage -c $install_dir/garage.toml"
|
||||||
|
|
||||||
# define node
|
# define node
|
||||||
$garage_command layout assign $node_id -z $domain -c $weight -t $domain
|
$garage_command layout assign $node_id -z $domain -c $weight -t $domain
|
||||||
|
|
|
@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
#REMOVEME? rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret)
|
||||||
port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
#REMOVEME? port_api=$(ynh_app_setting_get --app=$app --key=port_api)
|
||||||
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
#REMOVEME? bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
#REMOVEME? virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
||||||
|
|
||||||
if [ "$virtualisation" = "true" ] ;
|
if [ "$virtualisation" = "true" ] ;
|
||||||
then
|
then
|
||||||
|
@ -47,16 +47,16 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -74,16 +74,16 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=
|
||||||
|
|
||||||
|
|
||||||
# Create a permission if needed
|
# Create a permission if needed
|
||||||
if ! ynh_permission_exists --permission="api"; then
|
#REMOVEME? if ! ynh_permission_exists --permission="api"; then
|
||||||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
#REMOVEME? ### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||||
### Those deb packages will be installed as dependencies of this package.
|
### Those deb packages will be installed as dependencies of this package.
|
||||||
### If you're not using this helper:
|
### If you're not using this helper:
|
||||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||||
|
@ -92,16 +92,16 @@ ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
if [ "$virtualisation" = "true" ]
|
if [ "$virtualisation" = "true" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -112,7 +112,7 @@ then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
pushd $final_path
|
pushd $install_dir
|
||||||
install_garage
|
install_garage
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
@ -123,9 +123,9 @@ fi
|
||||||
# files in some cases.
|
# 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.
|
# this will be treated as a security issue.
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -152,8 +152,8 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
### 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_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||||
### ynh_store_file_checksum --file="$final_path/some_config_file"
|
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -190,9 +190,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Add table
Reference in a new issue