summaryrefslogtreecommitdiff
path: root/mkgit
blob: 99449a6bf104de2139b85a76a0ec62bb6f62478d (plain)
  1. #!/bin/sh
  2. # create local git, and create and push to remote git
  3. set -e
  4. login=debian@source.jones.dk
  5. path="/srv/git/source.jones.dk/epfsug/diff"
  6. # resolve options
  7. eval set -- "$(getopt -s sh -o f -- "$@")"
  8. while true; do case "$1" in -f) force=-f; shift;; --) shift; break;; esac; done
  9. . /lib/lsb/init-functions
  10. # add suffix unless already included
  11. gitpath="$(dirname "$path")/$(basename "$path" .git).git"
  12. log_action_begin_msg "Publish git"
  13. # initialize local git
  14. log_action_cont_msg "init"
  15. if [ -d .git ]; then
  16. if [ -n "$force" ]; then
  17. log_warning_msg "purging"
  18. rm -rf .git
  19. else
  20. log_failure_msg "local git already exist (force with -f)"
  21. exit 1
  22. fi
  23. fi
  24. git init
  25. # add scripts
  26. log_action_cont_msg "add"
  27. git add mk*; git commit -m "Include mk* scripts"
  28. # create and populate remote git
  29. log_action_cont_msg "push"
  30. ssh "$login" git init --bare "$gitpath" \&\& cd "$gitpath" \&\& mv hooks/post-update{.sample,} \&\& touch git-daemon-export-ok
  31. git push $force --all -u "$login:$gitpath" || { log_failure_msg "remote git already exist (force with -f)"; exit 1; }
  32. log_action_end_msg $?