Created
June 21, 2017 17:28
-
-
Save rocktronica/7fa8865a643476b4e049c61992684b14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
{ | |
filename="$1" | |
user="pi" | |
host="octopi.local" | |
destination="~/.octoprint/uploads" | |
bandwidth_limit="1000" # prevents stalling on large files; kbit/s | |
function upload() { | |
echo "Uploading $filename" | |
scp -C -l "$bandwidth_limit" "$filename" "$user@$host:$destination" | |
echo | |
} | |
function stop_octoprint() { | |
echo 'Stopping OctoPrint' | |
ssh "$user@$host" 'sudo service octoprint stop' | |
echo | |
} | |
function start_octoprint() { | |
echo 'Starting OctoPrint' | |
ssh "$user@$host" 'sudo service octoprint start' | |
} | |
if [[ -z "$filename" ]]; then | |
echo 'No filename found' | |
exit 1 | |
fi | |
stop_octoprint | |
upload "$filename" | |
start_octoprint | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment