Page MenuHomeDevCentral

D2206.diff
No OneTemporary

D2206.diff

diff --git a/roles/devserver/webserver-wwwroot51/files/clone-repo.sh b/roles/devserver/webserver-wwwroot51/files/clone-repo.sh
new file mode 100755
--- /dev/null
+++ b/roles/devserver/webserver-wwwroot51/files/clone-repo.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Clone a repository using deploy credentials
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Author: Sébastien Santoro aka Dereckson
+# License: BSD-2-Clause
+# Source file: roles/devserver/webserver-wwwroot51/files/clone-repo.sh
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Parse arguments
+#
+# Usage: clone-repo <URL> <target> <user> <group> <deploy user> <key>
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ $# -ne 6 ]; then
+ echo "Usage: $0 <URL> <target> <user> <group> <deploy user> <key>" >&2
+ exit 1
+fi
+
+REPO_URL=$1
+REPO_TARGET=$2
+REPO_USER=$3
+REPO_GROUP=$4
+DEPLOY_USER=$5
+DEPLOY_KEY=$6
+
+id -u $REPO_USER > /dev/null 2> /dev/null
+if [ $? -ne 0 ]; then
+ echo "No such user: $REPO_USER" >&2
+ exit 2
+fi
+
+getent group $REPO_GROUP > /dev/null 2> /dev/null
+if [ $? -ne 0 ]; then
+ echo "No such group: $REPO_GROUP" >&2
+ exit 4
+fi
+
+# -------------------------------------------------------------
+# Clone the repository and transfer ownership to target user
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+echo sudo -u $DEPLOY_USER git clone $REPO_URL $REPO_TARGET
+echo " (with $DEPLOY_KEY as SSH key)"
+echo chown -R $REPO_USER:$REPO_GROUP $REPO_TARGET

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 18:39 (22 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262977
Default Alt Text
D2206.diff (1 KB)

Event Timeline