#!/bin/bash

# Grafana install hooks — pre-flight prereq check + post-start 0777 on the
# storage folder so Grafana can write its sqlite db regardless of host UID.

grafana_install_pre()
{
    local app_name="$1"
    if ! appInstallCheckRequirements "$app_name" "$CFG_GRAFANA_REQUIRES"; then
        grafana=n
        return 1
    fi
}

grafana_install_post_start()
{
    local app_name="$1"
    if [ -d "${containers_dir}grafana/grafana_storage" ]; then
        local result
        result=$(runFileOp chmod -R 777 "${containers_dir}grafana/grafana_storage")
        checkSuccess "Set permissions to grafana_storage folder."
    fi
}
