wintermute.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ##############################################################################
  2. #
  3. # Wintermute (Personal Server) Commands
  4. #
  5. ##############################################################################
  6. # Upload a file to wintermute
  7. function upload() {
  8. file=`curl -H 'Authorization: Basic cmFtYXRldmlzaDpVcmlhbDk5MQ==' -F "file=@$1" https://media.matevi.sh/api/upload.php | jq .url | tr -d '"'`
  9. echo "https://media.matevi.sh/$file"
  10. }
  11. function del-upload() {
  12. curl -X "DELETE" "https://mtv.sh/files/$1" --header "Authorization:mysecret"
  13. }
  14. function add_alias() {
  15. curl --header "Content-Type: application/json" \
  16. --request POST \
  17. --header "Authorization:mysecret" \
  18. --data "{\"alias\": \"$1\", \"target\": \"$2\"}" \
  19. https://mtv.sh/aliases
  20. echo "http://mtv.sh/a/$1"
  21. }
  22. ############ SSHFS
  23. SSHFS_OPTS="auto_cache,reconnect,defer_permissions,noappledouble,nolocalcaches,no_readahead";
  24. # Mount wintermute root
  25. WINTERMUTE_ROOT_MOUNT_DIR="$HOME/wintermute";
  26. function mount-wintermute() {
  27. umount $WINTERMUTE_ROOT_MOUNT_DIR;
  28. mkdir -p $WINTERMUTE_ROOT_MOUNT_DIR && sshfs matevi.sh:/ $WINTERMUTE_ROOT_MOUNT_DIR -o$SSHFS_OPTS -ovolname=wintermute-root;
  29. }
  30. function umount-wintermute() {
  31. umount $WINTERMUTE_ROOT_MOUNT_DIR && rmdir $WINTERMUTE_ROOT_MOUNT_DIR;
  32. }
  33. alias wd='docker -H=localhost:2376'
  34. function tun_docker() {
  35. ssh -nNT -L 2376:localhost:2375 wintermute &
  36. PID=$!
  37. $SHELL
  38. kill $PID
  39. }
  40. function tun_publish()
  41. {
  42. ssh -nNT -R 9001:localhost:${1:-8000} wintermute
  43. }
  44. function tun_publish_dir()
  45. {
  46. python3 -m http.server &
  47. PID=$!
  48. tun_publish 8000
  49. kill $PID
  50. }
  51. function tun_tcp()
  52. {
  53. ssh -nNT -R ${2:-2299}:localhost:$1 wintermute
  54. }
  55. function white-led () {
  56. ssh dixie "nohup watch -n 10 \"echo '2' > /proc/gpio/led_pattern\" &"
  57. }