1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/monitorix_ynh.git synced 2024-09-03 19:46:06 +02:00
monitorix_ynh/scripts/_common.sh

60 lines
2.2 KiB
Bash
Raw Normal View History

#=================================================
# SET ALL CONSTANTS
#=================================================
2017-07-21 22:11:45 +02:00
2017-01-05 23:37:07 +01:00
## Adapt md5sum while you update app
2018-03-22 12:46:15 +01:00
sha256sum="a974dd05f67562de85ce4a994cec7f0dcbe3cadad2c5f305131e3867af33a7ad"
2017-10-31 00:12:03 +01:00
app=$YNH_APP_INSTANCE_NAME
APP_VERSION=$(ynh_app_upstream_version)
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
2017-01-05 23:37:07 +01:00
2017-07-21 22:11:45 +02:00
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
2017-01-05 23:37:07 +01:00
}
2017-10-31 23:08:23 +01:00
get_install_source() {
2017-10-31 00:12:03 +01:00
wget -q -O '/tmp/monitorix.deb' "http://www.monitorix.org/monitorix_${APP_VERSION}-izzy1_all.deb"
2017-01-05 23:37:07 +01:00
2017-10-30 21:59:43 +01:00
if [[ ! -e '/tmp/monitorix.deb' ]] || [[ $(sha256sum '/tmp/monitorix.deb' | cut -d' ' -f1) != $sha256sum ]]
2017-01-05 23:37:07 +01:00
then
ynh_die "Error : can't get monitorix debian package"
fi
2017-10-31 23:08:23 +01:00
ynh_package_update
dpkg --force-confdef --force-confold -i /tmp/monitorix.deb
ynh_secure_remove /etc/monitorix/conf.d/00-debian.conf
ynh_package_install -f
2017-01-31 21:26:13 +01:00
}
2017-07-21 22:11:45 +02:00
config_nginx() {
ynh_add_nginx_config
# 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
systemctl reload nginx
2017-07-21 22:11:45 +02:00
}
config_monitorix() {
monitorix_conf=/etc/monitorix/monitorix.conf
cp ../conf/monitorix.conf $monitorix_conf
ynh_replace_string __SERVICE_PORT__ $port $monitorix_conf
2017-07-21 22:11:45 +02:00
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
2017-07-21 22:11:45 +02:00
ynh_replace_string __MYSQL_USER__ $dbuser $monitorix_conf
ynh_replace_string __MYSQL_PASSWORD__ $dbpass $monitorix_conf
}
set_permission() {
chown www-data:root -R /etc/monitorix
chmod u=rX,g=rwX,o= -R /etc/monitorix
chown www-data:root -R /var/lib/monitorix
chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
2017-07-21 22:11:45 +02:00
}