mirror of
https://github.com/YunoHost-Apps/monitorix_ynh.git
synced 2024-09-03 19:46:06 +02:00
Add message and use getops for helper's args
This commit is contained in:
parent
c7776743ff
commit
c5cf756a8a
10 changed files with 114 additions and 293 deletions
|
@ -39,10 +39,8 @@ This app have no specific authentification and no specific user management.
|
|||
|
||||
### Supported architectures
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/monitorix%20(Community).svg)](https://ci-apps.yunohost.org/ci/apps/monitorix/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/monitorix%20(Community).svg)](https://ci-apps-arm.yunohost.org/ci/apps/monitorix/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/jenkins/job/monitorix%20(Community).svg)](https://ci-stretch.nohost.me/jenkins/job/monitorix/)
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/monitorix%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/monitorix/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/monitorix%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/monitorix/)
|
||||
|
||||
<!--Limitations
|
||||
-----------
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"email": "josue@familletille.ch"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.4"
|
||||
"yunohost": ">= 3.5.2.2"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -13,11 +13,11 @@ install_dependances() {
|
|||
}
|
||||
|
||||
get_install_source() {
|
||||
ynh_setup_source /tmp
|
||||
ynh_setup_source --dest_dir /tmp
|
||||
|
||||
ynh_package_update
|
||||
dpkg --force-confdef --force-confold -i /tmp/app.deb
|
||||
ynh_secure_remove /etc/monitorix/conf.d/00-debian.conf
|
||||
ynh_secure_remove --file=/etc/monitorix/conf.d/00-debian.conf
|
||||
ynh_package_install -f
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ config_nginx() {
|
|||
# Add special hostname for monitorix status
|
||||
nginx_status_conf="/etc/nginx/conf.d/monitorix_status.conf"
|
||||
cp ../conf/nginx_status.conf $nginx_status_conf
|
||||
ynh_replace_string __PORT__ $nginx_status_port $nginx_status_conf
|
||||
ynh_replace_string --match_string __PORT__ --replace_string $nginx_status_port --target_file $nginx_status_conf
|
||||
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ config_nginx() {
|
|||
config_monitorix() {
|
||||
monitorix_conf=/etc/monitorix/monitorix.conf
|
||||
cp ../conf/monitorix.conf $monitorix_conf
|
||||
ynh_replace_string __SERVICE_PORT__ $port $monitorix_conf
|
||||
ynh_replace_string __YNH_DOMAIN__ $domain $monitorix_conf
|
||||
ynh_replace_string __NGINX_STATUS_PORT__ $nginx_status_port $monitorix_conf
|
||||
ynh_replace_string "__YNH_WWW_PATH__/" "${path_url%/}/" $monitorix_conf
|
||||
ynh_replace_string __YNH_WWW_PATH__ $path_url $monitorix_conf
|
||||
ynh_replace_string __MYSQL_USER__ $dbuser $monitorix_conf
|
||||
ynh_replace_string __MYSQL_PASSWORD__ $dbpass $monitorix_conf
|
||||
ynh_replace_string --match_string __SERVICE_PORT__ --replace_string $port --target_file $monitorix_conf
|
||||
ynh_replace_string --match_string __YNH_DOMAIN__ --replace_string $domain --target_file $monitorix_conf
|
||||
ynh_replace_string --match_string __NGINX_STATUS_PORT__ --replace_string $nginx_status_port --target_file $monitorix_conf
|
||||
ynh_replace_string --match_string __YNH_WWW_PATH__/ --replace_string "${path_url%/}/" --target_file $monitorix_conf
|
||||
ynh_replace_string --match_string __YNH_WWW_PATH__ --replace_string $path_url --target_file $monitorix_conf
|
||||
ynh_replace_string --match_string __MYSQL_USER__ --replace_string $dbuser --target_file $monitorix_conf
|
||||
ynh_replace_string --match_string __MYSQL_PASSWORD__ --replace_string $dbpass --target_file $monitorix_conf
|
||||
}
|
||||
|
||||
set_permission() {
|
||||
|
|
|
@ -15,23 +15,27 @@ source ../settings/scripts/experimental_helper.sh
|
|||
source ../settings/scripts/_common.sh
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
|
||||
# Copy NGINX configuration
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/monitorix_status.conf" "monitorix_status.conf"
|
||||
ynh_script_progression --message="Backing up configuration..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
ynh_backup --src_path "/etc/nginx/conf.d/monitorix_status.conf"
|
||||
|
||||
# Copy hook
|
||||
ynh_backup "/etc/yunohost/hooks.d/post_iptable_rules/50-$app"
|
||||
ynh_backup --src_path "/etc/yunohost/hooks.d/post_iptable_rules/50-$app"
|
||||
|
||||
# Copy Monitorix configuration
|
||||
ynh_backup "/etc/monitorix" "config"
|
||||
ynh_backup --src_path "/etc/monitorix"
|
||||
|
||||
# Copy Monitorix data
|
||||
ynh_backup "/var/lib/monitorix" "data"
|
||||
ynh_script_progression --message="Backing up data..." --weight=10
|
||||
ynh_backup --src_path "/var/lib/monitorix"
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
|
@ -14,40 +14,49 @@ ynh_abort_if_errors
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrive arguments
|
||||
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'})
|
||||
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
domain=$YNH_APP_NEW_DOMAIN
|
||||
port=$(ynh_app_setting_get "$app" http_port)
|
||||
nginx_status_port=$(ynh_app_setting_get "$app" nginx_status_port)
|
||||
port=$(ynh_app_setting_get --app $app --key http_port)
|
||||
nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
|
||||
dbuser=$app
|
||||
dbname=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Updating nginx configuration..."
|
||||
|
||||
# Update nginx config
|
||||
if [ "$old_domain" != "$domain" ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
|
||||
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
config_nginx
|
||||
|
||||
ynh_script_progression --message="Updating monitorix configuration..."
|
||||
|
||||
# Update monitorix configuration
|
||||
config_monitorix
|
||||
|
||||
ynh_script_progression --message="Restarting monitorix services..." --weight=3
|
||||
# Reload monitorix
|
||||
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
||||
# So this fix that
|
||||
systemctl stop monitorix.service
|
||||
sleep 1
|
||||
pkill -f "monitorix-httpd listening on" || true
|
||||
ynh_check_starting ' - Ok, ready.' '/var/log/monitorix'
|
||||
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
|
|
|
@ -1,235 +0,0 @@
|
|||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: manifest - Path of the manifest to read
|
||||
# | arg: key - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
manifest="$1"
|
||||
key="$2"
|
||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version
|
||||
ynh_app_upstream_version () {
|
||||
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_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Read package version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number after ~ynh
|
||||
# In the last example it return 3
|
||||
#
|
||||
# usage: ynh_app_package_version
|
||||
ynh_app_package_version () {
|
||||
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_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/*~ynh/}"
|
||||
}
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Start or restart a service and follow its booting
|
||||
#
|
||||
# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name]
|
||||
#
|
||||
# | arg: Line to match - The line to find in the log to attest the service have finished to boot.
|
||||
# | arg: Log file - The log file to watch
|
||||
# | arg: Service name
|
||||
# /var/log/$app/$app.log will be used if no other log is defined.
|
||||
# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds.
|
||||
ynh_check_starting () {
|
||||
local line_to_match="$1"
|
||||
local service_name="${4:-$app}"
|
||||
local app_log="${2:-/var/log/$service_name/$service_name.log}"
|
||||
local timeout=${3:-300}
|
||||
|
||||
ynh_clean_check_starting () {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
|
||||
echo "Starting of $service_name" >&2
|
||||
systemctl stop $service_name
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
tail -F -n0 "$app_log" > "$templog" &
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
systemctl start $service_name
|
||||
|
||||
local i=0
|
||||
for i in `seq 1 $timeout`
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_to_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
|
||||
# Delete a file checksum from the app settings
|
||||
#
|
||||
# $app should be defined when calling this helper
|
||||
#
|
||||
# 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
|
||||
}
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
#
|
||||
# The file conf/app.src need to contains:
|
||||
#
|
||||
# SOURCE_URL=Address to download the app archive
|
||||
# SOURCE_SUM=Control sum
|
||||
# # (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# # default: sha256
|
||||
# SOURCE_SUM_PRG=sha256
|
||||
# # (Optional) Archive format
|
||||
# # default: tar.gz
|
||||
# SOURCE_FORMAT=tar.gz
|
||||
# # (Optional) Put false if sources are directly in the archive root
|
||||
# # default: true
|
||||
# SOURCE_IN_SUBDIR=false
|
||||
# # (Optionnal) Name of the local archive (offline setup support)
|
||||
# # default: ${src_id}.${src_format}
|
||||
# SOURCE_FILENAME=example.tar.gz
|
||||
# # (Optional) If it set as false don't extract the source.
|
||||
# # (Useful to get a debian package or a python wheel.)
|
||||
# # default: true
|
||||
# SOURCE_EXTRACT=(true|false)
|
||||
#
|
||||
# Details:
|
||||
# This helper downloads sources from SOURCE_URL if there is no local source
|
||||
# archive in /opt/yunohost-apps-src/APP_ID/SOURCE_FILENAME
|
||||
#
|
||||
# Next, it checks the integrity with "SOURCE_SUM_PRG -c --status" command.
|
||||
#
|
||||
# If it's ok, the source archive will be uncompressed in $dest_dir. If the
|
||||
# SOURCE_IN_SUBDIR is true, the first level directory of the archive will be
|
||||
# removed.
|
||||
#
|
||||
# Finally, patches named sources/patches/${src_id}-*.patch and extra files in
|
||||
# sources/extra_files/$src_id will be applied to dest_dir
|
||||
#
|
||||
#
|
||||
# usage: ynh_setup_source dest_dir [source_id]
|
||||
# | arg: dest_dir - Directory where to setup sources
|
||||
# | arg: source_id - Name of the app, if the package contains more than one app
|
||||
ynh_setup_source () {
|
||||
local dest_dir=$1
|
||||
local src_id=${2:-app} # If the argument is not given, source_id equals "app"
|
||||
|
||||
local src_file_path="$YNH_CWD/../conf/${src_id}.src"
|
||||
# In case of restore script the src file is in an other path.
|
||||
# So try to use the restore path if the general path point to no file.
|
||||
if [[ ! -e "$src_file_path" ]]; then
|
||||
src_file_path="$YNH_CWD/../settings/conf/${src_id}.src"
|
||||
fi
|
||||
|
||||
# Load value from configuration file (see above for a small doc about this file
|
||||
# format)
|
||||
local src_url=$(grep 'SOURCE_URL=' "$src_file_path" | cut -d= -f2-)
|
||||
local src_sum=$(grep 'SOURCE_SUM=' "$src_file_path" | cut -d= -f2-)
|
||||
local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$src_file_path" | cut -d= -f2-)
|
||||
local src_format=$(grep 'SOURCE_FORMAT=' "$src_file_path" | cut -d= -f2-)
|
||||
local src_extract=$(grep 'SOURCE_EXTRACT=' "$src_file_path" | cut -d= -f2-)
|
||||
local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$src_file_path" | cut -d= -f2-)
|
||||
local src_filename=$(grep 'SOURCE_FILENAME=' "$src_file_path" | cut -d= -f2-)
|
||||
|
||||
# Default value
|
||||
src_sumprg=${src_sumprg:-sha256sum}
|
||||
src_in_subdir=${src_in_subdir:-true}
|
||||
src_format=${src_format:-tar.gz}
|
||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||
src_extract=${src_extract:-true}
|
||||
if [ "$src_filename" = "" ] ; then
|
||||
src_filename="${src_id}.${src_format}"
|
||||
fi
|
||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
||||
|
||||
if test -e "$local_src"
|
||||
then # Use the local source file if it is present
|
||||
cp $local_src $src_filename
|
||||
else # If not, download the source
|
||||
local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out
|
||||
fi
|
||||
|
||||
# Check the control sum
|
||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|
||||
|| ynh_die "Corrupt source"
|
||||
|
||||
# Extract source into the app dir
|
||||
mkdir -p "$dest_dir"
|
||||
|
||||
if ! "$src_extract"
|
||||
then
|
||||
mv $src_filename $dest_dir
|
||||
elif [ "$src_format" = "zip" ]
|
||||
then
|
||||
# Zip format
|
||||
# Using of a temp directory, because unzip doesn't manage --strip-components
|
||||
if $src_in_subdir ; then
|
||||
local tmp_dir=$(mktemp -d)
|
||||
unzip -quo $src_filename -d "$tmp_dir"
|
||||
cp -a $tmp_dir/*/. "$dest_dir"
|
||||
ynh_secure_remove "$tmp_dir"
|
||||
else
|
||||
unzip -quo $src_filename -d "$dest_dir"
|
||||
fi
|
||||
else
|
||||
local strip=""
|
||||
if $src_in_subdir ; then
|
||||
strip="--strip-components 1"
|
||||
fi
|
||||
if [[ "$src_format" =~ ^tar.gz|tar.bz2|tar.xz$ ]] ; then
|
||||
tar -xf $src_filename -C "$dest_dir" $strip
|
||||
else
|
||||
ynh_die "Archive format unrecognized."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Apply patches
|
||||
if (( $(find $YNH_CWD/../sources/patches/ -type f -name "${src_id}-*.patch" 2> /dev/null | wc -l) > "0" )); then
|
||||
local old_dir=$(pwd)
|
||||
(cd "$dest_dir" \
|
||||
&& for p in $YNH_CWD/../sources/patches/${src_id}-*.patch; do \
|
||||
patch -p1 < $p; done) \
|
||||
|| ynh_die "Unable to apply patches"
|
||||
cd $old_dir
|
||||
fi
|
||||
|
||||
# Add supplementary files
|
||||
if test -e "$YNH_CWD/../sources/extra_files/${src_id}"; then
|
||||
cp -a $YNH_CWD/../sources/extra_files/$src_id/. "$dest_dir"
|
||||
fi
|
||||
}
|
|
@ -14,41 +14,51 @@ ynh_abort_if_errors
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_ARG_PATH)
|
||||
|
||||
# Check domain/path availability
|
||||
test $(ynh_webpath_available $domain $path_url) == 'True' || ynh_die "$domain$path_url is not available, please use an other domain or path."
|
||||
test $(ynh_webpath_available --domain $domain --path_url $path_url) == 'True' || ynh_die --message "$domain$path_url is not available, please use an other domain or path."
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
# Find a port for built-in monitorix HTTP server
|
||||
port=$(ynh_find_port 8080)
|
||||
nginx_status_port=$(ynh_find_port $(($port +1)))
|
||||
ynh_script_progression --message="Finding available ports..."
|
||||
port=$(ynh_find_port --port 8080)
|
||||
nginx_status_port=$(ynh_find_port --port $(($port +1)))
|
||||
|
||||
ynh_app_setting_set $app http_port $port
|
||||
ynh_app_setting_set $app nginx_status_port $nginx_status_port
|
||||
# store config in yunohost
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_app_setting_set --app $app --key http_port --value $port
|
||||
ynh_app_setting_set --app $app --key nginx_status_port --value $nginx_status_port
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
# Install package
|
||||
# Install package
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=7
|
||||
install_dependances
|
||||
|
||||
# Download package and install it
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
get_install_source
|
||||
|
||||
# # Generate MySQL user
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_string_random 12)
|
||||
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||
ynh_app_setting_set --app $app --key mysqlpwd --value "$dbpass"
|
||||
ynh_mysql_create_user $dbuser $dbpass
|
||||
|
||||
# Config nginx
|
||||
ynh_script_progression --message="Configuring nginx..." --weight=1
|
||||
config_nginx
|
||||
|
||||
# Update monitorix configuration
|
||||
ynh_script_progression --message="Configuring application..." --weight=3
|
||||
config_monitorix
|
||||
|
||||
#=================================================
|
||||
|
@ -56,15 +66,19 @@ config_monitorix
|
|||
#=================================================
|
||||
|
||||
# Set access
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# register yunohost service
|
||||
yunohost service add monitorix
|
||||
|
||||
# Reload monitorix
|
||||
ynh_script_progression --message="Starting monitorix services..." --weight=3
|
||||
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
||||
# So this fix that
|
||||
sudo systemctl stop monitorix.service
|
||||
systemctl stop monitorix.service
|
||||
sleep 1
|
||||
pkill -f "monitorix-httpd listening on" || true
|
||||
ynh_check_starting ' - Ok, ready.' '/var/log/monitorix'
|
||||
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -7,35 +7,47 @@
|
|||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
set -u
|
||||
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
||||
# Stop service
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
systemctl stop monitorix.service
|
||||
|
||||
# Drop MySQL database and user
|
||||
ynh_script_progression --message="Removing databases..."
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
ynh_mysql_drop_db "$dbname" || true
|
||||
ynh_mysql_drop_user "$dbuser" || true
|
||||
|
||||
# Remove data
|
||||
ynh_secure_remove /var/lib/monitorix
|
||||
ynh_script_progression --message="Removing logs..."
|
||||
ynh_secure_remove --file=/var/lib/monitorix
|
||||
|
||||
# Remove nginx config
|
||||
ynh_secure_remove "/etc/nginx/conf.d/monitorix_status.conf"
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/monitorix_status.conf"
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# Autoremove package
|
||||
ynh_script_progression --message="Removing dependencies" --weight=10
|
||||
ynh_remove_app_dependencies
|
||||
ynh_package_autoremove monitorix
|
||||
|
||||
yunohost service remove monitorix
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -14,31 +14,37 @@ ynh_abort_if_errors
|
|||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
# Retrieve old app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
||||
|
||||
# Check domain/path availability
|
||||
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain or path."
|
||||
ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path."
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
|
||||
# Install package
|
||||
# Install package
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
install_dependances
|
||||
|
||||
# Download package and install it
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
get_install_source
|
||||
|
||||
# Create user for database
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
ynh_mysql_create_user $dbuser $dbpass
|
||||
|
||||
# Restore all config and data
|
||||
ynh_secure_remove /etc/monitorix # we remove the directory because if it is not empty the ynh_restore cmd fail
|
||||
ynh_secure_remove /var/lib/monitorix
|
||||
ynh_script_progression --message="Restoring files..." --weight=10
|
||||
ynh_secure_remove --file=/etc/monitorix # we remove the directory because if it is not empty the ynh_restore cmd fail
|
||||
ynh_secure_remove --file=/var/lib/monitorix
|
||||
ynh_restore
|
||||
|
||||
#=================================================
|
||||
|
@ -46,15 +52,19 @@ ynh_restore
|
|||
#=================================================
|
||||
|
||||
# Set access
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Reload nginx
|
||||
systemctl reload nginx.service
|
||||
|
||||
# Reload monitorix
|
||||
ynh_script_progression --message="Starting monitorix services..." --weight=3
|
||||
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
||||
# So this fix that
|
||||
systemctl stop monitorix.service
|
||||
sleep 1
|
||||
pkill -f "monitorix-httpd listening on" || true
|
||||
ynh_check_starting ' - Ok, ready.' '/var/log/monitorix'
|
||||
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
|
@ -14,16 +14,19 @@ ynh_abort_if_errors
|
|||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
|
||||
port=$(ynh_app_setting_get "$app" http_port)
|
||||
nginx_status_port=$(ynh_app_setting_get "$app" nginx_status_port)
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
||||
port=$(ynh_app_setting_get --app $app --key http_port)
|
||||
nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
|
||||
dbuser=$app
|
||||
dbname=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
||||
|
||||
# Stop services
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
systemctl stop monitorix.service
|
||||
|
||||
# Backup the current version of the app
|
||||
|
@ -40,28 +43,34 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Download package and install it
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
get_install_source
|
||||
|
||||
# Update nginx config
|
||||
config_nginx
|
||||
|
||||
# Update monitorix configuration
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
config_monitorix
|
||||
|
||||
# Remove old hook if exist
|
||||
ynh_secure_remove /usr/share/yunohost/hooks/post_iptable_rules/50-$app
|
||||
ynh_secure_remove --file=/usr/share/yunohost/hooks/post_iptable_rules/50-$app
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set access
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Reload monitorix
|
||||
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
||||
# So this fix that
|
||||
sudo systemctl stop monitorix.service
|
||||
ynh_script_progression --message="Starting monitorix services..." --weight=3
|
||||
systemctl stop monitorix.service
|
||||
sleep 1
|
||||
pkill -f "monitorix-httpd listening on" || true
|
||||
ynh_check_starting ' - Ok, ready.' '/var/log/monitorix'
|
||||
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue