1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garage_ynh.git synced 2024-09-03 18:36:32 +02:00
This commit is contained in:
Éric Gaspar 2023-12-10 21:01:43 +01:00
parent ed30446be7
commit 3a53cc8696
9 changed files with 18 additions and 101 deletions

View file

@ -18,7 +18,6 @@ then
echo "formatting /dev/nbd$i"
mkfs.ext4 /dev/nbd$i
fi
mkdir -p $data_dir/data
chown __APP__:__APP__ $data_dir/data
mount /dev/nbd$i $data_dir/data/
fi

View file

@ -77,7 +77,7 @@ ram.runtime = "50M"
[resources.install_dir]
[resources.data_dir]
subdirs = ["data"]
subdirs = ["data", "metadata"]
[resources.permissions]
main.url = "/"

View file

@ -32,7 +32,7 @@ garage_connect() {
i=$(( i + 1 ))
if [ $i -gt 30 ]
then
ynh_die --message="unable to get layout from remote peer"
ynh_die --message="Unable to get layout from remote peer"
fi
sleep 1
done
@ -48,7 +48,7 @@ apply_layout() {
then
$garage_command layout apply --version $layout_version
else
ynh_print_warn --message="unable to apply layout. No enough nodes"
ynh_print_warn --message="Unable to apply layout. No enough nodes"
return 0
fi
}

View file

@ -27,8 +27,6 @@ ynh_backup --src_path="$install_dir"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================

View file

@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
#=================================================
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"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
@ -32,7 +32,7 @@ ynh_change_url_nginx_config
#=================================================
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"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT

View file

@ -103,7 +103,7 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# CONFIGURE GARAGE

View file

@ -12,12 +12,13 @@ source /usr/share/yunohost/helpers
#=================================================
# REMOVE NODE CONFIGURATION
#=================================================
$install_dir/garage -c $install_dir/garage.toml layout remove "$node_id"
apply_layout "$install_dir/garage -c $install_dir/garage.toml "
if [ $? -ne 0 ]
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"
fi
#=================================================
@ -33,43 +34,20 @@ then
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
if [[ "$system_is_inside_container" == "true" ]]
then
#=================================================
# REMOVE VIRTUAL DISK
#=================================================
ynh_script_progression --message="Umount virtual disk..."
# Remove the app directory securely
$install_dir/umount_disk.sh
fi
#=================================================
# REMOVE NGINX HOOK
#=================================================
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
@ -77,20 +55,9 @@ ynh_remove_nginx_config
ynh_replace_string --replace_string="server_name $domain" --match_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
yunohost tools regen-conf nginx

View file

@ -24,8 +24,6 @@ chown -R $app:$app "$install_dir"
#=================================================
ynh_script_progression --message="Restoring the data directory..."
mkdir -p "$data_dir/data"
if [[ "$system_is_inside_container" == "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.
@ -33,25 +31,9 @@ then
$install_dir/mount_disk.sh true
fi
# # FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# Open the port
ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow TCP $port
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
@ -63,26 +45,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
yunohost tools regen-conf nginx
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port
#=================================================
@ -93,7 +60,8 @@ ynh_script_progression --message="Starting a systemd service..."
#recreate log folder
mkdir /var/log/$app
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# RECREATE CONFIGURATION
#=================================================
@ -111,12 +79,13 @@ if [ -n "$bootstrap_peers" ]
then
garage_connect "$garage_command" "$bootstrap_peers"
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -48,33 +48,17 @@ ynh_add_nginx_config
ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
yunohost tools regen-conf nginx
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
ynh_script_progression --message="Updating a configuration file..."
#=================================================
# UPDATE A CONFIG FILE
#=================================================
### Same as during install
###
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum)
ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml"
#=================================================
@ -89,7 +73,7 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT