mirror of
https://github.com/YunoHost-Apps/hedgedoc_ynh.git
synced 2024-09-03 19:25:52 +02:00
Secure config file
This commit is contained in:
parent
96c8e7c516
commit
60dd01d161
3 changed files with 41 additions and 62 deletions
|
@ -72,6 +72,14 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
# Install Yarn
|
# Install Yarn
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..." --weight=2
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -100,14 +108,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=2
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#==============================================
|
#==============================================
|
||||||
|
@ -135,25 +135,21 @@ 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.json"
|
path=${path_url:1}
|
||||||
|
|
||||||
# Main config File
|
# cp ../conf/config.json.example "$final_path/config.json"
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$final_path/config.json"
|
# # Main config File
|
||||||
|
# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json"
|
||||||
|
# ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json"
|
||||||
|
# ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json"
|
||||||
|
# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json"
|
||||||
|
# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config.json"
|
||||||
|
# ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json"
|
||||||
|
|
||||||
# cp ../conf/.sequelizerc.example "$final_path/.sequelizerc"
|
# ynh_store_file_checksum --file="$final_path/config.json"
|
||||||
|
|
||||||
# # DB Config File
|
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json"
|
||||||
# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/.sequelizerc"
|
|
||||||
# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/.sequelizerc"
|
|
||||||
|
|
||||||
# ynh_store_file_checksum --file="$final_path/.sequelizerc"
|
|
||||||
|
|
||||||
ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_path/.sequelizerc"
|
ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_path/.sequelizerc"
|
||||||
|
|
||||||
|
@ -165,7 +161,8 @@ ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_p
|
||||||
ynh_script_progression --message="Securing files and directories..." --weight=1
|
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:$app $final_path
|
||||||
|
chmod 600 $final_path/.sequelizerc
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
|
|
@ -52,6 +52,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." --weight
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -59,21 +67,14 @@ ynh_script_progression --message="Restoring HedgeDoc main directory..." --weight
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
ynh_system_user_create --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring user rights..." --weight=2
|
ynh_script_progression --message="Restoring user rights..." --weight=2
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R $app: $final_path
|
chown -R $app:$app $final_path
|
||||||
|
chmod 600 $final_path/.sequelizerc
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
|
|
@ -66,6 +66,14 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||||
|
|
||||||
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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -116,14 +124,6 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
# Install Yarn
|
# Install Yarn
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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,26 +139,6 @@ then
|
||||||
popd || ynh_die
|
popd || ynh_die
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MODIFY A CONFIG FILE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Modifying a config file..." --weight=2
|
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/config.json"
|
|
||||||
|
|
||||||
cp ../conf/config.json.example "$final_path/config.json"
|
|
||||||
|
|
||||||
# # Main config File
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config.json"
|
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json"
|
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
|
||||||
ynh_store_file_checksum --file="$final_path/config.json"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -178,7 +158,8 @@ ynh_add_systemd_config
|
||||||
ynh_script_progression --message="Securing files and directories..." --weight=1
|
ynh_script_progression --message="Securing files and directories..." --weight=1
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R $app: $final_path
|
chown -R $app:$app $final_path
|
||||||
|
chmod 600 $final_path/.sequelizerc
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
|
Loading…
Reference in a new issue