EOF
hook_hash="$(printf '%s' "${hook}"|sha256sum| cut -d\ -f1)"
-post_receive="hooks/post-receive"
-[[ -f "${dest}" ]] && current_hash="$(sha256sum "${post_receive}"| cut -d\ -f1)"
+[[ -f "${dest}" ]] && current_hash="$(sha256sum hooks/post-receive| cut -d\ -f1)"
print_and_run() {
printf ">>>"
"$@"
}
-update_hook() {
- print_and_run bash -c "cat >${post_receive} <<'EOF'"$'\n'"${hook}"$'\nEOF\n'
+update_post_receive_hook() {
+ local stat_cmd="\$(stat -c %a hooks/post-receive)"
+ print_and_run bash -c "cat >hooks/post-receive <<'EOF'"$'\n'"${hook}"$'\nEOF\n'
+ print_and_run bash -c "[[ ${stat_cmd} == 755 ]] || chmod 755 hooks/post-receive"
}
if [[ "${1}" == --install ]]; then
echo "Error: No further arguments expected." >&2
exit 1
fi
- update_hook "${post_receive}"
+ update_post_receive_hook
exit
fi
-[[ "${hook_hash}" != "${current_hash}" ]] && update_hook "${post_receive}"
-[[ -x "${post_receive}" ]] || chmod 755 "${post_receive}"
+[[ "${hook_hash}" != "${current_hash}" ]] && update_post_receive_hook
update_gitweb_theme() {
local theme_css_dest="/usr/share/gitweb/static/gitweb-theme.css"