improve config panel
This commit is contained in:
parent
b7c721266e
commit
a04efbd137
|
@ -13,7 +13,7 @@ rpc_secret = "__RPC_SECRET__"
|
|||
rpc_bind_addr = "[::]:__PORT__"
|
||||
# Le port peut être différent (eg NAT) mais doit rediriger sur le
|
||||
# port de rpc_bind_addr
|
||||
#rpc_public_addr = "__DOMAIN__:__PORT__"
|
||||
rpc_public_addr = "__DOMAIN__:__PORT__"
|
||||
|
||||
bootstrap_peers = []
|
||||
|
||||
|
@ -23,12 +23,7 @@ bootstrap_peers = []
|
|||
api_bind_addr = "[::]:__PORT_API__"
|
||||
s3_region = "garage"
|
||||
|
||||
[s3_web]
|
||||
bind_addr = "[::]:__PORT_WEB__"
|
||||
root_domain = ".web.garage.localhost"
|
||||
index = "index.html"
|
||||
|
||||
[admin]
|
||||
api_bind_addr = "127.0.0.1:__PORT_ADMIN__"
|
||||
metrics_token = "cacce0b2de4bc2d9f5b5fdff551e01ac1496055aed248202d415398987e35f81"
|
||||
admin_token = "ae8cb40ea7368bbdbb6430af11cca7da833d3458a5f52086f4e805a570fb5c2a"
|
||||
metrics_token = "__METRIC_TOKEN__"
|
||||
admin_token = "__ADMIN_TOKEN__"
|
||||
|
|
|
@ -1,26 +1,37 @@
|
|||
version = "1.0"
|
||||
[main]
|
||||
|
||||
services = ["__APP__"]
|
||||
|
||||
[main.garage_conf]
|
||||
name = "Garage configuration"
|
||||
|
||||
[main.garage_conf.rpc_secret]
|
||||
ask.en = "Choose rpc secret"
|
||||
type = "string"
|
||||
bind = "rpc_secret:/opt/yunohost/__APP__/garage.toml"
|
||||
pattern.regexp = '^[0-9a-f]{64}$'
|
||||
pattern.error = "rpc_secret have to be a 32-byte hex-encoded random string. See https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/ for more information"
|
||||
|
||||
|
||||
[main.garage_conf.weight]
|
||||
ask.en = "allocated space (Gio)"
|
||||
ask = "allocated space (Gio)"
|
||||
help = "This value is doubled used by yunohost. It set the weight of the garage node and if virtualisation is enabled, it create a virtual disk with the same size"
|
||||
type = "number"
|
||||
bind = "weight()"
|
||||
|
||||
[main.garage_conf.bootstrap_peers]
|
||||
ask.en = "Friend serveur adress"
|
||||
ask = "Friend serveur adress"
|
||||
help = "add bootstrap_peers address to connect to existing cluster"
|
||||
type = "string"
|
||||
pattern.regexp = '[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}'
|
||||
bind = "null"
|
||||
pattern.regexp = '[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}'
|
||||
pattern.error = "friend server id must have id with the following form : 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@192.168.1.1:1234 or 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@example.tld:1234"
|
||||
|
||||
[danger]
|
||||
services = ["__APP__"]
|
||||
|
||||
[danger.sensible]
|
||||
name = "Danger Zone"
|
||||
|
||||
[danger.sensible.rpc_secret]
|
||||
ask = "Choose/Change rpc secret"
|
||||
type = "string"
|
||||
redact = true
|
||||
bind = "rpc_secret:/opt/yunohost/__APP__/garage.toml"
|
||||
pattern.regexp = '^[0-9a-f]{64}$'
|
||||
pattern.error = "rpc_secret have to be a 32-byte hex-encoded random string. See https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/ for more information"
|
||||
help = "Be careful if your node is already connected to a cluster, it won't be able to connect anymore if you change the rpc_secret value"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
pkg_dependencies_virtualisation="qemu-utils"
|
||||
pkg_dependencies_virtualisation="qemu-utils e2fsprogs"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
@ -45,9 +45,10 @@ garage_connect() {
|
|||
local command="$1"
|
||||
local peer="$2"
|
||||
# connect to cluster
|
||||
$garage_command node connect "$peer"
|
||||
$command node connect "$peer"
|
||||
sleep 2
|
||||
# wait until layout is updated
|
||||
until $garage_command layout show 2>/dev/null | grep "${peer:0:15}"; do
|
||||
until $command layout show 2>/dev/null | grep "${peer:0:15}"; do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
|
|
@ -16,30 +16,55 @@ 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)
|
||||
nbd_index=$(ynh_app_setting_get $app nbd_index)
|
||||
command="$final_path/garage -c $final_path/garage.toml"
|
||||
|
||||
get_weight() {
|
||||
get__weight() {
|
||||
ynh_app_setting_get --app=$app --key=weight
|
||||
}
|
||||
|
||||
set_weight() {
|
||||
$command layout assign $node_id -c $weight
|
||||
set__weight() {
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
systemctl stop $YNH_APP_INSTANCE_NAME
|
||||
old_weight="$ynh_app_setting_get --app=$app --key=weight"
|
||||
if [ $old_weight -le $weight }
|
||||
then
|
||||
$final_path/umount_disk.sh $nbd_index
|
||||
qemu-img resize $datadir/$datadir/garage_data.qcow2 $weightG
|
||||
qemu-nbd --connect /dev/nbd$nbd_index $datadir/garage.qcow2
|
||||
e2fsck -f /dev/nbd$nbd_index
|
||||
resize2fs /dev/nbd$nbd_index
|
||||
mount /dev/nbd$nbd_index $datadir/data/
|
||||
else
|
||||
umount /dev/nbd$nbd_index
|
||||
e2fsck -f /dev/nbd$nbd_index
|
||||
resize2fs /dev/nbd$nbd_index $weightG
|
||||
qemu-nbd --disconnect /dev/nbd$nbd_index
|
||||
qemu-img resize $datadir/$datadir/garage_data.qcow2 $weightG
|
||||
$nbd_index=$(final_path/mount_disk.sh false)
|
||||
ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index
|
||||
fi
|
||||
systemctl start $YNH_APP_INSTANCE_NAME
|
||||
fi
|
||||
$command layout assign $node_id -c $weight 2>/dev/null
|
||||
apply_layout "$command"
|
||||
ynh_app_setting_set --app=$app --key=weight --value=$weight
|
||||
}
|
||||
|
||||
|
||||
get_peers() {
|
||||
get__bootstrap_peers() {
|
||||
ynh_app_setting_get --app=$app --key=bootstrap_peers
|
||||
}
|
||||
|
||||
set_peers() {
|
||||
garage_connect "$command" "$bootstrap_peers"
|
||||
set__bootstrap_peers() {
|
||||
garage_connect "$command" "$bootstrap_peers" 2>/dev/null
|
||||
apply_layout "$command"
|
||||
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
||||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -50,15 +50,15 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
### About --weight and --time
|
||||
### About --weight and
|
||||
### ynh_script_progression will show to your final users the progression of each scripts.
|
||||
### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
|
||||
### --time is a packager option, it will show you the execution time since the previous call.
|
||||
### is a packager option, it will show you the execution time since the previous call.
|
||||
### This option should be removed before releasing your app.
|
||||
### Use the execution time, given by --time, to estimate the weight of a step.
|
||||
### 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.
|
||||
### 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..." --time --weight=1
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app"
|
||||
|
@ -87,7 +87,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url="/"
|
|||
#=================================================
|
||||
# LOOKING FOR VIRTUALISATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking virtualisation availability…" --time --weight=1
|
||||
ynh_script_progression --message="Checking virtualisation availability…" --weight=1
|
||||
|
||||
if [ "$(which modprobe)" = "" ]
|
||||
then
|
||||
|
@ -95,12 +95,12 @@ then
|
|||
else
|
||||
virtualisation=true
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=virtualisation --value=true
|
||||
ynh_app_setting_set --app=$app --key=virtualisation --value=$virtualisation
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret
|
||||
|
@ -114,7 +114,7 @@ ynh_app_setting_set --app=$app --key=weight --value=$weight
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding available ports..." --time --weight=1
|
||||
ynh_script_progression --message="Finding available ports..." --weight=1
|
||||
|
||||
### Use these lines if you have to open a port for the application
|
||||
### `ynh_find_port` will find the first available port starting from the given port.
|
||||
|
@ -141,13 +141,13 @@ nbd_index=127
|
|||
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||
|
||||
# Open the port
|
||||
ynh_script_progression --message="Configuring firewall..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall allow TCP $port
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||
|
||||
### `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.
|
||||
|
@ -163,7 +163,7 @@ fi
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
@ -171,7 +171,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --time --weight=1
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
|
||||
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||
### downloaded from an upstream source, like a git repository.
|
||||
|
@ -199,7 +199,7 @@ chown -R $app:$app "$final_path"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
|
||||
|
@ -218,7 +218,7 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
|||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --time --weight=1
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
### You can add specific configuration files.
|
||||
###
|
||||
|
@ -254,7 +254,7 @@ chown $app:$app "$final_path/garage.toml"
|
|||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --time --weight=1
|
||||
ynh_script_progression --message="Creating a data directory..." --weight=1
|
||||
|
||||
### Use these lines if you need to create a directory to store "persistent files" for the application.
|
||||
### Usually this directory is used to store uploaded files or any file that won't be updated during
|
||||
|
@ -298,7 +298,7 @@ fi
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
||||
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
||||
|
@ -319,7 +319,7 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
|
||||
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
||||
### Use this helper only if there is effectively a log file for this app.
|
||||
|
@ -335,7 +335,7 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||
### displayed in the admin interface and through the others `yunohost service` commands.
|
||||
|
@ -368,7 +368,7 @@ yunohost service add --needs_exposed_ports $port --description="s3 storage" --lo
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
### `ynh_systemd_action` is used to start a systemd service for an app.
|
||||
### Only needed if you have configure a systemd service
|
||||
|
@ -385,7 +385,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
|
@ -394,7 +394,7 @@ ynh_script_progression --message="Configuring permissions..." --time --weight=1
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -402,7 +402,7 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
#=================================================
|
||||
# CONFIGURE GARAGE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring garage..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring garage..." --weight=1
|
||||
|
||||
garage_command="$final_path/garage -c $final_path/garage.toml"
|
||||
|
||||
|
@ -433,4 +433,4 @@ ynh_send_readme_to_admin --app_message=$app_message
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --time --last
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -51,14 +51,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..." --time --weight=1
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
@ -66,7 +66,7 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
@ -77,7 +77,7 @@ then
|
|||
#=================================================
|
||||
# REMOVE VIRTUAL DISK
|
||||
#=================================================
|
||||
ynh_script_progression --message="umount virtual disk..." --time --weight=1
|
||||
ynh_script_progression --message="umount virtual disk..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
$final_path/umount_disk.sh $nbd_index
|
||||
|
@ -85,7 +85,7 @@ fi
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
@ -93,18 +93,13 @@ ynh_secure_remove --file="$final_path"
|
|||
#=================================================
|
||||
# REMOVE DATA DIR
|
||||
#=================================================
|
||||
|
||||
# Remove the data directory if --purge option is used
|
||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Removing app data directory..." --time --weight=1
|
||||
ynh_secure_remove --file="$datadir"
|
||||
fi
|
||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||
ynh_secure_remove --file="$datadir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -116,7 +111,7 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -127,7 +122,7 @@ ynh_remove_app_dependencies
|
|||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_script_progression --message="Closing port $port..." --time --weight=1
|
||||
ynh_script_progression --message="Closing port $port..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
|
@ -137,7 +132,7 @@ fi
|
|||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..." --time --weight=1
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
@ -147,7 +142,7 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
@ -156,4 +151,4 @@ ynh_system_user_delete --username=$app
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -24,7 +24,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -37,7 +37,7 @@ bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers)
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
@ -47,7 +47,7 @@ test ! -d $final_path \
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
@ -55,7 +55,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
|
@ -72,7 +72,7 @@ chown -R $app:$app "$final_path"
|
|||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
|
||||
mkdir -p "$datadir/data"
|
||||
|
||||
|
@ -102,13 +102,13 @@ chown -R $app:$app "$datadir"
|
|||
#=================================================
|
||||
|
||||
# Open the port
|
||||
ynh_script_progression --message="Configuring firewall..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall allow TCP $port
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
#add wildcard subdomain
|
||||
|
@ -118,7 +118,7 @@ ynh_replace_special_string --match_string="server_name $domain" --replace_string
|
|||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
@ -126,21 +126,21 @@ systemctl enable $app.service --quiet
|
|||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
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..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
|
@ -164,7 +164,7 @@ init_garage "$garage_command" "$node_id" "$weight" "$domain"
|
|||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -172,4 +172,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --time --last
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -39,7 +39,7 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -55,14 +55,14 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
#
|
||||
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
|
||||
|
@ -105,7 +105,7 @@ fi
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
@ -116,7 +116,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
pushd $final_path
|
||||
|
@ -138,7 +138,7 @@ chown -R $app:$app "$final_path"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
@ -152,7 +152,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --time --weight=1
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
|
||||
### For more complex cases where you want to replace stuff using regexes,
|
||||
|
@ -165,7 +165,7 @@ ynh_script_progression --message="Updating a configuration file..." --time --wei
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
@ -175,7 +175,7 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
@ -183,21 +183,21 @@ ynh_use_logrotate --non-append
|
|||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
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..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -205,4 +205,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in New Issue
Block a user