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/install

72 lines
2.2 KiB
Text
Raw Normal View History

2017-01-05 23:37:07 +01:00
#!/bin/bash
# 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
2017-01-31 21:26:13 +01:00
CHECK_PATH
2017-01-05 23:37:07 +01:00
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${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
# # Generate MySQL password and create database
dbuser=$app
dbname=$app
dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# Find a port for built-in monitorix HTTP server
2017-03-07 15:46:16 +01:00
http_port=$(ynh_find_port 8080)
nginx_status_port=$(ynh_find_port $(($http_port +1)))
2017-01-05 23:37:07 +01:00
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
# 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
2017-05-26 15:02:19 +02:00
# register yunohost service
sudo yunohost service add monitorix
2017-01-05 23:37:07 +01:00
# Reload services
sudo service monitorix restart
2017-05-26 15:02:19 +02:00
sudo yunohost app ssowatconf
sudo service nginx reload