mirror of
https://github.com/balkian/gists.git
synced 2024-11-24 02:12:29 +00:00
This commit is contained in:
parent
bb2abfdb1c
commit
9967ab2b24
16
octo.sh
16
octo.sh
@ -1,18 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Starting Octoprint's CLI takes **very long**.
|
CONF_FILE=$HOME/.octo.conf
|
||||||
# So long that it's useless for LIRC (remote) control.
|
if [ ! -f "$CONF_FILE" ];
|
||||||
# This script uses the CLI only once, to retrieve the API.
|
|
||||||
# It's a bit hacky, but it works for LIRC (infrared remote)
|
|
||||||
KEY_FILE=$HOME/.octokey
|
|
||||||
if [ ! -f "$KEY_FILE" ];
|
|
||||||
then
|
then
|
||||||
OctoPrint/venv/bin/octoprint config get api.key | tr -d "'" > $KEY_FILE
|
echo OCTO_API_KEY=$(OctoPrint/venv/bin/octoprint config get api.key | tr -d "'") > $CONF_FILE
|
||||||
|
echo OCTO_PORT=$(OctoPrint/venv/bin/octoprint config get server.port | tr -d "'") >> $CONF_FILE
|
||||||
|
echo OCTO_HOST=$(OctoPrint/venv/bin/octoprint config get server.host | tr -d "'") >> $CONF_FILE
|
||||||
echo 'Retrieved API key'
|
echo 'Retrieved API key'
|
||||||
fi
|
fi
|
||||||
OCTO_API_KEY=$(cat $KEY_FILE)
|
source $CONF_FILE
|
||||||
|
|
||||||
function send_octo() {
|
function send_octo() {
|
||||||
curl -H "X-Api-Key: $OCTO_API_KEY" -H 'Content-Type: application/json' --data "$1" http://localhost:5000/api/printer/printhead
|
curl -H "X-Api-Key: $OCTO_API_KEY" -H 'Content-Type: application/json' --data "$1" http://$OCTO_HOST:$OCTO_PORT/api/printer/printhead
|
||||||
}
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
Loading…
Reference in New Issue
Block a user