mirror of
https://github.com/YunoHost-Apps/monitorix_ynh.git
synced 2024-09-03 19:46:06 +02:00
Use new helper
This commit is contained in:
parent
9090436531
commit
290f0043ae
10 changed files with 169 additions and 282 deletions
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# See monitorix.conf(5) manpage for a detailed description of each option.
|
||||
#
|
||||
|
||||
|
||||
title = Yunohost Stats
|
||||
hostname = Yunohost Server
|
||||
theme_color = black
|
||||
|
@ -18,16 +18,16 @@ max_historic_years = 5
|
|||
accept_selfsigned_certs = y
|
||||
image_format = svg
|
||||
include_dir = /etc/monitorix/conf.d
|
||||
|
||||
|
||||
base_dir = /var/lib/monitorix/www/
|
||||
base_lib = /var/lib/monitorix/
|
||||
base_url = YNH_WWW_PATH
|
||||
base_cgi = YNH_WWW_PATH-cgi
|
||||
|
||||
base_url = __YNH_WWW_PATH__
|
||||
base_cgi = __YNH_WWW_PATH__-cgi
|
||||
|
||||
<httpd_builtin>
|
||||
enabled = y
|
||||
host = localhost
|
||||
port = SERVICE_PORT
|
||||
port = __SERVICE_PORT__
|
||||
user = www-data
|
||||
group = nogroup
|
||||
log_file = /var/log/monitorix-httpd
|
||||
|
@ -446,8 +446,8 @@ secure_log_date_format = %b %e
|
|||
# NGINX graph
|
||||
# -----------------------------------------------------------------------------
|
||||
<nginx>
|
||||
url = http://localhost:NGINX_STATUS_PORT/nginx_status_monitorix
|
||||
port = NGINX_STATUS_PORT
|
||||
url = http://localhost:__NGINX_STATUS_PORT__/nginx_status_monitorix
|
||||
port = __NGINX_STATUS_PORT__
|
||||
rule = 24100
|
||||
rigid = 0, 0, 0
|
||||
limit = 100, 100, 100
|
||||
|
@ -469,7 +469,7 @@ secure_log_date_format = %b %e
|
|||
conn_type = socket
|
||||
list = /var/run/mysqld/mysqld.sock
|
||||
<desc>
|
||||
/var/run/mysqld/mysqld.sock = 3306, MYSQL_USER, MYSQL_PASSWORD
|
||||
/var/run/mysqld/mysqld.sock = 3306, __MYSQL_USER__, MYSQL_PASSWORD
|
||||
</desc>
|
||||
rigid = 0, 2, 0, 0, 0, 0
|
||||
limit = 100, 100, 100, 100, 100, 100
|
||||
|
@ -733,9 +733,9 @@ secure_log_date_format = %b %e
|
|||
# -----------------------------------------------------------------------------
|
||||
<emailreports>
|
||||
enabled = n
|
||||
url_prefix = http://127.0.0.1:SERVICE_PORTYNH_WWW_PATH
|
||||
url_prefix = http://127.0.0.1:__SERVICE_PORT____YNH_WWW_PATH__
|
||||
smtp_hostname = localhost
|
||||
from_address = noreply@YNH_DOMAIN
|
||||
from_address = noreply@__YNH_DOMAIN__
|
||||
hour = 0
|
||||
minute = 0
|
||||
<daily>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
location YNH_WWW_PATH {
|
||||
proxy_pass http://127.0.0.1:SERVICE_PORTYNH_WWW_PATH;
|
||||
location __YNH_WWW_PATH__ {
|
||||
proxy_pass http://127.0.0.1:__SERVICE_PORT____YNH_WWW_PATH__;
|
||||
allow 127.0.0.0/8;
|
||||
|
||||
location ~ ^YNH_WWW_PATH/(.+\.png)$ {
|
||||
location ~ ^__YNH_WWW_PATH__/(.+\.png)$ {
|
||||
alias /var/lib/monitorix/www/$1;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"en": "A monitoring tools",
|
||||
"fr": "Un outils de monitoring"
|
||||
},
|
||||
"version": "3.9.0",
|
||||
"url": "http://monitorix.org",
|
||||
"license": "free",
|
||||
"maintainer": {
|
||||
|
@ -13,7 +14,7 @@
|
|||
"email": "josue@familletille.ch"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">> 2.4.0"
|
||||
"yunohost": ">= 2.6.4"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
## Adapt md5sum while you update app
|
||||
md5sum="7314ad6fcd014a34c2e4e8a95455bcaa"
|
||||
monitorix_version="3.9.0"
|
||||
|
||||
init_script() {
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
install_dependances() {
|
||||
ynh_install_app_dependencies rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm
|
||||
ynh_package_update
|
||||
dpkg -i /tmp/monitorix.deb
|
||||
ynh_secure_remove /etc/monitorix/conf.d/00-debian.conf
|
||||
ynh_package_install -f
|
||||
}
|
||||
|
||||
get_source() {
|
||||
|
||||
wget -q -O '/tmp/monitorix.deb' "http://www.monitorix.org/monitorix_${monitorix_version}-izzy1_all.deb"
|
||||
|
||||
if [[ ! -e '/tmp/monitorix.deb' ]] || [[ $(md5sum '/tmp/monitorix.deb' | cut -d' ' -f1) != $md5sum ]]
|
||||
|
@ -25,56 +23,27 @@ get_source() {
|
|||
fi
|
||||
}
|
||||
|
||||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
||||
# $1 = Variable à vérifier
|
||||
# $2 = Texte à afficher en cas d'erreur
|
||||
test -n "$1" || (echo "$2" >&2 && false)
|
||||
config_nginx() {
|
||||
nginx_conf=../conf/nginx.conf
|
||||
ynh_replace_string __YNH_WWW_PATH__ $path $nginx_conf
|
||||
ynh_replace_string __SERVICE_PORT__ $http_port $nginx_conf
|
||||
cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Add special hostname for monitorix status
|
||||
nginx_status_conf=../conf/nginx_status.conf
|
||||
ynh_replace_string PORT $nginx_status_port $nginx_status_conf
|
||||
cp $nginx_status_conf /etc/nginx/conf.d/monitorix_status.conf
|
||||
|
||||
systemctl reload nginx.service
|
||||
}
|
||||
|
||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
||||
path="/$path" # Ajoute un / en début de path
|
||||
fi
|
||||
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère.
|
||||
path="${path:0:${#path}-1}" # Supprime le dernier caractère
|
||||
fi
|
||||
}
|
||||
|
||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
}
|
||||
|
||||
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
final_path=/var/www/$app
|
||||
if [ -e "$final_path" ]
|
||||
then
|
||||
echo "This path already contains a folder" >&2
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
### REMOVE SCRIPT
|
||||
|
||||
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx
|
||||
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
||||
echo "Delete nginx config"
|
||||
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo service nginx reload
|
||||
fi
|
||||
}
|
||||
config_monitorix() {
|
||||
monitorix_conf=../conf/monitorix.conf
|
||||
ynh_replace_string __SERVICE_PORT__ $http_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 $monitorix_conf
|
||||
ynh_replace_string __MYSQL_USER__ $dbuser $monitorix_conf
|
||||
ynh_replace_string MYSQL_PASSWORD $dbpass $monitorix_conf
|
||||
cp $monitorix_conf /etc/monitorix/monitorix.conf
|
||||
}
|
|
@ -1,33 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
|
||||
# # Import common cmd
|
||||
# source ./_common.sh
|
||||
#
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
######## We implement manually this fonctions
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
init_script() {
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
# Import common cmd
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
# Retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
}
|
||||
|
||||
######## End of common fonctions
|
||||
|
||||
# Init script
|
||||
init_script
|
||||
|
||||
# # Dump the database
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||
|
||||
# Copy NGINX configuration
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
|
55
scripts/change_url
Normal file
55
scripts/change_url
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Import common cmd
|
||||
source ./_common.sh
|
||||
|
||||
# Retrive arguments
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$(ynh_normalize_url_path $YNH_APP_OLD_PATH)
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$(ynh_normalize_url_path $YNH_APP_NEW_PATH)
|
||||
http_port=$(ynh_app_setting_get "$app" http_port)
|
||||
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
# STANDARD MODIFICATIONS
|
||||
# MODIFY URL IN NGINX CONF
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path"
|
||||
ynh_replace_string "http://127.0.0.1:$http_port$old_path;" "http://127.0.0.1:$http_port$new_path;" "$nginx_conf_path"
|
||||
ynh_replace_string "location ~ ^$old_path/(.+\.png)$" "location ~ ^$new_path/(.+\.png)$" "$nginx_conf_path"
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
fi
|
||||
|
||||
# Update Monitorix Config
|
||||
ynh_replace_string "base_url = $old_path" "base_url = $new_path" /etc/monitorix/monitorix.conf
|
||||
ynh_replace_string "base_cgi = $old_path-cgi" "base_cgi = $new_path-cgi" /etc/monitorix/monitorix.conf
|
||||
ynh_replace_string "url_prefix = http://127.0.0.1:$http_port$old_path" "url_prefix = http://127.0.0.1:$http_port$new_path" /etc/monitorix/monitorix.conf
|
||||
ynh_replace_string "from_address = noreply@$old_domain" "from_address = noreply@$new_domain" /etc/monitorix/monitorix.conf
|
||||
|
||||
# Reload services
|
||||
sudo systemctl reload nginx.service
|
||||
sudo systemctl restart monitorix.service
|
|
@ -1,38 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Import common cmd
|
||||
source ./_common.sh
|
||||
|
||||
# Init script
|
||||
init_script
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
|
||||
# Correct path if it is not correct
|
||||
CHECK_PATH
|
||||
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain or path."
|
||||
ynh_webpath_register $app $domain $path
|
||||
|
||||
# Download package
|
||||
get_source
|
||||
|
||||
# Install package
|
||||
ynh_package_update
|
||||
ynh_package_install rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm
|
||||
sudo dpkg -i /tmp/monitorix.deb
|
||||
sudo rm -rf /etc/monitorix/conf.d/00-debian.conf
|
||||
ynh_package_install -f
|
||||
install_dependances
|
||||
|
||||
# # Generate MySQL password and create database
|
||||
# # Generate MySQL user
|
||||
dbuser=$app
|
||||
dbname=$app
|
||||
dbpass=$(ynh_string_random 12)
|
||||
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_create_user $dbuser $dbpass
|
||||
|
||||
# Find a port for built-in monitorix HTTP server
|
||||
http_port=$(ynh_find_port 8080)
|
||||
|
@ -41,31 +36,14 @@ nginx_status_port=$(ynh_find_port $(($http_port +1)))
|
|||
ynh_app_setting_set $app http_port $http_port
|
||||
ynh_app_setting_set $app nginx_status_port $nginx_status_port
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
nginx_conf=../conf/nginx.conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
||||
sed -i "s@SERVICE_PORT@$http_port@g" $nginx_conf
|
||||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Add special hostname for monitorix status
|
||||
nginx_status_conf=../conf/nginx_status.conf
|
||||
sed -i "s@PORT@$nginx_status_port@g" $nginx_status_conf
|
||||
sudo cp $nginx_status_conf /etc/nginx/conf.d/monitorix_status.conf
|
||||
# Config nginx
|
||||
config_nginx
|
||||
|
||||
# Update monitorix configuration
|
||||
monitorix_conf=../conf/monitorix.conf
|
||||
sed -i "s@SERVICE_PORT@$http_port@g" $monitorix_conf
|
||||
sed -i "s@YNH_DOMAIN@$domain@g" $monitorix_conf
|
||||
sed -i "s@NGINX_STATUS_PORT@$nginx_status_port@g" $monitorix_conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $monitorix_conf
|
||||
sed -i "s@MYSQL_USER@$dbuser@g" $monitorix_conf
|
||||
sed -i "s@MYSQL_PASSWORD@$dbpass@g" $monitorix_conf
|
||||
sudo cp $monitorix_conf /etc/monitorix/monitorix.conf
|
||||
config_monitorix
|
||||
|
||||
# register yunohost service
|
||||
sudo yunohost service add monitorix
|
||||
yunohost service add monitorix
|
||||
|
||||
# Reload services
|
||||
sudo service monitorix restart
|
||||
sudo yunohost app ssowatconf
|
||||
sudo service nginx reload
|
||||
systemctl restart monitorix.service
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
set -u
|
||||
|
||||
# Import common cmd
|
||||
source ./_common.sh
|
||||
|
||||
# Init script
|
||||
init_script
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
||||
# Stop service
|
||||
sudo service monitorix stop || true
|
||||
systemctl stop monitorix.service
|
||||
|
||||
# Remove nginx configuration file
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
# Suppression de la configuration nginx
|
||||
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
systemctl reload nginx.service
|
||||
|
||||
# Drop MySQL database and user
|
||||
dbname=$app
|
||||
|
@ -22,9 +26,7 @@ ynh_mysql_drop_db "$dbname" || true
|
|||
ynh_mysql_drop_user "$dbuser" || true
|
||||
|
||||
# Autoremove package
|
||||
ynh_remove_app_dependencies
|
||||
ynh_package_autoremove monitorix
|
||||
|
||||
sudo yunohost service remove monitorix
|
||||
|
||||
# Reload nginx service
|
||||
sudo service nginx reload
|
||||
yunohost service remove monitorix
|
||||
|
|
121
scripts/restore
121
scripts/restore
|
@ -1,122 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
|
||||
# # Import common cmd
|
||||
# source ./_common.sh
|
||||
#
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
######## We implement manually this fonctions
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
## Adapt md5sum while you update app
|
||||
md5sum="7314ad6fcd014a34c2e4e8a95455bcaa"
|
||||
monitorix_version="3.9.0"
|
||||
|
||||
init_script() {
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
}
|
||||
|
||||
get_source() {
|
||||
|
||||
wget -q -O '/tmp/monitorix.deb' "http://www.monitorix.org/monitorix_${monitorix_version}-izzy1_all.deb"
|
||||
|
||||
if [[ ! -e '/tmp/monitorix.deb' ]] || [[ $(md5sum '/tmp/monitorix.deb' | cut -d' ' -f1) != $md5sum ]]
|
||||
then
|
||||
ynh_die "Error : can't get monitorix debian package"
|
||||
fi
|
||||
}
|
||||
|
||||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
||||
# $1 = Variable à vérifier
|
||||
# $2 = Texte à afficher en cas d'erreur
|
||||
test -n "$1" || (echo "$2" >&2 && false)
|
||||
}
|
||||
|
||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
||||
path="/$path" # Ajoute un / en début de path
|
||||
fi
|
||||
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère.
|
||||
path="${path:0:${#path}-1}" # Supprime le dernier caractère
|
||||
fi
|
||||
}
|
||||
|
||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
}
|
||||
|
||||
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
final_path=/var/www/$app
|
||||
if [ -e "$final_path" ]
|
||||
then
|
||||
echo "This path already contains a folder" >&2
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
### REMOVE SCRIPT
|
||||
|
||||
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx
|
||||
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
||||
echo "Delete nginx config"
|
||||
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo service nginx reload
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
######## End of common fonctions
|
||||
|
||||
# Init script
|
||||
init_script
|
||||
|
||||
# Note: each files and directories you've saved using the ynh_backup helper
|
||||
# will be located in the current directory, regarding the last argument.
|
||||
# Import common cmd
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
# Retrieve old app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
|
||||
# Correct path if it is not correct
|
||||
CHECK_PATH
|
||||
path=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain or path."
|
||||
|
||||
# Download package
|
||||
get_source
|
||||
|
||||
# Download package
|
||||
get_source
|
||||
|
||||
# Install package
|
||||
ynh_package_update
|
||||
ynh_package_install rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl
|
||||
sudo dpkg -i /tmp/monitorix.deb
|
||||
sudo rm -rf /etc/monitorix/conf.d/00-debian.conf
|
||||
ynh_package_install -f
|
||||
install_dependances
|
||||
|
||||
# # Create and restore the database
|
||||
dbname=$app
|
||||
# Create user for database
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
|
||||
ynh_mysql_create_user $dbuser $dbpass
|
||||
|
||||
# Restore NGINX configuration
|
||||
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sudo cp -a ./monitorix_status.conf "/etc/nginx/conf.d/monitorix_status.conf"
|
||||
# Restore all config and data
|
||||
ynh_restore
|
||||
|
||||
# Restore Monitorix configuration
|
||||
sudo cp -a ./config/. "/etc/monitorix/."
|
||||
sudo cp -a ./data/. "/var/lib/monitorix/."
|
||||
|
||||
|
||||
# Restart webserver
|
||||
sudo service monitorix restart
|
||||
sudo yunohost app ssowatconf
|
||||
sudo service nginx reload
|
||||
# Reload services
|
||||
systemctl restart monitorix.service
|
|
@ -1,52 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Import common cmd
|
||||
source ./_common.sh
|
||||
|
||||
# Init script
|
||||
init_script
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
path=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
|
||||
http_port=$(ynh_app_setting_get "$app" http_port)
|
||||
nginx_status_port=$(ynh_app_setting_get "$app" nginx_status_port)
|
||||
dbuser=$app
|
||||
dbname=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
|
||||
# Correct path if it is not correct
|
||||
CHECK_PATH
|
||||
|
||||
# Download package
|
||||
get_source
|
||||
|
||||
# Update package
|
||||
sudo dpkg -i /tmp/monitorix.deb
|
||||
sudo rm -rf /etc/monitorix/conf.d/00-debian.conf
|
||||
dpkg -i /tmp/monitorix.deb
|
||||
ynh_secure_remove /etc/monitorix/conf.d/00-debian.conf
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
nginx_conf=../conf/nginx.conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
||||
sed -i "s@SERVICE_PORT@$http_port@g" $nginx_conf
|
||||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Add special hostname for monitorix status
|
||||
nginx_status_conf=../conf/nginx_status.conf
|
||||
sed -i "s@PORT@$nginx_status_port@g" $nginx_status_conf
|
||||
sudo cp $nginx_status_conf /etc/nginx/conf.d/monitorix_status.conf
|
||||
# Update nginx config
|
||||
config_nginx
|
||||
|
||||
# Update monitorix configuration
|
||||
monitorix_conf=../conf/monitorix.conf
|
||||
sed -i "s@SERVICE_PORT@$http_port@g" $monitorix_conf
|
||||
sed -i "s@YNH_DOMAIN@$domain@g" $monitorix_conf
|
||||
sed -i "s@NGINX_STATUS_PORT@$nginx_status_port@g" $monitorix_conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $monitorix_conf
|
||||
sed -i "s@MYSQL_USER@$dbuser@g" $monitorix_conf
|
||||
sed -i "s@MYSQL_PASSWORD@$dbpass@g" $monitorix_conf
|
||||
sudo cp $monitorix_conf /etc/monitorix/monitorix.conf
|
||||
config_monitorix
|
||||
|
||||
# Reload services
|
||||
sudo service monitorix restart
|
||||
sudo yunohost app ssowatconf
|
||||
sudo service nginx reload
|
||||
systemctl restart monitorix.service
|
||||
|
|
Loading…
Add table
Reference in a new issue