Compare commits
25 Commits
a37de1795c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99613af73c | ||
|
|
7ca24923b7 | ||
|
|
4c4958df6a | ||
|
|
353873d18f | ||
|
|
801c170ab9 | ||
|
|
fa52d0a4b4 | ||
|
|
7cd0be6339 | ||
|
|
353e7cd02b | ||
|
|
28a177c50d | ||
|
|
ff6be76e85 | ||
|
|
827c9425b0 | ||
|
|
928edeface | ||
|
|
81776945bb | ||
|
|
94188611cf | ||
|
|
a0ee0ec724 | ||
|
|
6e6938f49a | ||
|
|
068220ad6e | ||
|
|
ac381b9490 | ||
|
|
e9dff464cd | ||
|
|
279b0a6e4b | ||
|
|
94c76ff596 | ||
|
|
a04efbd137 | ||
|
|
b7c721266e | ||
|
|
a1ec9b2763 | ||
|
|
0d40db44d4 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,5 @@
|
||||
*~
|
||||
*.sw[op]
|
||||
.apps/
|
||||
.apps_git_clone_cache
|
||||
.spdx_licenses
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
metadata_dir = "/opt/yunohost/__APP__/metadata"
|
||||
data_dir = "__DATADIR__"
|
||||
data_dir = "__DATADIR__/data"
|
||||
|
||||
block_size = 1048576
|
||||
block_manager_background_tranquility = 2
|
||||
@@ -13,24 +13,12 @@ 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 = "__IP__:__PORT__"
|
||||
rpc_public_addr = "__DOMAIN__:__PORT__"
|
||||
|
||||
bootstrap_peers = [
|
||||
__BOOTSTRAP_PEERS_VAR__
|
||||
]
|
||||
bootstrap_peers = []
|
||||
|
||||
[s3_api]
|
||||
# Ne supporte pas TLS → reverse proxy obligatoire
|
||||
# pour avoir de la sécurité
|
||||
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"
|
||||
|
||||
@@ -4,16 +4,18 @@ then
|
||||
datadir=__DATADIR__
|
||||
format=$1
|
||||
i=0
|
||||
while $(fdisk -l /dev/nbd$i 1&>2 /dev/null)
|
||||
while fdisk -l /dev/nbd$i 1> /dev/null 2> /dev/null
|
||||
do
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
echo $i
|
||||
echo $i > $datadir/nbd_index
|
||||
modprobe nbd max_part=$(( i + 1 ))
|
||||
qemu-nbd --connect /dev/nbd$i $datadir/garage.qcow2
|
||||
qemu-nbd --connect /dev/nbd$i $datadir/garage_data.qcow2
|
||||
if [[ "$format" = "true" ]]
|
||||
then
|
||||
mkfs.ext4 /dev/nbd$i > /dev/null
|
||||
echo "formatting /dev/nbd$i"
|
||||
mkfs.ext4 /dev/nbd$i
|
||||
fi
|
||||
mkdir -p $datadir/data
|
||||
mount /dev/nbd$i $datadir/data/
|
||||
fi
|
||||
|
||||
@@ -8,8 +8,8 @@ User=__APP__
|
||||
Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1'
|
||||
ExecStartPre=+__FINALPATH__/mount_disk.sh
|
||||
ExecStart=__FINALPATH__/garage -c __FINALPATH__/garage.toml server
|
||||
ExecStopPost=+__FINALPATH__/umount_disk.sh
|
||||
WorkingDirectory=__FINALPATH__/
|
||||
NoNewPrivileges=true
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
|
||||
@@ -17,16 +17,16 @@ StandardError=inherit
|
||||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
# .. but this should be a good baseline
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
__VIRT_PROTECTION__PrivateTmp=yes
|
||||
#PrivateDevices=yes
|
||||
# RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
DevicePolicy=closed
|
||||
ProtectSystem=full
|
||||
ProtectControlGroups=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
#DevicePolicy=closed
|
||||
__VIRT_PROTECTION__ProtectSystem=full
|
||||
__VIRT_PROTECTION__ProtectControlGroups=yes
|
||||
#ProtectKernelModules=yes
|
||||
__VIRT_PROTECTION__ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
if [ "$VIRTUALISATION" = "true" ]
|
||||
then
|
||||
nbd=__NBD_INDEX__
|
||||
datadir=__DATADIR__
|
||||
nbd=$(cat $datadir/nbd_index)
|
||||
umount /dev/nbd$nbd
|
||||
qemu-nbd --disconnect /dev/nbd$nbd
|
||||
fi
|
||||
|
||||
37
config_panel.toml
Normal file
37
config_panel.toml
Normal file
@@ -0,0 +1,37 @@
|
||||
version = "1.0"
|
||||
[main]
|
||||
|
||||
|
||||
[main.garage_conf]
|
||||
name = "Garage configuration"
|
||||
|
||||
|
||||
[main.garage_conf.weight]
|
||||
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 = "Friend serveur adress"
|
||||
help = "add bootstrap_peers address to connect to existing cluster"
|
||||
type = "string"
|
||||
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"
|
||||
|
||||
@@ -89,7 +89,7 @@ services = ["__APP__"]
|
||||
|
||||
## (optional) By default all questions are optionals, but you can specify a
|
||||
## default behaviour for question in the section
|
||||
optional = false
|
||||
##optional = false
|
||||
|
||||
## (optional) It's also possible with the 'visible' property to only
|
||||
## display the section depending on the user's answers to previous questions.
|
||||
@@ -118,14 +118,14 @@ services = ["__APP__"]
|
||||
## extend availables questions types list.
|
||||
## See: TODO DOC LINK
|
||||
|
||||
[main.customization.project_name]
|
||||
[main.customization.weight]
|
||||
|
||||
## (required) The ask property is equivalent to the ask property in
|
||||
## the manifest. However, in config panels, questions are displayed on the
|
||||
## left side and therefore have less space to be rendered. Therefore,
|
||||
## it is better to use a short question, and use the "help" property to
|
||||
## provide additional details if necessary.
|
||||
ask.en = "Name of the project"
|
||||
ask.en = "allocated space"
|
||||
|
||||
## (required) The type property indicates how the question should be
|
||||
## displayed, validated and managed. Some types have specific properties.
|
||||
@@ -134,7 +134,7 @@ services = ["__APP__"]
|
||||
## email, url, date, time, color, select, domain, user, tags, file.
|
||||
##
|
||||
## For a complete list with specific properties, see: TODO DOC LINK
|
||||
type = "string"
|
||||
type = "number"
|
||||
|
||||
########################################################################
|
||||
#### ABOUT THE BIND PROPERTY
|
||||
|
||||
10
hooks/regen_conf
Normal file
10
hooks/regen_conf
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
action=$1
|
||||
domain=__DOMAIN__
|
||||
|
||||
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
||||
@@ -6,10 +6,10 @@
|
||||
"en": "S3 storage",
|
||||
"fr": "stockage S3"
|
||||
},
|
||||
"version": "0.7.3~ynh1",
|
||||
"version": "0.8.0~ynh1",
|
||||
"url": "https://garagehq.deuxfleurs.fr/",
|
||||
"upstream": {
|
||||
"license": "free",
|
||||
"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/",
|
||||
@@ -24,7 +24,7 @@
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"multi_instance": true,
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
pkg_dependencies_virtualisation="qemu-utils"
|
||||
pkg_dependencies_virtualisation="qemu-utils e2fsprogs"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
|
||||
GARAGE_VERSION="0.7.3"
|
||||
GARAGE_VERSION="0.8.0"
|
||||
|
||||
get_ip() {
|
||||
curl ip.me
|
||||
@@ -41,25 +41,35 @@ install_garage () {
|
||||
chmod +x garage
|
||||
}
|
||||
|
||||
init_garage() {
|
||||
garage_command="$1"
|
||||
node_id="$2"
|
||||
weight="$3"
|
||||
zone="$4"
|
||||
|
||||
$garage_command layout assign $node_id -z $zone -c $weight -t $zone
|
||||
|
||||
apply_layout "$garage_command"
|
||||
garage_connect() {
|
||||
local command="$1"
|
||||
local peer="$2"
|
||||
# connect to cluster
|
||||
$command node connect "$peer"
|
||||
sleep 2
|
||||
# wait until layout is updated
|
||||
local i=0
|
||||
until $command layout show 2>/dev/null | grep "${peer:0:15}"; do
|
||||
i=$(( i + 1 ))
|
||||
if [ $i -gt 30 ]
|
||||
then
|
||||
ynh_die --message="unable to get layout from remote peer"
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
apply_layout() {
|
||||
|
||||
garage_command=$1
|
||||
|
||||
if [ $($garage_command -c garage.toml layout show 2>/dev/null | grep -- --version) ]
|
||||
$garage_command layout show 2>/dev/null
|
||||
local layout_version=$($garage_command layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs)
|
||||
if [ "$layout_version" != "" ]
|
||||
then
|
||||
layout_version=$($garage_command layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs)
|
||||
$garage_command layout apply --version $layout_version
|
||||
else
|
||||
ynh_print_warn --message="unable to apply layout. No enough nodes"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
110
scripts/config
110
scripts/config
@@ -1,19 +1,11 @@
|
||||
#!/bin/bash
|
||||
# In simple cases, you don't need a config script.
|
||||
|
||||
# With a simple config_panel.toml, you can write in the app settings, in the
|
||||
# upstream config file or replace complete files (logo ...) and restart services.
|
||||
|
||||
# The config scripts allows you to go further, to handle specific cases
|
||||
# (validation of several interdependent fields, specific getter/setter for a value,
|
||||
# display dynamic informations or choices, pre-loading of config type .cube... ).
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_abort_if_errors
|
||||
@@ -23,78 +15,54 @@ 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"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
get__weight() {
|
||||
ynh_app_setting_get --app=$app --key=weight
|
||||
}
|
||||
|
||||
get__amount() {
|
||||
# Here we can imagine to have an API call to stripe to know the amount of donation during a month
|
||||
local amount = 200
|
||||
|
||||
# It's possible to change some properties of the question by overriding it:
|
||||
if [ $amount -gt 100 ]
|
||||
set__weight() {
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
cat << EOF
|
||||
style: success
|
||||
value: $amount
|
||||
ask:
|
||||
en: A lot of donation this month: **$amount €**
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
style: danger
|
||||
value: $amount
|
||||
ask:
|
||||
en: Not so much donation this month: $amount €
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
get__prices() {
|
||||
local prices = "$(grep "DONATION\['" "$final_path/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
|
||||
if [ "$prices" == "," ];
|
||||
then
|
||||
# Return YNH_NULL if you prefer to not return a value at all.
|
||||
echo YNH_NULL
|
||||
else
|
||||
echo $prices
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
validate__publishable_key() {
|
||||
|
||||
# We can imagine here we test if the key is really a publisheable key
|
||||
(is_secret_key $publishable_key) &&
|
||||
echo 'This key seems to be a secret key'
|
||||
get__bootstrap_peers() {
|
||||
ynh_app_setting_get --app=$app --key=bootstrap_peers
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
set__prices() {
|
||||
|
||||
#---------------------------------------------
|
||||
# IMPORTANT: setter are trigger only if a change is detected
|
||||
#---------------------------------------------
|
||||
for price in $(echo $prices | sed "s/,/ /"); do
|
||||
frequency=$(echo $price | cut -d/ -f1)
|
||||
currency=$(echo $price | cut -d/ -f2)
|
||||
price_id=$(echo $price | cut -d/ -f3)
|
||||
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$final_path/settings.py"
|
||||
|
||||
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py"
|
||||
done
|
||||
|
||||
#---------------------------------------------
|
||||
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
|
||||
#---------------------------------------------
|
||||
ynh_app_setting_set $app prices $prices
|
||||
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
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
104
scripts/install
104
scripts/install
@@ -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"
|
||||
@@ -73,10 +73,7 @@ else
|
||||
fi
|
||||
if [ -n "$bootstrap_peers" ]
|
||||
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}:3901' || ynh_die --message="friend server id must have id with the following form : 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@192.168.1.1:3901"
|
||||
bootstrap_peers_var="\"$bootstrap_peers\","
|
||||
else
|
||||
bootstrap_peers_var=""
|
||||
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
|
||||
|
||||
if [ "$datadir" = "/home/yunohost.app/__APP_NAME__/data" ]
|
||||
@@ -90,25 +87,32 @@ 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
|
||||
virtualisation=false
|
||||
export VIRTUALISATION=false
|
||||
# uncomment systemd isolation
|
||||
virt_protection=""
|
||||
else
|
||||
export VIRTUALISATION=true
|
||||
virtualisation=true
|
||||
# comment systemd isolation to allow mount disk
|
||||
virt_protection="#"
|
||||
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
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
||||
ynh_app_setting_set --app=$app --key=weight --value=$weight
|
||||
|
||||
|
||||
#=================================================
|
||||
@@ -116,7 +120,7 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
||||
#=================================================
|
||||
# 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.
|
||||
@@ -129,12 +133,6 @@ port=$(ynh_find_port --port=4000)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
port_api=$(ynh_find_port --port=5000)
|
||||
ynh_app_setting_set --app=$app --key=port_api --value=$port_api
|
||||
port_web=$(ynh_find_port --port=6000)
|
||||
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
||||
port_admin=$(ynh_find_port --port=7000)
|
||||
ynh_app_setting_set --app=$app --key=port_admin --value=$port_admin
|
||||
|
||||
ynh_print_warn --message="port : $port port_api : $port_api port_web : $port_web port_admin : $port_admin"
|
||||
|
||||
|
||||
# Optional: Expose this port publicly
|
||||
@@ -142,13 +140,13 @@ ynh_print_warn --message="port : $port port_api : $port_api port_web : $port_web
|
||||
# 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.
|
||||
@@ -164,7 +162,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"
|
||||
@@ -172,7 +170,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.
|
||||
@@ -200,7 +198,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
|
||||
|
||||
@@ -208,7 +206,7 @@ ynh_script_progression --message="Configuring NGINX web server..." --time --weig
|
||||
ynh_add_nginx_config
|
||||
|
||||
#add wildcard subdomain
|
||||
ynh_replace_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
@@ -219,7 +217,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.
|
||||
###
|
||||
@@ -255,7 +253,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
|
||||
@@ -272,13 +270,12 @@ mkdir -p $datadir/data
|
||||
#=================================================
|
||||
# create data partition
|
||||
#=================================================
|
||||
nbd_index=127
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
# 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
|
||||
nbd_index=$($final_path/mount_disk.sh true)
|
||||
ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index
|
||||
VIRTUALISATION=true $final_path/mount_disk.sh true
|
||||
fi
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
@@ -293,13 +290,13 @@ chown -R $app:$app "$datadir"
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
$final_path/umount_disk.sh $nbd_index
|
||||
VIRTUALISATION=true $final_path/umount_disk.sh
|
||||
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.
|
||||
@@ -320,7 +317,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.
|
||||
@@ -336,7 +333,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.
|
||||
@@ -369,7 +366,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
|
||||
@@ -386,7 +383,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.
|
||||
@@ -395,7 +392,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
|
||||
|
||||
@@ -403,27 +400,44 @@ 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"
|
||||
|
||||
node_id=$($garage_command node id -q | cut -d '@' -f1)
|
||||
ynh_app_setting_set --app=$app --key=node_id --value=node_id
|
||||
node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)
|
||||
ynh_app_setting_set --app=$app --key=node_id --value=$node_id
|
||||
|
||||
|
||||
init_garage "$garage_command" "$node_id" "$weight" "$domain"
|
||||
# define node
|
||||
$garage_command layout assign $node_id -z $domain -c $weight -t $domain
|
||||
# if there is enough node, apply layout
|
||||
apply_layout "$garage_command"
|
||||
|
||||
if [ -n "$bootstrap_peers" ]
|
||||
then
|
||||
garage_connect "$garage_command" "$bootstrap_peers"
|
||||
fi
|
||||
|
||||
self_bootstrap_peers="$($garage_command node id --quiet)"
|
||||
garage_layout="$($garage_command layout show)"
|
||||
|
||||
#=================================================
|
||||
# Send email to admin
|
||||
#=================================================
|
||||
app_message="your garage node have been installed. You can now connect to other nodes with the following identifiers : \
|
||||
rpc_secret: $rpc_secret
|
||||
bootstrap_peers: $bootstrap_peers"
|
||||
app_message="
|
||||
your garage node have been installed. You can now connect to other nodes with the following identifiers :
|
||||
|
||||
ynh_send_readme_to_admin --app_message=$app_message
|
||||
rpc_secret: $rpc_secret
|
||||
bootstrap_peers: $self_bootstrap_peers
|
||||
|
||||
Current garage layout :
|
||||
|
||||
$garage_layout"
|
||||
|
||||
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
|
||||
|
||||
@@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
nbd_index=$(ynh_app_setting_get --app=$app --key=nbd_index)
|
||||
export VIRTUALISTATION=true
|
||||
fi
|
||||
#=================================================
|
||||
# REMOVE NODE CONFIGURATION
|
||||
@@ -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,15 +77,15 @@ 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
|
||||
$final_path/umount_disk.sh
|
||||
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
|
||||
|
||||
@@ -32,12 +32,12 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
|
||||
|
||||
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,24 +72,22 @@ 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"
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
export VIRTUALISATION=true
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies_virtualisation
|
||||
# to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size.
|
||||
qemu-img create -f qcow2 $datadir/garage_data.qcow2 "$weight"G
|
||||
nbd_index=$($final_path/mount_disk.sh "$datadir" true)
|
||||
ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index
|
||||
$final_path/mount_disk.sh true
|
||||
fi
|
||||
|
||||
#ynh_restore_file --origin_path="$datadir/data" --not_mandatory
|
||||
|
||||
|
||||
# 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
|
||||
# such that the appropriate users (e.g. maybe www-data) can access
|
||||
# files in some cases.
|
||||
@@ -102,29 +100,25 @@ chown -R $app:$app "$datadir"
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||
|
||||
|
||||
# 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
|
||||
ynh_replace_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
@@ -132,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"
|
||||
|
||||
@@ -158,6 +152,11 @@ weight=$(ynh_app_setting_get --app=$app --key=weight)
|
||||
|
||||
garage_command="$garage_path/garage -c $garage_path/garage.toml"
|
||||
|
||||
if [ -n "$bootstrap_peers" ]
|
||||
then
|
||||
$garage_command id connect "$bootstrap_peers"
|
||||
fi
|
||||
|
||||
init_garage "$garage_command" "$node_id" "$weight" "$domain"
|
||||
|
||||
#=================================================
|
||||
@@ -165,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
|
||||
|
||||
@@ -173,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
|
||||
|
||||
Reference in New Issue
Block a user