diff --git a/src/Simple-Git-Deploy/cmd.sh b/src/Simple-Git-Deploy/cmd.sh index 59ebfc2..fe5f32f 100755 --- a/src/Simple-Git-Deploy/cmd.sh +++ b/src/Simple-Git-Deploy/cmd.sh @@ -1,3 +1,26 @@ #!/bin/bash -#ssh-agent bash -c 'ssh-add /mnt/drive/wobsites/life/keys/deploy; git clone ssh://git@git.mowie.cc:9022/Websites/Life-Homepage.git /mnt/drive/wobsites/life/deploy-test' -git --version \ No newline at end of file + +while getopts ':k:g:d:' OPTION ; do + case "$OPTION" in + k) KEY=$OPTARG;; + g) GIT_URL=$OPTARG;; + d) DEPLOY_DIR=$OPTARG;; + *) echo "Unknown parameter" + esac +done + +echo "-----------------------------" +echo "Key: ${KEY}" +echo "Git-Url: ${GIT_URL}" +echo "Deploy-Dir: ${DEPLOY_DIR}" +echo "----------------------------" + +rm -Rf /tmp/git-deploy +ssh-agent bash -c "ssh-add ${KEY}; git clone ${GIT_URL} /tmp/git-deploy" + +rm -Rf /tmp/git-deploy/.git # Remove the Git Folder +# Empty the deploy-directory without deleting itself +rm -Rf ${DEPLOY_DIR}/.* 2> /dev/null +rm -Rf ${DEPLOY_DIR}/* +# Move the newly downloaded files to the deploy-folder +mv -fT /tmp/git-deploy ${DEPLOY_DIR} \ No newline at end of file