Files
addons/google_assistant/run.sh
Pascal Vizeli 0b8bc56642 add google auth (#147)
* add google auth

* fix parse

* Update handling

* fix spell
2017-07-22 16:35:06 +02:00

33 lines
960 B
Bash

#!/bin/bash
set -e
CONFIG_PATH=/data/options.json
CLIENT_JSON=/data/client.json
CRED_JSON=/data/cred.json
CLIENT_SECRETS=$(jq --raw-output '.client_secrets' $CONFIG_PATH)
SPEAKER=$(jq --raw-output '.speaker' $CONFIG_PATH)
MIC=$(jq --raw-output '.mic' $CONFIG_PATH)
echo "[Info] Show audio device"
aplay -l
echo "[Info] Setup audio device"
sed -i "s/%%SPEAKER%%/$SPEAKER/g" /root/.asoundrc
sed -i "s/%%MIC%%/$MIC/g" /root/.asoundrc
# check if a new assistant file exists
if [ -f "/share/$CLIENT_SECRETS" ]; then
echo "[Info] Install/Update service client_secrets file"
cp -f "/share/$CLIENT_SECRETS" "$CLIENT_JSON"
rm -f "/share/$CLIENT_SECRETS"
echo "[Info] Start WebUI for handling oauth2"
python3 /hassio_oauth.py "$CLIENT_JSON" "$CRED_JSON"
elif [ ! -f "$CRED_JSON" ]; then
echo "[Error] You need initialize GoogleAssistant with a client secret json!"
exit 1
fi
exec python3 /hassio_gassistant.py "$CRED_JSON" < /dev/null