mirror of
https://github.com/YunoHost-Apps/droppy_ynh.git
synced 2024-09-03 18:26:27 +02:00
fix
This commit is contained in:
parent
a78a536caf
commit
1aec6071f5
7 changed files with 92 additions and 86 deletions
|
@ -3,4 +3,3 @@ SOURCE_SUM=6bdb9f9e629d942c81b4228ba3b49749ddf5e2b7e3c484540adb4196c43efc44
|
|||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"name": "eric_G"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.1.7"
|
||||
"yunohost": ">= 4.2.3"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
@ -23,8 +23,7 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "domain.org"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
|
|
|
@ -28,6 +28,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -47,12 +48,18 @@ ynh_backup --src_path="$final_path"
|
|||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP DATADIR DIRECTORY
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/home/yunohost.app/$app"
|
||||
ynh_backup --src_path="$data_path" --is_big
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
|
|
|
@ -67,6 +67,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=2
|
|||
# Install Nodejs
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -76,6 +84,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir=$final_path
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -84,14 +96,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#==============================================
|
||||
|
@ -99,10 +103,10 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#==============================================
|
||||
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=26
|
||||
|
||||
pushd "$final_path" || ynh_die
|
||||
pushd "$final_path"
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_npm install
|
||||
popd || ynh_die
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# CREATE DIRECTORY FOR DATA AND CONFIG
|
||||
|
@ -110,16 +114,18 @@ popd || ynh_die
|
|||
ynh_script_progression --message="Creating the data directory..." --weight=1
|
||||
|
||||
# Define app's data directory
|
||||
data_path="/home/yunohost.app/${app}"
|
||||
data_path=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
|
||||
|
||||
# Create datadir folder
|
||||
mkdir -p $data_path
|
||||
|
||||
# Create config folder
|
||||
mkdir -p $final_path/config
|
||||
|
||||
# Give permission to the datadir
|
||||
chown -R $app: "$data_path"
|
||||
chmod 750 "$data_path"
|
||||
chmod -R o-rwx "$data_path"
|
||||
chown -R $app:www-data "$data_path"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -127,7 +133,6 @@ chown -R $app: "$data_path"
|
|||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
|
||||
ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service"
|
||||
|
||||
ynh_add_systemd_config
|
||||
|
||||
|
@ -137,18 +142,18 @@ ynh_add_systemd_config
|
|||
ynh_script_progression --message="Modifying a config file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
|
||||
chmod 600 "$final_path/config/config.json"
|
||||
chown $app:$app "$final_path/config/config.json"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..." --weight=1
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app: $final_path
|
||||
chmod 755 $final_path
|
||||
chmod 600 $final_path/config/config.json
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
|
|
|
@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -56,11 +57,15 @@ ynh_script_progression --message="Removing app main directory..." --weight=6
|
|||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DATADIR DIRECTORY
|
||||
# REMOVE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove --file="/home/yunohost.app/$app"
|
||||
|
||||
# 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..." --weight=1
|
||||
ynh_secure_remove --file="$datadir"
|
||||
fi
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
|
|
@ -35,8 +35,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
|
@ -64,14 +62,9 @@ ynh_script_progression --message="Restoring $app main directory..." --weight=20
|
|||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user rights..."
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app:$app $final_path
|
||||
chmod 755 $final_path
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -92,12 +85,24 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
|
||||
ynh_restore_file "/home/yunohost.app/$app"
|
||||
chown -R $app: "/home/yunohost.app/$app"
|
||||
chmod 600 $final_path/config/config.json
|
||||
ynh_restore_file --origin_path="$data_path" --not_mandatory
|
||||
|
||||
mkdir -p $data_path
|
||||
|
||||
chmod 750 "$data_path"
|
||||
chmod -R o-rwx "$data_path"
|
||||
chown -R $app:www-data "$data_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
|
@ -109,7 +114,7 @@ yunohost service add $app --description="Self-hosted file storage server" --log=
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=40
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=20
|
||||
|
||||
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Ready for requests!"
|
||||
|
||||
|
|
|
@ -24,22 +24,9 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
|||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..." --weight=1
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -54,6 +41,18 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -86,6 +85,10 @@ then
|
|||
ynh_setup_source --dest_dir=$final_path
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -107,39 +110,25 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
|||
#==============================================
|
||||
# INSTALL DROPPY
|
||||
#==============================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=25
|
||||
|
||||
pushd "$final_path" || ynh_die
|
||||
pushd "$final_path"
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_npm install
|
||||
popd || ynh_die
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DIRECTORY FOR DATA AND CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating the data directory..." --weight=1
|
||||
|
||||
# Define app's data directory
|
||||
data_path="/home/yunohost.app/${app}"
|
||||
|
||||
# Create datadir folder
|
||||
mkdir -p $data_path
|
||||
|
||||
# Create config folder
|
||||
mkdir -p $final_path/config
|
||||
|
||||
# Give permission to the datadir
|
||||
chown -R $app:$app "$data_path"
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=2
|
||||
|
||||
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
|
||||
chmod 600 "$final_path/config/config.json"
|
||||
chown $app:$app "$final_path/config/config.json"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -147,7 +136,6 @@ ynh_add_config --template="../conf/config.json.example" --destination="$final_pa
|
|||
ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
||||
|
||||
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
|
||||
ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service"
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
@ -155,14 +143,12 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..." --weight=2
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app:$app $final_path
|
||||
chmod 755 $final_path
|
||||
chmod 600 $final_path/config/config.json
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
|
@ -174,7 +160,7 @@ yunohost service add $app --description="Self-hosted file storage server" --log=
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=40
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=20
|
||||
|
||||
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Ready for requests!"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue