mirror of
https://github.com/YunoHost-Apps/aeneria_ynh.git
synced 2024-09-03 18:06:15 +02:00
commit
0848b0b4b3
7 changed files with 63 additions and 111 deletions
|
@ -1 +1 @@
|
||||||
*/20 * * * * #USER# php7.3 #DESTDIR#/bin/console aeneria:fetch-data
|
*/20 * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/bin/console aeneria:fetch-data
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "aeneria",
|
"name": "æneria",
|
||||||
"id": "aeneria",
|
"id": "aeneria",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Dashboard to analyse your energy consumption data from Linky & weather",
|
"en": "Dashboard to analyse your energy consumption data from Linky & weather",
|
||||||
"fr": "Tableau de bord pour analyser votre consomation d'énergie à partir des données d'un Linky et de la météo"
|
"fr": "Tableau de bord pour analyser votre consomation d'énergie à partir des données d'un Linky et de la météo"
|
||||||
},
|
},
|
||||||
"version": "1.1.5~ynh1",
|
"version": "1.1.5~ynh2",
|
||||||
"url": "https://gitlab.com/aeneria/aeneria-app",
|
"url": "https://gitlab.com/aeneria/aeneria-app",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"email": "bonjour@aeneria.com"
|
"email": "bonjour@aeneria.com"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 4.1.7"
|
"yunohost": ">= 4.2.4"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
|
|
@ -19,19 +19,6 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql ph
|
||||||
# EXPERIMENTAL HELPERS
|
# 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.
|
# Check available space before creating a temp directory.
|
||||||
#
|
#
|
||||||
# usage: ynh_smart_mktemp --min_size="Min size"
|
# usage: ynh_smart_mktemp --min_size="Min size"
|
||||||
|
|
|
@ -57,7 +57,15 @@ ynh_app_setting_set --app=$app --key=deskey --value=$deskey
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less 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 PSQL DATABASE
|
# CREATE A PSQL DATABASE
|
||||||
|
@ -80,6 +88,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
|
||||||
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -88,14 +100,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||||
# 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=1
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -124,10 +128,6 @@ chmod 600 "$aeneria_conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing aeneria..." --weight=1
|
ynh_script_progression --message="Installing aeneria..." --weight=1
|
||||||
|
|
||||||
# Set permissions to app files
|
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 755 $final_path
|
|
||||||
|
|
||||||
# Install aeneria
|
# Install aeneria
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
ynh_exec_as $app php$phpversion bin/console aeneria:install "$app" -n
|
ynh_exec_as $app php$phpversion bin/console aeneria:install "$app" -n
|
||||||
|
@ -148,15 +148,11 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET UP CRON JOB
|
# SET UP CRON JOB
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setuping a cron job..." --weight=1
|
ynh_script_progression --message="Setuping a cron..." --weight=1
|
||||||
|
|
||||||
cron_path="/etc/cron.d/$app"
|
ynh_add_config --template="../conf/aeneria.cron" --destination="/etc/cron.d/$app"
|
||||||
cp -a ../conf/aeneria.cron "$cron_path"
|
chown root: "/etc/cron.d/$app"
|
||||||
chown root: "$cron_path"
|
chmod 644 "/etc/cron.d/$app"
|
||||||
chmod 644 "$cron_path"
|
|
||||||
|
|
||||||
ynh_replace_string "#USER#" "$app" "$cron_path"
|
|
||||||
ynh_replace_string "#DESTDIR#" "$final_path" "$cron_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADAPT HOOK FOR AENERIA INSTANCE
|
# ADAPT HOOK FOR AENERIA INSTANCE
|
||||||
|
@ -166,17 +162,6 @@ ynh_script_progression --message="Adapting hooks..." --weight=1
|
||||||
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string="$app" --target_file="../hooks/post_user_create"
|
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string="$app" --target_file="../hooks/post_user_create"
|
||||||
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string="$app" --target_file="../hooks/post_user_delete"
|
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string="$app" --target_file="../hooks/post_user_delete"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# SECURE FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Securing files and directories..." --weight=1
|
|
||||||
|
|
||||||
# Set permissions to app files
|
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 755 $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -50,7 +50,7 @@ ynh_secure_remove --file="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -58,7 +58,7 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE PHP-FPM CONFIGURATION
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing php-fpm configuration..." --weight=1
|
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
|
||||||
|
|
||||||
# Remove the dedicated php-fpm config
|
# Remove the dedicated php-fpm config
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
|
|
@ -36,8 +36,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|
||||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
|
@ -50,6 +48,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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -57,21 +63,9 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
chmod 750 "$final_path"
|
||||||
# RECREATE THE DEDICATED USER
|
chmod -R o-rwx "$final_path"
|
||||||
#=================================================
|
chown -R $app:www-data "$final_path"
|
||||||
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
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring user rights..."
|
|
||||||
|
|
||||||
# Restore permissions on app files
|
|
||||||
chown -R $app: $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
@ -92,7 +86,7 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PSQL DATABASE
|
# RESTORE THE PSQL DATABASE
|
||||||
|
|
|
@ -33,6 +33,20 @@ ynh_script_progression --message="Checking version..."
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,18 +72,12 @@ if ynh_legacy_permissions_exists; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Create a dedicated user (if not existing)
|
||||||
ynh_backup_before_upgrade
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
ynh_clean_setup () {
|
|
||||||
# restore it if the upgrade fails
|
|
||||||
ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -99,6 +107,10 @@ then
|
||||||
ynh_secure_remove --file="$tmpdir"
|
ynh_secure_remove --file="$tmpdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -112,15 +124,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
|
@ -149,10 +153,6 @@ chmod 600 "$aeneria_conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading aeneria..." --weight=1
|
ynh_script_progression --message="Upgrading aeneria..." --weight=1
|
||||||
|
|
||||||
# Set permissions on app files
|
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 755 $final_path
|
|
||||||
|
|
||||||
# Install dependencies and aeneria
|
# Install dependencies and aeneria
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
ynh_exec_as $app php$phpversion bin/console cache:clear -n
|
ynh_exec_as $app php$phpversion bin/console cache:clear -n
|
||||||
|
@ -183,32 +183,18 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setuping a cron job..." --weight=1
|
ynh_script_progression --message="Setuping a cron job..." --weight=1
|
||||||
|
|
||||||
cron_path="/etc/cron.d/$app"
|
ynh_add_config --template="../conf/aeneria.cron" --destination="/etc/cron.d/$app"
|
||||||
cp -a ../conf/aeneria.cron "$cron_path"
|
chown root: "/etc/cron.d/$app"
|
||||||
chown root: "$cron_path"
|
chmod 644 "/etc/cron.d/$app"
|
||||||
chmod 644 "$cron_path"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="#USER#" --replace_string="$app" --target_file="$cron_path"
|
|
||||||
ynh_replace_string --match_string="#DESTDIR#" --replace_string="$final_path" --target_file="$cron_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADAPT HOOK FOR AENERIA INSTANCE
|
# ADAPT HOOK FOR AENERIA INSTANCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adapting hooks..." --weight=1
|
ynh_script_progression --message="Adapting hooks..." --weight=1
|
||||||
|
|
||||||
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_create"
|
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_create"
|
||||||
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_delete"
|
ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_delete"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# SECURE FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Securing files and directories..."
|
|
||||||
|
|
||||||
# Set permissions on app files
|
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 755 $final_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue