1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Cleanup: double quotes, remove chown/chmod duplicates.

This commit is contained in:
Félix Piédallu 2023-09-06 12:18:24 +02:00 committed by Salamandar
parent bb1505e55c
commit 68eed5b920
5 changed files with 30 additions and 54 deletions

View file

@ -40,8 +40,9 @@ domain="$new_domain"
sub_path_only="$(if [[ "$path" == "/" ]]; then echo '# ' ; else echo ''; fi)"
ynh_add_config --template="../conf/ihatemoney.cfg" --destination="$install_dir/ihatemoney.cfg"
chmod 640 "$install_dir/ihatemoney.cfg"
chown $app:$app "$install_dir/ihatemoney.cfg"
chown "$app:$app" "$install_dir/ihatemoney.cfg"
#=================================================
# GENERIC FINALISATION
@ -51,7 +52,7 @@ chown $app:$app "$install_dir/ihatemoney.cfg"
ynh_script_progression --message="Starting a systemd service..." --weight=5
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
ynh_systemd_action --service_name="$app" --action="start"
wait_gunicorn_start
#=================================================

View file

@ -19,10 +19,6 @@ ynh_script_progression --message="Building venv..." --weight=6
__ynh_python_venv_setup --venv_dir="$install_dir/venv" --packages "${pip_dependencies[*]}"
python_venv_site_packages=$(__ynh_python_venv_get_site_packages_dir -d "$install_dir/venv")
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -39,26 +35,23 @@ ynh_script_progression --message="Adding a configuration file..."
# Secret key for cookies encryption.
secret_key=$(ynh_string_random --length=32)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key"
hashed_password=$(_hash_password "$password")
ynh_secure_remove --file="$install_dir/key.txt"
ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
ynh_add_config --template="../conf/gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
chmod 640 "$install_dir/gunicorn.conf.py"
chown $app:$app "$install_dir/gunicorn.conf.py"
ynh_app_setting_set --app="$app" --key=hashed_password --value="$hashed_password"
# Allows to comment some config lines if not using sub path
sub_path_only="$(if [[ "$path" == "/" ]]; then echo '# ' ; else echo ''; fi)"
ynh_add_config --template="../conf/gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
ynh_add_config --template="../conf/ihatemoney.cfg" --destination="$install_dir/ihatemoney.cfg"
chmod 640 "$install_dir/ihatemoney.cfg"
chown $app:$app "$install_dir/ihatemoney.cfg"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
# Configure log directory
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
chown -R "$app:$app" "/var/log/$app"
#=================================================
# SETUP SYSTEMD
@ -75,7 +68,7 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for IHateMoney" --log=systemd
yunohost service add "$app" --description="$app daemon for IHateMoney" --log=systemd
#=================================================
# START SYSTEMD SERVICE
@ -83,7 +76,7 @@ yunohost service add $app --description="$app daemon for IHateMoney" --log=syste
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
ynh_systemd_action --service_name="$app" --action="start" --line_match="Listening at"
wait_gunicorn_start
#=================================================

View file

@ -14,20 +14,15 @@ source /usr/share/yunohost/helpers
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
ynh_script_progression --message="Removing $app service integration..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
yunohost service remove "$app"
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
@ -35,7 +30,6 @@ ynh_remove_systemd_config
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================

View file

@ -17,10 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
@ -35,7 +31,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#=================================================
# RESTORE SYSTEMD
@ -43,7 +39,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
systemctl enable "$app.service" --quiet
#=================================================
# RESTORE LOG
@ -56,14 +52,14 @@ ynh_restore_file --origin_path="/var/log/$app"
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for IHateMoney" --log=systemd
yunohost service add "$app" --description="$app daemon for IHateMoney" --log=systemd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
ynh_systemd_action --service_name="$app" --action="start" --line_match="Listening at"
wait_gunicorn_start
#=================================================

View file

@ -31,7 +31,7 @@ fi
if [[ "$upgrade_from_opt" == "false" ]]; then
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemd_action --service_name="$app" --action="stop"
fi
#=================================================
@ -62,31 +62,30 @@ if [[ "$upgrade_from_opt" == "true" ]]; then
done
install_dir=/var/www/$app
ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir"
db_name=ihatemoney
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
fi
# If secret_key doesn't exist, create it
if [ -z "${secret_key:-}" ]; then
secret_key=$(ynh_string_random --length=32)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key"
fi
# If hashed_password doesn't exist, create it
if [ -z "${hashed_password:-}" ]; then
password=$(ynh_string_random --length=16)
hashed_password=$(_hash_password "$password")
ynh_secure_remove --file="$install_dir/key.txt"
ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
ynh_app_setting_set --app="$app" --key=hashed_password --value="$hashed_password"
fi
if [ ! -d "/var/log/$app" ]; then
# Configure log directory
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
chown -R "$app:$app" "/var/log/$app"
fi
@ -101,10 +100,6 @@ ynh_secure_remove --file="$install_dir/venv"
__ynh_python_venv_setup --venv_dir="$install_dir/venv" --packages "${pip_dependencies[*]}"
python_venv_site_packages=$(__ynh_python_venv_get_site_packages_dir -d "$install_dir/venv")
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -119,23 +114,20 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
chmod 640 "$install_dir/gunicorn.conf.py"
chown $app:$app "$install_dir/gunicorn.conf.py"
# Allows to comment some config lines if not using sub path
sub_path_only="$(if [[ "$path" == "/" ]]; then echo '# ' ; else echo ''; fi)"
ynh_add_config --template="../conf/gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
ynh_add_config --template="../conf/ihatemoney.cfg" --destination="$install_dir/ihatemoney.cfg"
chmod 640 "$install_dir/ihatemoney.cfg"
chown $app:$app "$install_dir/ihatemoney.cfg"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
@ -145,14 +137,14 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for IHateMoney" --log=systemd
yunohost service add "$app" --description="$app daemon for IHateMoney" --log=systemd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
ynh_systemd_action --service_name="$app" --action="start" --line_match="Listening at"
wait_gunicorn_start
#=================================================