-
Notifications
You must be signed in to change notification settings - Fork 2
/
full_import.sh
executable file
·79 lines (70 loc) · 2 KB
/
full_import.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# add some variables around retries
retryCount=0
maxRetries=15
retryCountDelay=30
# run the script as sudo so that you
#if [ -z "$SUDO_COMMAND" ]
#then
#echo -e "Only root can run this script.\nRelaunching script with sudo.\n"
#sudo -E $0 $*
#exit 0
#fi
while getopts lsth flag
do
case "${flag}" in
l)
LOCAL=true
;;
s)
SSH=true
;;
t)
TAIL=true
SSH=true
;;
h)
echo "Upload .bash_alias, .vimrc, and sample data files to specified environment."
echo
echo "Syntax: ${0##*/} [-l|s|t|h] environment-url"
echo "Options:"
echo " -l Specify if using a local vagrant environment."
echo " -s SSH into the environment after transferring files."
echo " -t Start tailing /var/log/cloud-init-output.log after sshing.(Desire to SSH is assumed.)"
echo " -h Print this help."
exit;;
\?)
echo "Error: Invalid Option"
exit;;
esac
done
shift $((OPTIND - 1))
if [[ $LOCAL = true ]]
then
SITE="${1}.local"
else
SITE="${1}.dev.dgi"
fi
until host $SITE &> /dev/null || [ $retryCount -gt $maxRetries ]
do
echo "Waiting for environment... ${retryCount}/${maxRetries}"
sleep $retryCountDelay
#sudo pkill -HUP -x mDNSResponder
((retryCount++))
done
echo "## Running .bash_alias and .vimrc import"
sh /Users/noelchiasson/bin/transfer_bash_vim.sh $SITE
echo "## Running import of CSV Test Files"
sh /Users/noelchiasson/bin/import_data_aws.sh $SITE
echo "## Running import of bin scripts"
sh /Users/noelchiasson/bin/import_bin_aws.sh $SITE
if [[ $SSH = true ]]
then
echo "## ssh-ing into environment"
if [[ $TAIL = true ]]
then
ssh -t $SITE 'until pgrep -x puppet &> /dev/null ; do echo "Puppet process does not exist... retrying" ; sleep 10 ; done ; tail --pid=$(pgrep -x puppet) -f /var/log/cloud-init-output.log; bash -l'
else
ssh $SITE
fi
fi