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

33 lines
982 B
Bash

7 years ago
#!/bin/bash
7 years ago
echo $(date) - "$@" >> /tmp/octo-log
7 years ago
CONF_FILE=$HOME/.octo.conf
if [ ! -f "$CONF_FILE" ];
7 years ago
then
7 years ago
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
7 years ago
echo 'Retrieved API key'
fi
7 years ago
source $CONF_FILE
7 years ago
function send_octo() {
7 years ago
curl -H "X-Api-Key: $OCTO_API_KEY" -H 'Content-Type: application/json' --data "$1" http://$OCTO_HOST:$OCTO_PORT/api/printer/printhead
7 years ago
}
case $1 in
move)
shift
x=$1
y=$2
z=$3
echo $1 $2 $3
send_octo '{"command": "jog","x": '$x',"y": '$y',"z": '$z'}' http://localhost:5000/api/printer/printhead
sleep 2
;;
home)
send_octo '{ "command": "home", "axes": ["x", "y", "z"] }'
7 years ago
;;
nothing)
echo "nothing $(date)" >> /tmp/prueba
;;
7 years ago
esac