-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·32 lines (29 loc) · 947 Bytes
/
deploy.sh
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
#!/usr/bin/env bash
# Usage: ./deploy.sh local | [host]
# argument requirement check
# require at least 1 arg to detect script running at localhost or remotehost
if [ $# -eq 0 ]
then
echo -e "No arguments supplied, require at least one argument
Example:
$(basename $0) \t local \t\t to setup chef-solo locally
$(basename $0) \t <hostname> \t to setup chef-solo remotely"
exit;
fi
# Set proper _PATH dir base on working environment
case $1 in
local)
export _PATH=$PWD
source $_PATH/install.sh
;;
remote)
export _PATH=/home/deployuser/chef
export _REMOTEHOST="${2:-deployuser@<default-hostname>}"
chmod 0600 /var/jenkins_home/workspace/deploy.live/key/deployuser
ssh -i /var/jenkins_home/workspace/deploy.live/key/deployuser deployuser@$_REMOTEHOST sudo /home/deployuser/chef/install.sh $_PATH
;;
*)
echo "Wrong argurments."
exit;
;;
esac