1
0

execution-wrapper.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # Klimbim Software collection, A bag full of things
  3. # Copyright (C) 2011-2023 Johannes 'Banana' Keßler
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. # 2020 https://www.bananas-playground.net
  18. # this file can be used to wrap the execution of a
  19. # command which needs to be ox independent or
  20. # needs other commands before or after
  21. # the following example detects the os type
  22. # sets env vars and executes a command befor and after
  23. unameOut="$(uname -s)"
  24. case "${unameOut}" in
  25. Linux)
  26. cmd="some-command_linux-amd64";
  27. ;;
  28. Darwin)
  29. cmd="some-command_darwin-amd64";
  30. ;;
  31. *)
  32. echo "UNKNOWN System:${unameOut}";
  33. exit
  34. ;;
  35. esac
  36. # this path detection works on linux and mac
  37. SCRIPT="$(readlink "$0")";
  38. SCRIPTPATH="$(dirname "$SCRIPT")"
  39. # change dir since the executed script is within a git repo
  40. cd $SCRIPTPATH;
  41. git pull;
  42. # set some EVN, execute and after quit of the cmd, do a git update
  43. SOME_ENV_VAR=$SCRIPTPATH/a.db ./${cmd} && git commit -am"`date +'%c'`" && git push;