Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

63 строки
1.9KB

  1. #!/bin/bash
  2. # Function to set the path correct in the config files and store them in the correct location.
  3. replace_and_move() {
  4. # The ${GIT_DIR//\//\\\/} replaces '/' with '\/' as '/' is a control char in regex
  5. REPLACE_STR="s/\[\[path_to_repo\\]\\]/${GIT_DIR//\//\\\/}/g"
  6. OUTDIR="$DIRECTORY/$1"
  7. # Parse the file trough `sed` and write output to correct directory
  8. sed $REPLACE_STR $2/$1 > $OUTDIR
  9. echo "$1 script placed at $OUTDIR"
  10. }
  11. setfile() {
  12. TIMERNAME="$1.timer"
  13. SERVICENAME="$1.service"
  14. replace_and_move $TIMERNAME $MAPPATH
  15. replace_and_move $SERVICENAME $MAPPATH
  16. echo "Reload systemd deamon"
  17. `systemctl --user daemon-reload`
  18. echo "Enable $TIMERNAME for systemd"
  19. `systemctl --user enable $TIMERNAME`
  20. echo "Start $TIMERNAME for systemd"
  21. `systemctl --user start $TIMERNAME`
  22. }
  23. ###################
  24. # START OF SCRIPT #
  25. ###################
  26. # Check if XDG_CONFIG_HOME is set and select correct config file location.
  27. # See also: systemd.unit manual - section: UNIT FILE LOAD PATH
  28. if [[ -e $XDG_CONFIG_HOME ]]; then
  29. DIRECTORY=$XDG_CONFIG_HOME/systemd/user
  30. else
  31. DIRECTORY=$HOME/.config/systemd/user
  32. fi
  33. echo "The scripts will be put in $DIRECTORY"
  34. # The following git command will give the root of the current repo.
  35. GIT_DIR=`git rev-parse --show-toplevel`
  36. echo "Root of this git repo is: $GIT_DIR"
  37. if [[ -e $GIT_DIR/.venv/bin/python3 ]]; then
  38. echo "Found a virtual environment for Python in the repo"
  39. else
  40. echo "Pythons virtual environment not found at '$GIT_DIT/.venv'. "
  41. #There should be a setup.sh file in the directory that setups the virtual environment for python
  42. if [[ -f $GIT_DIR/setup.sh ]]; then
  43. echo "Have you tried running '$GIT_DIR/setup.sh'?"
  44. fi
  45. echo "I could install config files, but they whould not work. Aborting now"
  46. exit
  47. fi
  48. FOLDERNAME="systemd_timer_files"
  49. MAPPATH="$GIT_DIR/$FOLDERNAME/"
  50. setfile "pythontaskcheck"
  51. setfile "pythoncreatelog"