1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/aeneria_ynh.git synced 2024-09-03 18:06:15 +02:00

Merge pull request #1 from YunoHost-Apps/testing

Testing
This commit is contained in:
Simon MELLERIN 2020-12-31 14:26:57 +01:00 committed by GitHub
commit 1681641e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 113 additions and 66 deletions

View file

@ -1,7 +1,5 @@
# æneria for YunoHost
**DO NOT USE, WORK IN PROGRESS**
[![Integration level](https://dash.yunohost.org/integration/aeneria.svg)](https://dash.yunohost.org/appci/app/aeneria) ![](https://ci-apps.yunohost.org/ci/badges/aeneria.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/aeneria.maintain.svg)
[![Install æneria with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=aeneria)
@ -9,12 +7,12 @@
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
The idea of [æneria](https://gitlab.com/aeneria/aeneria-app) is to display electricity consumption and weather data on a little dashboard that allow the user to:
The idea of [æneria](https://gitlab.com/aeneria/aeneria-app) is to display energy consumption and weather data on a little dashboard that allow the user to:
* Better understand his electricity consumption
* Analyse his electricity consumption throw weather data
* Better understand our own energy consumption
* Analyse energy consumption throw weather data
**Shipped version:** 1.0.3
**Shipped version:** 1.0.4
## Screenshots
@ -22,8 +20,9 @@ The idea of [æneria](https://gitlab.com/aeneria/aeneria-app) is to display elec
## Configuration
* First of all, you'll need a Linky (obviously) and an [Enedis account](https://mon-compte-client.enedis.fr/)
* After you have installed the app, just visit it and follow instructions
* First of all, you'll need a Linky and an [Enedis account](https://mon-compte-client.enedis.fr/)
* In your Enedis space, go to ["Gérer l'accès à mes données"](https://mon-compte-particulier.enedis.fr/donnees/) tab, and allow Enedis to collect and store your hourly consumption
* After that, install æneria to your Yunohost instance, visit it and just follow instructions
* That's it, now wait a bit to see data appear !
## Documentation
@ -36,7 +35,7 @@ More information can be found on [æneria documentation](https://docs.aeneria.co
This new version introduced some breaking changes in data structure: migration from Pilea can't be done automaticly.
But don't worry, you can easilly transfer your data from Pilea to æneria, just follow [this documentation](https://docs.aeneria.com/fr/latest/administrateur/pilea_migration.html).
But don't worry, you can easilly transfer your data from Pilea to æneria following [this documentation](https://docs.aeneria.com/fr/latest/administrateur/pilea_migration.html).
## YunoHost specific features

View file

@ -13,7 +13,7 @@
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=702db62e7b25c06972301828b275529a087a98ba
upgrade=1 from_commit=25bf428e280f463fb85c3f8332b523415c56f816
backup_restore=1
multi_instance=1
incorrect_path=1
@ -25,5 +25,5 @@
Email=
Notification=change
;;; Upgrade options
; commit=702db62e7b25c06972301828b275529a087a98ba
; commit=25bf428e280f463fb85c3f8332b523415c56f816
name=1.0.3

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://statics.aeneria.com/aeneria-app-1.0.3.tar.gz
SOURCE_SUM=f61cf16edd8a435f693261243e2d671487f28e8253c17885da77397cd8878887
SOURCE_URL=https://statics.aeneria.com/aeneria-app-1.0.4.tar.gz
SOURCE_SUM=900e165d2992c1349b2ed1fff8fda7ec999b78c70e6a14043800defdb715a91d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -6,7 +6,7 @@
"en": "A little dashboard to analyse your electricity consumption data from Linky & weather",
"fr": "Un petit tableau de bord pour analyser votre consomation d'électricité à partir des données d'un Linky et de la météo"
},
"version": "1.0.3~ynh1",
"version": "1.0.4~ynh1",
"url": "https://gitlab.com/aeneria/aeneria-app",
"license": "AGPL-3.0-or-later",
"maintainer": {

View file

@ -19,6 +19,56 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql ph
# EXPERIMENTAL HELPERS
#=================================================
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
ynh_exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}
# Check available space before creating a temp directory.
#
# usage: ynh_smart_mktemp --min_size="Min size"
#
# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb
ynh_smart_mktemp () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=min_size= )
local min_size
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
min_size="${min_size:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(mktemp --directory --tmpdir="$tmpdir")"
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -21,10 +21,23 @@ new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -32,7 +45,7 @@ ynh_clean_setup () {
# 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"
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -45,13 +58,13 @@ ynh_abort_if_errors
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
change_path=1
fi
#=================================================
@ -59,42 +72,30 @@ fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Store path_url setting
ynh_app_setting_set --app=$app --key=path_url --value="$path_url"
# Create a dedicated nginx config
ynh_add_nginx_config
if [ "$path_url" = "/" ]
then
# Replace "//" location (due to nginx template)
# Prevent from replacing in "http://" expressions by excluding ":" as preceding character
sed --in-place "s@\([^:]\)//@\1/@g" "$nginx_conf_path"
else
# Move prefix comment #for-subdir at end of lines
sed --in-place "s/#for-subdir\(.*\)/\1 #for-subdir/g" "$nginx_conf_path"
fi
ynh_store_file_checksum --file="$nginx_conf_path"
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for nginx
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -102,7 +103,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@ -110,4 +111,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app"
ynh_script_progression --message="Change of URL completed for $app" --time --last

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_exec_as
source /usr/share/yunohost/helpers
#=================================================

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_exec_as
source /usr/share/yunohost/helpers
#=================================================
@ -85,8 +84,22 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
# For aeneria source update, we use a temporary directory because
# without it, patche can't be apply correctly:
# In 'app-00-ldap-auth.patch' we create a new file, if we try
# to apply the patch a second time while the file already exists, it
# throws a warning leading to an upgrade fail.
# Create tmpdir for new sources
tmpdir="$(ynh_smart_mktemp min_size=300)"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$tmpdir"
# Replace the old aeneria by the new one
ynh_secure_remove --file="$final_path"
mv "$tmpdir" "$final_path"
ynh_secure_remove --file="$tmpdir"
fi
#=================================================

View file

@ -1,14 +0,0 @@
#!/bin/bash
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
ynh_exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}

View file

@ -2,8 +2,6 @@ commit c7a763a0fae7e1933f280b29bd2a1911b01f7170
Author: Simon Mellerin <simon.mellerin@makina-corpus.com>
Date: Fri Nov 27 12:19:02 2020 +0100
toto
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 15ef608..8516775 100644
--- a/config/packages/security.yaml
@ -178,3 +176,4 @@ index 0000000..39ba1e8
+ return $values[0];
+ }
+}
--