mirror of
https://github.com/YunoHost-Apps/garage_ynh.git
synced 2024-09-03 18:36:32 +02:00
cleaning
This commit is contained in:
parent
6f145ca3c7
commit
9dfe0785db
10 changed files with 18 additions and 168 deletions
|
@ -1,32 +0,0 @@
|
|||
# See here for more information
|
||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||
|
||||
# Move this file from check_process.default to check_process when you have filled it.
|
||||
|
||||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
rpc_secret=""
|
||||
bootstrap_peers=""
|
||||
weight="10"
|
||||
datadir=""
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0
|
||||
setup_root=0
|
||||
setup_nourl=1
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
upgrade=0 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&rpc_secret=RPC_SECRET&bootstrap_peers=BOOTSTRAP_PEERS&weight=WEIGHT&datadir=DATADIR
|
|
@ -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
|
||||
|
|
|
@ -79,6 +79,7 @@ ram.runtime = "50M"
|
|||
[resources.install_dir]
|
||||
|
||||
[resources.data_dir]
|
||||
subdirs = ["data", "metadata"]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
GARAGE_VERSION="0.8.2"
|
||||
GARAGE_VERSION="0.9.0"
|
||||
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
|
@ -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,10 +48,11 @@ 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
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -15,11 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||
### to be backuped and not an actual copy of any file. The actual backup that
|
||||
### creates and fill the archive with the files happens in the core after this
|
||||
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
|
|
@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
|
@ -30,7 +30,7 @@ ynh_change_url_nginx_config
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
|
@ -38,4 +38,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||
ynh_script_progression --message="Change of URL completed for $app"--last
|
||||
|
|
|
@ -32,7 +32,6 @@ ynh_script_progression --message="Storing installation settings..."
|
|||
ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret
|
||||
ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers
|
||||
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -70,7 +69,7 @@ ynh_script_progression --message="Creating a data directory..." --weight=5
|
|||
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
ynh_print_warn --message="This may take time regarding disk size…"
|
||||
ynh_print_warn --message="This may take time regarding disk size..."
|
||||
|
||||
# to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size.
|
||||
qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G
|
||||
|
@ -94,22 +93,10 @@ ynh_script_progression --message="Configuring a systemd service..."
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app
|
||||
yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
|
|
@ -9,13 +9,10 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# 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 "
|
||||
|
@ -24,7 +21,6 @@ then
|
|||
ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough"
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
@ -38,43 +34,23 @@ 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..."
|
||||
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
|
||||
|
||||
|
@ -82,31 +58,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"
|
||||
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_script_progression --message="Closing port $port..."
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
|
|
|
@ -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,8 @@ 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,27 +44,12 @@ 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 --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app
|
||||
yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -94,6 +60,7 @@ ynh_script_progression --message="Starting a systemd service..."
|
|||
mkdir /var/log/$app
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RECREATE CONFIGURATION
|
||||
#=================================================
|
||||
|
|
|
@ -48,43 +48,21 @@ 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..."
|
||||
yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue