/
pushand_server_install
executable file
·35 lines (28 loc) · 1.07 KB
/
pushand_server_install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/bash
#
# Overrides git-receive-pack on the current computer so,
# when a repository is pushed to the computer, the repository
# is created locally and, if it contains a .pushand script,
# it will run the .pushand script.
#
source "$(dirname $0)/pushand_server_variables"
if [[ -f "$real_script_new_path" ]]; then
echo "$real_script_new_path already exists"
else
if [[ ! -w "$real_script_path" ]]; then
echo "You don't have permission to modify $real_script_path"
else
# make the directory that we back up git-receive-pack in.
# it has to be in a directory because the script *must* keep
# the name 'git-receive-pack' (in the latest versions of git)
mkdir -p $real_script_new_dir
# move the real git-receive-pack
mv $real_script_path $real_script_new_path
# copy our git-receive-pack to where the real one was
cp $our_script_path $real_script_path
# copy our post-receive hook (which we register with all git repos)
# somewhere where we can easily get to it
cp $post_receive_hook_path $post_receive_hook_new_path
echo 'pushand installed'
fi
fi