1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/droppy_ynh.git synced 2024-09-03 18:26:27 +02:00

Fix rights

This commit is contained in:
ericgaspar 2021-10-09 20:02:51 +02:00
parent a78a536caf
commit 679e767e6b
No known key found for this signature in database
GPG key ID: 574F281483054D44
7 changed files with 90 additions and 76 deletions

View file

@ -1,9 +1,9 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
admin="john" (USER) admin="john"
is_public=1 (PUBLIC|public=1|private=0) is_public=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -15,7 +15,6 @@
#upgrade=1 from_commit=CommitHash #upgrade=1 from_commit=CommitHash
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=

View file

@ -6,14 +6,14 @@
"en": "Self-hosted file storage server", "en": "Self-hosted file storage server",
"fr": "Serveur de stockage de fichiers auto-hébergé" "fr": "Serveur de stockage de fichiers auto-hébergé"
}, },
"version": "12.2.0~ynh6", "version": "12.2.0~ynh7",
"url": "https://github.com/silverwind/droppy", "url": "https://github.com/silverwind/droppy",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"maintainer": { "maintainer": {
"name": "eric_G" "name": "eric_G"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.7" "yunohost": ">= 4.2.4"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -23,8 +23,7 @@
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"example": "domain.org"
}, },
{ {
"name": "path", "name": "path",

View file

@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -28,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) 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 # DECLARE DATA AND CONF FILES TO BACKUP
@ -52,7 +50,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP DATADIR DIRECTORY # BACKUP DATADIR DIRECTORY
#================================================= #=================================================
ynh_backup --src_path="/home/yunohost.app/$app" ynh_backup --src_path="$data_path" --is_big
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD

View file

@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -76,6 +73,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path 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 # NGINX CONFIGURATION
#================================================= #=================================================
@ -99,10 +100,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 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_use_nodejs
ynh_exec_warn_less ynh_npm install ynh_exec_warn_less ynh_npm install
popd || ynh_die popd
#================================================= #=================================================
# CREATE DIRECTORY FOR DATA AND CONFIG # CREATE DIRECTORY FOR DATA AND CONFIG
@ -111,6 +112,7 @@ ynh_script_progression --message="Creating the data directory..." --weight=1
# Define app's data directory # 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 # Create datadir folder
mkdir -p $data_path mkdir -p $data_path
@ -119,7 +121,9 @@ mkdir -p $data_path
mkdir -p $final_path/config mkdir -p $final_path/config
# Give permission to the datadir # 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 # SETUP SYSTEMD
@ -127,7 +131,6 @@ chown -R $app: "$data_path"
ynh_script_progression --message="Configuring a systemd service..." --weight=1 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="__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 ynh_add_systemd_config
@ -137,19 +140,16 @@ ynh_add_systemd_config
ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json" ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files
chown -R $app: $final_path
chmod 755 $final_path
chmod 600 $final_path/config/config.json chmod 600 $final_path/config/config.json
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================

View file

@ -40,6 +40,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================

View file

@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -29,14 +26,13 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2 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 \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -64,14 +60,9 @@ ynh_script_progression --message="Restoring $app main directory..." --weight=20
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RESTORE USER RIGHTS chmod -R o-rwx "$final_path"
#================================================= chown -R $app:www-data "$final_path"
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app:$app $final_path
chmod 755 $final_path
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -83,6 +74,19 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=5
# Install Nodejs # Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
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 SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -92,12 +96,11 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file "/home/yunohost.app/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
chown -R $app: "/home/yunohost.app/$app"
chmod 600 $final_path/config/config.json
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST

View file

@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -28,18 +29,6 @@ ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed) 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 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -54,6 +43,18 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors 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 # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -86,6 +87,10 @@ then
ynh_setup_source --dest_dir=$final_path ynh_setup_source --dest_dir=$final_path
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -107,14 +112,15 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#============================================== #==============================================
# INSTALL DROPPY # INSTALL DROPPY
#============================================== #==============================================
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=25 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_use_nodejs
ynh_exec_warn_less ynh_npm install ynh_exec_warn_less ynh_npm install
popd || ynh_die popd
fi fi
#================================================= #=================================================
@ -122,9 +128,6 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1 ynh_script_progression --message="Creating the data directory..." --weight=1
# Define app's data directory
data_path="/home/yunohost.app/${app}"
# Create datadir folder # Create datadir folder
mkdir -p $data_path mkdir -p $data_path
@ -132,7 +135,9 @@ mkdir -p $data_path
mkdir -p $final_path/config mkdir -p $final_path/config
# Give permission to the datadir # Give permission to the datadir
chown -R $app:$app "$data_path" chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
@ -140,6 +145,7 @@ chown -R $app:$app "$data_path"
ynh_script_progression --message="Modifying a config file..." --weight=2 ynh_script_progression --message="Modifying a config file..." --weight=2
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json" ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
chmod 600 $final_path/config/config.json
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -147,22 +153,17 @@ ynh_add_config --template="../conf/config.json.example" --destination="$final_pa
ynh_script_progression --message="Configuring a systemd service..." --weight=2 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="__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 # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # SETUP LOGROTATE
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=2
# Set permissions on app files # Use logrotate to manage app-specific logfile(s)
chown -R $app:$app $final_path ynh_use_logrotate --non-append
chmod 755 $final_path
chmod 600 $final_path/config/config.json
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST