Queer European MD passionate about IT

run_me.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. # Import variables from my_config.sh
  8. # `$python_virtual_environment`: python virtual environment directory
  9. # containing `python` and `pip`
  10. # `$python_script`: complete path to python script to be run
  11. source $this_script_directory/my_config.sh;
  12. # Ensure the success of importing procedure:
  13. ## variables of interest should be non-zero (`-z`)
  14. if [ -z ${python_virtual_environment} ];
  15. then
  16. printf "Please set in \"my_config.sh\" the path to bot python \
  17. virtual environment\n\
  18. \n\
  19. Example:\n\
  20. python_virtual_environment=\"path/to/virtual/env\"\n\
  21. ";
  22. exit;
  23. fi
  24. if [ -z ${python_script} ];
  25. then
  26. printf "Please set in \"my_config.sh\" the path to python script to be run \
  27. \n\
  28. Example:\n\
  29. python_script=\"path/to/python/script.py\"\n\
  30. ";
  31. exit;
  32. elif [ ! -e ${python_script} ];
  33. then
  34. printf "File $python_script does not exist\n\
  35. Please point to a valid file.\n\
  36. Example:\n\
  37. python_script=\"path/to/python/script.py\"\n\
  38. ";
  39. fi
  40. echo "Python script will be run while it exits with value===65.";
  41. i=65;
  42. while [ $i -eq 65 ]
  43. do
  44. echo "Pulling from repository..."
  45. git pull;
  46. echo "Updating dependencies";
  47. $python_virtual_environment/pip install --upgrade --no-cache-dir \
  48. --no-deps davtelepot;
  49. echo "Running python script";
  50. $python_virtual_environment/python $python_script;
  51. i=$?;
  52. done