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

Merge pull request #47 from YunoHost-Apps/example

Example
This commit is contained in:
yalh76 2022-03-14 20:29:14 +01:00 committed by GitHub
commit 0fb4570527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 31 additions and 89 deletions

4
.gitignore vendored
View file

@ -1,4 +0,0 @@
budget/budget.db
budget/memory
budget/settings.py
*.pyc

View file

@ -15,7 +15,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Simple app to manage your collective expenses I hate money is a web application made to ease shared budget management. It keeps track of who bought what, when, and for whom; and helps to settle the bills.
**Shipped version:** 4.1.5~ynh3 **Shipped version:** 4.1.5~ynh3

View file

@ -11,7 +11,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble ## Vue d'ensemble
Gérez simplement vos dépenses collectives I hate money is a web application made to ease shared budget management. It keeps track of who bought what, when, and for whom; and helps to settle the bills.
**Version incluse :** 4.1.5~ynh3 **Version incluse :** 4.1.5~ynh3

View file

@ -3,10 +3,6 @@ location __PATH__/static/ {
alias __PYTHON_VENV_SITE_PACKAGES__/ihatemoney/static/; alias __PYTHON_VENV_SITE_PACKAGES__/ihatemoney/static/;
} }
location __PATH__/ { location __PATH__/ {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
I hate money is a web application made to ease shared budget management. It keeps track of who bought what, when, and for whom; and helps to settle the bills.

View file

@ -6,9 +6,8 @@
"en": "Simple app to manage your collective expenses", "en": "Simple app to manage your collective expenses",
"fr": "Gérez simplement vos dépenses collectives" "fr": "Gérez simplement vos dépenses collectives"
}, },
"url": "http://ihatemoney.org/",
"version": "4.1.5~ynh3", "version": "4.1.5~ynh3",
"license": "MIT", "url": "http://ihatemoney.org/",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",
"website": "https://github.com/spiral-project/ihatemoney", "website": "https://github.com/spiral-project/ihatemoney",
@ -16,16 +15,21 @@
"code": "https://github.com/spiral-project/ihatemoney", "code": "https://github.com/spiral-project/ihatemoney",
"demo": "https://ihatemoney.org/demo/" "demo": "https://ihatemoney.org/demo/"
}, },
"license": "MIT",
"maintainer": { "maintainer": {
"name": "Jocelyn Delalande", "name": "Jocelyn Delalande",
"email": "jocelyn@crapouillou.net", "email": "jocelyn@crapouillou.net",
"url": "https://jocelyn.delalande.fr" "url": "https://jocelyn.delalande.fr"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.0" "yunohost": ">= 4.3.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": ["nginx", "mysql", "postfix"], "services": [
"nginx",
"postfix",
"mysql"
],
"arguments": { "arguments": {
"install" : [ "install" : [
{ {

View file

@ -17,7 +17,8 @@ pip_dependencies=(
'gunicorn>=19.3.0' 'gunicorn>=19.3.0'
'PyMySQL>=0.9,<0.10' 'PyMySQL>=0.9,<0.10'
'SQLAlchemy<1.4' 'SQLAlchemy<1.4'
'ihatemoney>=4,<5' 'ihatemoney==4.1.5'
'markupsafe==2.0.1'
) )
### Constants ### Constants

View file

@ -33,11 +33,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fill the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -50,13 +45,6 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
@ -70,9 +58,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
ynh_print_info --message="Backing up the MySQL database..." ynh_print_info --message="Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db --database="$db_name" > db.sql ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================

View file

@ -42,6 +42,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
@ -134,6 +135,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=5 ynh_script_progression --message="Starting a systemd service..." --weight=5
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
#================================================= #=================================================

View file

@ -13,6 +13,9 @@ 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
@ -156,14 +159,6 @@ for _ in {1..20}; do
sleep 1 sleep 1
done done
#=================================================
# SETUP FAIL2BAN
#=================================================
# ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================

View file

@ -50,14 +50,6 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=2
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -75,12 +67,12 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
# ynh_script_progression --message="Removing Fail2ban configuration..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=2
# # Remove the dedicated Fail2Ban config # Remove metapackage and its dependencies
# ynh_remove_fail2ban_config ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE

View file

@ -14,6 +14,9 @@ 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,7 +32,6 @@ 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -44,7 +46,7 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
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"
@ -63,25 +65,10 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
# ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
# ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
# ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
# ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================

View file

@ -26,13 +26,8 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
if ynh_compare_current_package_version --comparison le --version "4.1.5~ynh2"; then if ynh_compare_current_package_version --comparison le --version "4.1.5~ynh2"; then
@ -49,6 +44,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
@ -163,16 +159,9 @@ mails_sender="no-reply@$domain"
# Allows to comment some config lines if not using sub path # Allows to comment some config lines if not using sub path
sub_path_only="$(if [[ "$path_url" == "/" ]]; then echo '# ' ; else echo ''; fi)" sub_path_only="$(if [[ "$path_url" == "/" ]]; then echo '# ' ; else echo ''; fi)"
ynh_add_config --template ../conf/ihatemoney.cfg --destination "$final_path/ihatemoney.cfg" ynh_add_config --template="../conf/ihatemoney.cfg" --destination="$final_path/ihatemoney.cfg"
chmod 600 "$final_path/ihatemoney.cfg" chmod 600 "$final_path/ihatemoney.cfg"
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
@ -205,14 +194,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
# FIXME: We need to wait for the db to upgrade and gunicorn to restart! # FIXME: We need to wait for the db to upgrade and gunicorn to restart!
sleep 3 sleep 3
#=================================================
# UPGRADE FAIL2BAN
#=================================================
# ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# # Create a dedicated Fail2Ban config
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================