mirror of
https://github.com/lildude/ha-addon-teslamate.git
synced 2026-10-13 13:10:30 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4567555071 | ||
|
|
694b43eb93 | ||
|
|
04e01df081 |
@@ -35,12 +35,13 @@ jobs:
|
||||
- name: Get TeslaMate release notes
|
||||
run: |
|
||||
touch CHANGELOG.txt
|
||||
gh pr list --repo lildude/ha-addon-teslamate --state=merged --search="Update TeslaMate" --limit=1 --json=body --jq '.[].body' | sed -n "/<\/summary>/,/<\/details>/p" | sed '1d;$d' > changelog.tmp
|
||||
last_release_date=$(gh release list --repo lildude/ha-addon-teslamate --limit=1 --json=publishedAt)
|
||||
gh pr list --repo lildude/ha-addon-teslamate --state=merged --search="Update TeslaMate in:title closed:>$last_release_date" --limit=1 --json=body --jq '.[].body' | sed -n "/<\/summary>/,/<\/details>/p" | sed '1d;$d' > changelog.tmp
|
||||
if [ -s changelog.tmp ]; then
|
||||
echo "## TeslaMate Release Notes" > CHANGELOG.txt
|
||||
cat changelog.tmp >> CHANGELOG.txt
|
||||
echo -e "---\n\n## Add-on Release Notes\n\n" >> CHANGELOG.txt
|
||||
fi
|
||||
echo -e "---\n\n## Add-on Release Notes\n\n" >> CHANGELOG.txt
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Create tag
|
||||
|
||||
+21
-16
@@ -11,13 +11,14 @@
|
||||
|
||||
set -o errexit
|
||||
|
||||
readonly HOST=$(bashio::config 'grafana_host')
|
||||
readonly PORT=$(bashio::config 'grafana_port')
|
||||
readonly USER=$(bashio::config 'grafana_user')
|
||||
readonly PASS=$(bashio::config 'grafana_pass')
|
||||
readonly DASHBOARDS_DIRECTORY="/dashboards"
|
||||
readonly FOLDER_NAME=$(bashio::config 'grafana_folder_name')
|
||||
HOST=$(bashio::config 'grafana_host')
|
||||
PORT=$(bashio::config 'grafana_port')
|
||||
USER=$(bashio::config 'grafana_user')
|
||||
PASS=$(bashio::config 'grafana_pass')
|
||||
DASHBOARDS_DIRECTORY="/dashboards"
|
||||
FOLDER_NAME=$(bashio::config 'grafana_folder_name')
|
||||
|
||||
readonly HOST PORT USER PASS DASHBOARDS_DIRECTORY FOLDER_NAME
|
||||
|
||||
|
||||
main() {
|
||||
@@ -25,13 +26,12 @@ main() {
|
||||
|
||||
URL="http://$HOST:$PORT"
|
||||
LOGIN="$USER:$PASS"
|
||||
|
||||
|
||||
case $task in
|
||||
backup) backup;;
|
||||
restore) restore;;
|
||||
*) exit 1;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,7 @@ backup() {
|
||||
dashboard_json=$(get_dashboard "$dashboard")
|
||||
|
||||
if [[ -z "$dashboard_json" ]]; then
|
||||
echo "ERROR:
|
||||
Couldn't retrieve dashboard $dashboard.
|
||||
"
|
||||
echo "ERROR: Couldn't retrieve dashboard $dashboard."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -57,10 +55,18 @@ backup() {
|
||||
|
||||
restore() {
|
||||
bashio::log.info "Checking for Grafana folder: $FOLDER_NAME"
|
||||
FLD=$(curl --silent --show-error \
|
||||
folders=$(curl --silent --show-error \
|
||||
--user "$LOGIN" -H "Content-Type: application/json" \
|
||||
$URL/api/folders | jq ".[] | select(.title==\"$FOLDER_NAME\")")
|
||||
|
||||
"$URL/api/folders")
|
||||
|
||||
if [[ $folders == *"statusCode"* ]]; then
|
||||
bashio::log.error "Error getting Grafana folders: $(echo "$folders" | jq -r .message)"
|
||||
bashio::log.debug "$folders"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FLD=$(echo "$folders" | jq ".[] | select(.title==\"$FOLDER_NAME\")")
|
||||
|
||||
if [[ -z "$FLD" ]]; then
|
||||
bashio::log.info "Not found... creating"
|
||||
FLD=$(curl \
|
||||
@@ -72,7 +78,7 @@ restore() {
|
||||
"$URL/api/folders")
|
||||
fi
|
||||
|
||||
FOLDER_ID=$(echo $FLD | jq -r .id)
|
||||
FOLDER_ID=$(echo "$FLD" | jq -r .id)
|
||||
|
||||
if [[ -z "$FOLDER_ID" ]]; then
|
||||
bashio::log.error "Could not determine Grafana folder id"
|
||||
@@ -123,5 +129,4 @@ list_dashboards() {
|
||||
cut -d '/' -f2
|
||||
}
|
||||
|
||||
|
||||
main "$@"
|
||||
+7
-1
@@ -1,5 +1,11 @@
|
||||
#!/command/with-contenv bashio
|
||||
# -*- bash -*-
|
||||
# shellcheck shell=bash
|
||||
mkdir /run/nginx
|
||||
|
||||
bashio::log.info "Starting NGINX..."
|
||||
if [ -f /run/nginx ]; then
|
||||
rm -f /run/nginx
|
||||
fi
|
||||
mkdir -p /run/nginx
|
||||
|
||||
exec nginx -g 'daemon off;error_log /proc/1/fd/1 error;'
|
||||
@@ -54,14 +54,14 @@ done
|
||||
|
||||
# Import dashboards
|
||||
if bashio::config.true 'grafana_import_dashboards'; then
|
||||
/dashboards.sh restore
|
||||
/dashboards.sh restore || bashio::log.error "Failed to import dashboards"
|
||||
fi
|
||||
|
||||
# Create the PostgreSQL database if it doesn't exist
|
||||
if pg_isready -h "$DATABASE_HOST" -p "$DATABASE_PORT" > /dev/null 2>&1; then
|
||||
bashio::log.info "Creating database '$DATABASE_NAME' on $DATABASE_HOST"
|
||||
|
||||
if [[ -n $(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -Atqc "\list $DATABASE_NAME") ]]; then
|
||||
if [[ -n $(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -Atqc "\list \"$DATABASE_NAME\"") ]]; then
|
||||
bashio::log.info "Database $DATABASE_NAME already exists"
|
||||
else
|
||||
if PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -qc "CREATE DATABASE \"$DATABASE_NAME\""; then
|
||||
@@ -78,7 +78,7 @@ fi
|
||||
|
||||
ulimit -n 1048576
|
||||
|
||||
bashio::log.info "Starting TeslaMate"
|
||||
bashio::log.info "Starting TeslaMate..."
|
||||
|
||||
cd /opt/app
|
||||
exec $(/usr/bin/env sh) /entrypoint.sh bin/teslamate start
|
||||
|
||||
Reference in New Issue
Block a user