51 lines
1.0 KiB
Bash
Executable File
51 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
if [ "$#" -eq "0" ]; then
|
|
exit 1
|
|
fi
|
|
|
|
projectName=$1
|
|
gitBranch=$2
|
|
|
|
. /etc/vn-repo/config
|
|
|
|
if [ -z "$gitUrl" ]; then
|
|
gitUrl=http://localhost
|
|
fi
|
|
if [ -z "$gitBranch" ]; then
|
|
gitBranch=master
|
|
fi
|
|
|
|
repoDir="/var/lib/git/$projectName"
|
|
srcDir="/tmp/vn-repo/$projectName/src"
|
|
logDir="/usr/share/vn-repo/web/logs"
|
|
logFile="$logDir/$projectName.out"
|
|
|
|
mkdir -p "$logDir"
|
|
rm -f "$logFile"
|
|
|
|
echo -e "\n# Deploying started\n" >> "$logFile"
|
|
echo " * Date: $(date)" >> "$logFile"
|
|
echo " * Project: $projectName" >> "$logFile"
|
|
echo " * Directory: $srcDir" >> "$logFile"
|
|
echo " * Host: $(hostname)" >> "$logFile"
|
|
|
|
echo -e "\n# Fetching Git repository\n" >> "$logFile"
|
|
|
|
mkdir -p "$srcDir"
|
|
cd "$srcDir"
|
|
|
|
if [ ! -d "$srcDir/.git" ]; then
|
|
git init >> "$logFile"
|
|
fi
|
|
|
|
git config remote.origin.url "$gitUrl/$projectName" >> "$logFile"
|
|
git pull origin "$gitBranch" >> "$logFile"
|
|
|
|
if [ -f "$srcDir/deploy" ]; then
|
|
"$srcDir/deploy" >> "$logFile" 2>&1
|
|
fi
|
|
|
|
echo -e "\n# Deploying ended\n" >> "$logFile"
|