1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grafana_ynh.git synced 2024-09-03 20:36:29 +02:00

Minor linter fixes

This commit is contained in:
Jimmy Monin 2017-12-03 19:24:03 +01:00
parent 9a207690ff
commit e5a150e077
7 changed files with 95 additions and 62 deletions

View file

@ -15,7 +15,7 @@
"url": ""
},
"requirements": {
"yunohost": ">> 2.4.0"
"yunohost": ">= 2.7.2"
},
"multi_instance": false,
"services": [

View file

@ -57,7 +57,7 @@ install_dependencies() {
# Install packages
# We install them as dependencies as they may already be installed and used for other purposes
ynh_app_dependencies influxdb, grafana \
ynh_install_app_dependencies influxdb, grafana \
|| {
# Remove apt repositories if they were added
[[ -n "$influxdb_repository_present" ]] && sudo rm $INFLUXDB_REPOSITORY
@ -66,56 +66,15 @@ install_dependencies() {
}
}
# ======== Future YunoHost helpers ========
# Install dependencies with a equivs control file
#
# usage: ynh_app_dependencies dep [dep [...]]
# | arg: dep - the package name to install in dependence
ynh_app_dependencies () {
dependencies=$@
manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version=$(sudo python3 -c "import sys, json;print(json.load(open(\"$manifest_path\"))['version'])") # Retrieve the version number in the manifest file.
dep_app=${app//_/-} # Replace all '_' by '-'
cat > ./${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies// /, }
Architecture: all
Description: Fake package for ${app} (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs ./${dep_app}-ynh-deps.control \
|| ynh_die "Unable to install dependencies" # Install the fake package and its dependencies
}
# Remove fake package and its dependencies
# Delete a file checksum from the app settings
#
# Dependencies will removed only if no other package need them.
# $app should be defined when calling this helper
#
# usage: ynh_remove_app_dependencies
ynh_remove_app_dependencies () {
dep_app=${app//_/-} # Replace all '_' by '-'
ynh_package_autoremove ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used.
}
# Find a free port and return it
#
# example: port=$(ynh_find_port 8080)
#
# usage: ynh_find_port begin_port
# | arg: begin_port - port to start to search
ynh_find_port () {
port=$1
test -n "$port" || ynh_die "The argument of ynh_find_port must be a valid port."
while netcat -z 127.0.0.1 $port # Check if the port is free
do
port=$((port+1)) # Else, pass to next port
done
echo $port
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}

View file

@ -1,8 +1,27 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Fetch helpers file if not in current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers

View file

@ -1,14 +1,27 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
shopt -s extglob # sets extended pattern matching options in the bash shell
app=$YNH_APP_INSTANCE_NAME
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source local helpers
source ./_common.sh
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors # Stop script if an error is detected
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN

View file

@ -1,7 +1,17 @@
#!/bin/bash
# Treat unset variables as an error
set -u
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
# See comments in install script
app=$YNH_APP_INSTANCE_NAME

View file

@ -1,7 +1,27 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Fetch helpers file if not in current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME

View file

@ -29,6 +29,18 @@ fi
# Fix path if needed
path=$(fix_path $path)
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Use prior backup and restore on error only if backup feature
# exists on installed instance
ynh_backup_before_upgrade # Backup the current version of the app
ynh_clean_setup () {
ynh_restore_upgradebackup
}
ynh_abort_if_errors # Stop script if an error is detected
# There's currently nothing else to upgrade than packaging files
# as InfluxDB/Grafana updates are managed through APT