You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docker-grafana/grafana/entrypoint.sh

57 lines
1.8 KiB

3 years ago
#!/bin/sh
set -e
CONFIG_DIR="$(dirname "${GF_PATHS_CONFIG}")"
if [ ! -d "${CONFIG_DIR}" ]; then
echo "Directory '${CONFIG_DIR}' not found; creating it..."
mkdir -p "${CONFIG_DIR}"
chown -R "grafana:$GF_GID_NAME" "${CONFIG_DIR}"
fi
if [ ! -f "${GF_PATHS_CONFIG}" ]; then
echo "File '${GF_PATHS_CONFIG}' not found; creating it..."
cp "/etc/grafana/grafana.ini" "${GF_PATHS_CONFIG}"
chown -R "grafana:$GF_GID_NAME" "${GF_PATHS_CONFIG}"
fi
if [ ! -d "${GF_PATHS_DATA}" ]; then
echo "Directory '${GF_PATHS_DATA}' not found; creating it..."
mkdir -p "${GF_PATHS_DATA}"
chown -R "grafana:$GF_GID_NAME" "${GF_PATHS_DATA}"
fi
if [ ! -d "${GF_PATHS_LOGS}" ]; then
echo "Directory '${GF_PATHS_LOGS}' not found; creating it..."
mkdir -p "${GF_PATHS_LOGS}"
chown -R "grafana:$GF_GID_NAME" "${GF_PATHS_LOGS}"
fi
if [ ! -d "${GF_PATHS_PLUGINS}" ]; then
echo "Directory '${GF_PATHS_PLUGINS}' not found; creating it..."
mkdir -p "${GF_PATHS_PLUGINS}"
chown -R "grafana:$GF_GID_NAME" "${GF_PATHS_PLUGINS}"
fi
if [ ! -d "${GF_PATHS_PROVISIONING}" ]; then
echo "Directory '${GF_PATHS_PROVISIONING}' not found; creating it..."
mkdir -p "${GF_PATHS_PROVISIONING}/datasources" \
"${GF_PATHS_PROVISIONING}/dashboards" \
"${GF_PATHS_PROVISIONING}/notifiers" \
"${GF_PATHS_PROVISIONING}/plugins" \
"${GF_PATHS_PROVISIONING}/access-control"
chown -R "grafana:$GF_GID_NAME" "${GF_PATHS_PROVISIONING}"
fi
if [ -n "${GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH}" ]; then
CONFIG_DIR="$(dirname "${GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH}")"
if [ ! -d "${CONFIG_DIR}" ]; then
echo "Directory '${CONFIG_DIR}' not found; creating it..."
mkdir -p "${CONFIG_DIR}"
chown -R "grafana:$GF_GID_NAME" "${CONFIG_DIR}"
fi
fi
su grafana -s /bin/sh -c "/run.sh"