-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import os | ||
print os.name | ||
|
||
if os.name == 'nt': | ||
print 'windows' | ||
else: | ||
print 'linux' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<html> | ||
<header><title>This is title</title></header> | ||
<body> | ||
Hello world | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/git/puppet.git/hooks/commit_hooks/web-post-receive.sh -d 'localhost' -f '/etc/puppetlabs/code/environments/' -r 'git@alis-dsg-pupms:/git/puppet.git' -i '/git/puppet.git/hooks/id_rsa' -u 'root' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from flask import Flask | ||
app = Flask(__name__) | ||
|
||
@app.route("/") | ||
def index(): | ||
return "Hello World!" | ||
|
||
if __name__ == "__main__": | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/bash | ||
#This need to be on the git server where the on /opt/stash-hooks | ||
usage () { | ||
echo "This script convert the Git branches in puppet environment using SSH" | ||
echo "Usage:" | ||
echo "$0 -d <destination server> -f <environment folder> -r <the Git repo URL> -u <user> -i <path to ssh key>" | ||
exit 0 | ||
} | ||
|
||
|
||
if [ "$#" -ne 10 ]; then | ||
echo "Error: Illegal number of parameters" | ||
usage | ||
fi | ||
while getopts "h:d:f:r:i:u:" opt; do | ||
case $opt in | ||
h) | ||
usage | ||
;; | ||
d) | ||
DESTSERVER=$OPTARG | ||
;; | ||
f) | ||
FOLDER=$OPTARG | ||
;; | ||
r) | ||
REPO=$OPTARG | ||
;; | ||
u) | ||
USER=$OPTARG | ||
;; | ||
i) | ||
SSHKEY=$OPTARG | ||
;; | ||
|
||
*) | ||
usage | ||
;; | ||
esac | ||
done | ||
#debug: | ||
echo "destenation server: $DESTSERVER" | ||
echo "env folder: $FOLDER" | ||
echo "remote user: $USER" | ||
echo "ssh key:$SSHKEY" | ||
echo "Git repo: $REPO" | ||
|
||
read oldrev newrev refname | ||
|
||
REPOSITORY=$REPO | ||
#REPOSITORY="/opt/git/puppet.git" | ||
BRANCH=$( echo "${refname}" | sed -n 's!^refs/heads/!!p' ) | ||
#ENVIRONMENT_BASE="/tmp/puppet/environments" | ||
ENVIRONMENT_BASE=$FOLDER | ||
|
||
# master branch, as defined by git, is production | ||
if [[ "${BRANCH}" == "production" ]]; then | ||
ACTUAL_BRANCH="production" | ||
else | ||
ACTUAL_BRANCH=${BRANCH} | ||
fi | ||
|
||
# newrev is a bunch of 0s | ||
echo "${newrev}" | grep -qs '^0*$' | ||
if [ "$?" -eq "0" ]; then | ||
# branch is marked for deletion | ||
if [ "${ACTUAL_BRANCH}" = "production" ]; then | ||
echo "No way!" | ||
exit 1 | ||
fi | ||
pid1=`ps -ef |grep python |grep -v grep |head -1 |tr -s " " "#"|cut -d "#" -f2` | ||
kill -9 $pid1 | ||
|
||
#or service flask stop if there is service | ||
ssh -i $SSHKEY ${USER}@${DESTSERVER} "/usr/bin/pupdate.sh -d ${ENVIRONMENT_BASE} -r ${REPO} -b ${ACTUAL_BRANCH} -a delete" | ||
service flask start | ||
else | ||
pid1=`ps -ef |grep python |grep -v grep |head -1 |tr -s " " "#"|cut -d "#" -f2` | ||
kill -9 $pid1 | ||
ssh -i $SSHKEY ${USER}@${DESTSERVER} "/usr/bin/pupdate.sh -d ${ENVIRONMENT_BASE} -r ${REPO} -b ${ACTUAL_BRANCH} -a update" | ||
service flask start | ||
fi | ||
exit 0 |