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

start.sh 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # add current directory to PATH
  3. # shellcheck disable=SC2155
  4. export PATH=$PATH:$(pwd)
  5. # check if already running
  6. if [ -f .caddy.pid ]
  7. then
  8. echo "not-server is already running!"
  9. exit 0
  10. fi
  11. # check for rclone and valid configuration
  12. if ! [ -x "$(command -v rclone)" ]
  13. then
  14. echo "ERROR: rclone binary not found in PATH or current folder"
  15. echo "Have you run setup.sh?"
  16. exit 1
  17. fi
  18. if ! rclone listremotes --config rclone.conf | grep -q 'cdn:'
  19. then
  20. echo "ERROR: 'cdn:' remote not found in rclone.conf"
  21. echo "Have you run setup.sh?"
  22. exit 1
  23. fi
  24. # check for caddy
  25. if ! [ -x "$(command -v caddy)" ]
  26. then
  27. echo "caddy binary not found in PATH or current folder"
  28. echo "Have you run setup.sh?"
  29. exit 1
  30. fi
  31. # start rclone
  32. nohup rclone serve http cdn: \
  33. --config rclone.conf \
  34. --dir-cache-time 12h \
  35. --read-only \
  36. --log-file rclone.log \
  37. --addr localhost:3018 > /dev/null 2>&1 &
  38. echo $! > .rclone.pid
  39. # start caddy
  40. nohup caddy > /dev/null 2>&1 &
  41. echo $! > .caddy.pid
  42. echo "not-server started"