aboutsummaryrefslogtreecommitdiff
path: root/share/templater/pushtodeploy/setup
blob: b7c3c670c208f81635a6a14ce8d8d667551975dc (plain)
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
#!/bin/bash
#
# pushtodeploy templater module.
#

# Parameters
SHARE="$1"

# Include basic functions
source $SHARE/templater/functions || exit 1

# pushtodeploy implementation
function templater_pushtodeploy {
  if [ ! -e "bin/post-receive" ]; then
    __templater_echo "Setting up pushtodeploy..."

    mkdir -p bin
    cp $SHARE/pushtodeploy/files/post-receive bin/

    if [ -e "Makefile" ]; then
      if ! grep -q "^post_receive:" Makefile; then
        echo "post_receive:"                                       >> Makefile
        echo -e "\ttest -s bin/post-receive && cd .git/hooks && ln -sf ../../bin/post-receive" >> Makefile
      fi
    fi
  else
    __templater_echo "pushtodeploy already set"
  fi
}

# Dispatch
templater_pushtodeploy