Queer European MD passionate about IT

run_me.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # This file must be executable, otherwise the service cannot run it.
  3. # Run `$python_script` while exit code is 65.
  4. # At each iteration, pull news from repository and update dependencies.
  5. # Get current directory
  6. this_script_directory=$(cd `dirname $0` && pwd);
  7. cd "$this_script_directory";
  8. # Import variables from my_config.sh
  9. # `$python_virtual_environment`: python virtual environment directory
  10. # containing `python` and `pip`
  11. # `$python_script`: complete path to python script to be run
  12. source "$this_script_directory/my_config.sh";
  13. # Ensure the success of importing procedure:
  14. ## variables of interest should be non-zero (`-z`)
  15. if [ -z "${python_virtual_environment}" ];
  16. then
  17. printf "Please set in \"my_config.sh\" the path to bot python \
  18. virtual environment\n\
  19. \n\
  20. Example:\n\
  21. python_virtual_environment=\"path/to/virtual/env\"\n\
  22. ";
  23. exit;
  24. fi
  25. if [ -z "${python_script}" ];
  26. then
  27. printf "Please set in \"my_config.sh\" the path to python script to be run \
  28. \n\
  29. Example:\n\
  30. python_script=\"path/to/python/script.py\"\n\
  31. ";
  32. exit;
  33. elif [ ! -e "${python_script}" ];
  34. then
  35. printf "File $python_script does not exist\n\
  36. Please point to a valid file.\n\
  37. Example:\n\
  38. python_script=\"path/to/python/script.py\"\n\
  39. ";
  40. fi
  41. echo "Python script will be run while it exits with value===65.";
  42. i=65;
  43. while [ $i -eq 65 ]
  44. do
  45. echo "Pulling from repository..."
  46. git pull;
  47. echo "Updating dependencies";
  48. "$python_virtual_environment/pip" install --upgrade --no-cache-dir \
  49. --no-deps davtelepot;
  50. echo "Running python script";
  51. "$python_virtual_environment/python" -m ciclopibot.bot;
  52. i=$?;
  53. done