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

Remove mapzen

This commit is contained in:
ericgaspar 2021-06-26 23:10:27 +02:00
parent a7c525d910
commit f6c69cfe97
No known key found for this signature in database
GPG key ID: 574F281483054D44
6 changed files with 156 additions and 78 deletions

View file

@ -1,8 +1,8 @@
;; Full test
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0)
domain="domain.tld"
path="/path"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
@ -13,21 +13,7 @@
upgrade=1
backup_restore=1
multi_instance=0
incorrect_path=1
port_already_use=0
change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# There is no user concept in ihatemoney
Level 4=1
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options
Email=
Notification=change

View file

@ -1,7 +1,10 @@
location PATHTOCHANGE/static/ {
location __PATH__/static/ {
alias /opt/yunohost/ihatemoney/venv/lib/pythonPYTHON_VERSION/site-packages/ihatemoney/static/;
}
location PATHTOCHANGE {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Force https.
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;

View file

@ -15,7 +15,7 @@
"url": "https://jocelyn.delalande.fr"
},
"requirements": {
"yunohost": ">= 3.8"
"yunohost": ">= 4.2.4"
},
"multi_instance": false,
"services": ["nginx", "mysql", "postfix"],
@ -24,29 +24,17 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for ihatemoney",
"fr": "Choisir un domaine pour ihatemoney"
},
"example": "example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for ihatemoney",
"fr": "Choisir un chemin pour ihatemoney"
},
"example": "/example",
"default": "/ihatemoney"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public website ? (even if service is public, each project is protected by a password)",
"fr": "Le service est-il public ? (même dans ce cas, chaque projet est protégé par un mot de passe)"
},
"default": true
}
]

View file

@ -1,3 +1,13 @@
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="python3-dev python3-virtualenv libffi-dev libssl-dev supervisor virtualenv"
### Constants
supervisor_conf_path="/etc/supervisor/conf.d/ihatemoney.conf"
@ -6,23 +16,6 @@ ihatemoney_conf_path="/etc/ihatemoney/ihatemoney.cfg"
INSTALL_DIR="/opt/yunohost/ihatemoney"
### Functions
install_apt_dependencies() {
ynh_install_app_dependencies \
python3-dev \
python3-virtualenv \
libffi-dev \
libssl-dev \
supervisor \
virtualenv
}
create_unix_user() {
mkdir -p /opt/yunohost
useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home || ynh_die "User creation failed"
}
create_system_dirs() {
install -o ihatemoney -g ihatemoney -m 755 -d \

View file

@ -1,25 +1,39 @@
#!/bin/bash
# Source YunoHost helpers
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Get multi-instances specific variables
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
# Set app specific variables
dbname=$app
dbuser=$app
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
INSTALL_DIR=/opt/yunohost/ihatemoney
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# Backup conf files
mkdir ./conf
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
@ -27,8 +41,18 @@ ynh_backup "$gunicorn_conf_path"
ynh_backup "$supervisor_conf_path"
ynh_backup "$ihatemoney_conf_path"
# Dump the database
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql
# Backup code and venv
ynh_backup "$INSTALL_DIR" "install_dir"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,14 +1,30 @@
#!/bin/bash
# Source YunoHost helpers
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
app=ihatemoney
app=$YNH_APP_INSTANCE_NAME
# Database settings
db_pwd=$(ynh_string_random)
@ -20,12 +36,52 @@ secret_key=$(ynh_string_random --length 32)
mails_sender="no-reply@${domain}"
ynh_abort_if_errors
ynh_webpath_register $app $domain $path
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
# Configure database
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
# Save app settings
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
@ -62,17 +118,23 @@ sed -i "/APPLICATION_ROOT='\/'/d" ../conf/ihatemoney.cfg
install -o ihatemoney -g ihatemoney -m 640 \
../conf/ihatemoney.cfg /etc/ihatemoney/ihatemoney.cfg
# If app is public, add url to SSOWat conf as skipped_uris
if [[ "$is_public" -ne 0 ]];
then
ynh_app_setting_set $app unprotected_uris "/"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
# Start a systemd service
ynh_systemd_action --service_name=supervisor --action="start" --log_path="/var/log/$app/$app.log"
# Configure Nginx
configure_nginx "$domain" "$path"
# Start backend
systemctl start supervisor
# Wait that gunicorn is ready to consider the install finished, that is to
# avoid HTTP 502 right after installation
@ -85,4 +147,26 @@ done
# If socket not ready after 2 minutes waiting, ihatemoney will not work.
test -S /tmp/budget.gunicorn.sock || ynh_die
systemctl reload nginx
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last