#!/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" # The DIRECTORY, not its contents. Grafana runs as uid 472, which rootless # maps to a subuid this user has no authority over; it needs write on the dir # itself to create grafana.db and its plugin/png dirs on first boot, and from # then on those files are its own. `chmod -R` walked them as the docker # install user and failed per file with "Operation not permitted", failing the # step on every reinstall — while a fresh install passed, because the dir was # still empty. Grafana's files must keep Grafana's ownership regardless. if [ -d "$(appDir grafana)/grafana_storage" ]; then local result result=$(runFileOp chmod 0777 "$(appDir grafana)/grafana_storage") checkSuccess "Set permissions to grafana_storage folder." fi }