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

Protect config file

This commit is contained in:
ericgaspar 2021-03-23 17:53:50 +01:00
parent d282908b54
commit 50d52bb9e7
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 25 additions and 35 deletions

View file

@ -45,8 +45,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -136,12 +136,7 @@ ynh_add_systemd_config
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_script_progression --message="Modifying a config file..." --weight=1
cp ../conf/config.json.example "$final_path/config/config.json" ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
# Main config File
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/config.json"
ynh_store_file_checksum --file="$final_path/config/config.json"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -153,6 +148,7 @@ ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files # Set permissions to app files
chown -R $app: $final_path chown -R $app: $final_path
chmod 755 $final_path chmod 755 $final_path
chmod 600 $final_path/config/config.json
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -167,7 +163,7 @@ yunohost service add $app --description="Self-hosted file storage server" --log=
ynh_script_progression --message="Starting a systemd service..." --weight=40 ynh_script_progression --message="Starting a systemd service..." --weight=40
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ready for requests!" ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Ready for requests!"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -49,20 +49,20 @@ ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=20
ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=20
ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
@ -97,6 +97,7 @@ systemctl enable $app.service --quiet
ynh_restore_file "/home/yunohost.app/$app" ynh_restore_file "/home/yunohost.app/$app"
chown -R $app: "/home/yunohost.app/$app" chown -R $app: "/home/yunohost.app/$app"
chmod 600 $final_path/config/config.json
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -110,7 +111,7 @@ yunohost service add $app --description="Self-hosted file storage server" --log=
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=40 ynh_script_progression --message="Starting a systemd service..." --weight=40
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ready for requests!" ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Ready for requests!"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -63,6 +63,14 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=9
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
#=================================================
# CREATE DEDICATED USER
#=================================================
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
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -94,14 +102,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=2
# 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
#=================================================
# CREATE DEDICATED USER
#=================================================
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
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#============================================== #==============================================
@ -139,15 +139,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_backup_if_checksum_is_different --file="$final_path/config/config.json" ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config/config.json"
cp ../conf/config.json.example "$final_path/config/config.json"
# Main config File
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/config.json"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/config/config.json"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -170,6 +162,7 @@ ynh_script_progression --message="Securing files and directories..." --weight=2
# Set permissions on app files # Set permissions on app files
chown -R $app:$app $final_path chown -R $app:$app $final_path
chmod 755 $final_path chmod 755 $final_path
chmod 600 $final_path/config/config.json
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST