Upload bin files

This commit is contained in:
2020-05-03 20:21:48 +03:00
parent 6a6f7ade34
commit d389d21343
11 changed files with 78 additions and 9 deletions

1
.gitignore vendored
View File

@@ -1 +0,0 @@
bin/

View File

@@ -2,4 +2,4 @@
"files.associations": {
"*.yaml": "home-assistant"
}
}
}

22
.vscode/tasks.json vendored
View File

@@ -9,7 +9,9 @@
"command": "./bin/ui",
"problemMatcher": [],
"presentation": {
"focus": true
"panel": "shared",
"echo": false,
"clear": true
}
},
{
@@ -18,7 +20,9 @@
"command": "./bin/restart",
"problemMatcher": [],
"presentation": {
"focus": true
"panel": "shared",
"echo": false,
"clear": true
}
},
{
@@ -27,7 +31,9 @@
"command": "./bin/update",
"problemMatcher": [],
"presentation": {
"focus": true
"panel": "shared",
"echo": false,
"clear": true
}
},
{
@@ -36,7 +42,9 @@
"command": "./bin/upload",
"problemMatcher": [],
"presentation": {
"focus": true
"panel": "shared",
"echo": false,
"clear": true
}
},
{
@@ -45,9 +53,9 @@
"command": "./bin/logs",
"problemMatcher": [],
"presentation": {
"panel": "dedicated",
"clear": true,
"focus": true
"panel": "shared",
"echo": false,
"clear": true
}
}
]

View File

@@ -76,6 +76,19 @@ The `speech` module uses [partial templates](https://github.com/GeorgeSG/sarah/t
![Floorplan](assets/screenshot-floorplan.png?raw=true)
## Helpers
There are some useful scripts in `./bin`.
In order to use them, copy `./bin/.env.example` to `./bin/.env` and set the correct values.
You must be able to ssh to the host with a ssh key.
- `./bin/ui` - re-uploads only UI configuration files
- `./bin/upload` - re-uploads all configuration files
- `./bin/restart` - restarts Home Assistant via docker-compose
- `./bin/update` - `upload` and then `restart`
- `./bin/logs` - tails the logs of Home Assisstant via docker-compose
## Inspiration
1. [CCOSTAN/Home-AssistantConfig](https://github.com/CCOSTAN/Home-AssistantConfig)

3
bin/.env.example Normal file
View File

@@ -0,0 +1,3 @@
REMOTE_REPO_PATH="/path/to/repo"
REMOTE_HOST="username@server"
REMOTE_PORT="22"

1
bin/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

6
bin/logs Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
set -o allexport; source "$(dirname $0)/.env"; set +o allexport
ssh $REMOTE_HOST -p $REMOTE_PORT -t \
"docker-compose -f $REMOTE_REPO_PATH/docker/docker-compose.yml logs -f --tail=\"200\" | grep home-assistant"

7
bin/restart Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -o allexport; source "$(dirname $0)/.env"; set +o allexport
echo "Restarting..."
ssh $REMOTE_HOST -p $REMOTE_PORT \
"docker-compose -f $REMOTE_REPO_PATH/docker/docker-compose.yml restart"

11
bin/ui Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -o allexport; source "$(dirname $0)/.env"; set +o allexport
echo "Uploading UI configuration..."
ssh $REMOTE_HOST -p $REMOTE_PORT "rm -rf $REMOTE_REPO_PATH/config/lovelace"
scp -P $REMOTE_PORT \
-r config/themes/ config/*-lovelace.yaml config/lovelace \
"${REMOTE_HOST}:${REMOTE_REPO_PATH}/config"

6
bin/update Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
sh "$(dirname $0)/upload"
echo
sh "$(dirname $0)/restart"

15
bin/upload Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -o allexport; source "$(dirname $0)/.env"; set +o allexport
echo "Deleting old folders..."
ssh $REMOTE_HOST -p $REMOTE_PORT \
"rm -rf $REMOTE_REPO_PATH/config/{custom_scripts,lovelace,packages,templates}"
echo "Delete completed!"
echo
scp -P $REMOTE_PORT \
-r config/{custom_scripts,lovelace,packages,templates,themes,*.yaml} \
"${REMOTE_HOST}:${REMOTE_REPO_PATH}/config"