-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevrbuilder.sh
More file actions
executable file
·134 lines (114 loc) · 3.82 KB
/
devrbuilder.sh
File metadata and controls
executable file
·134 lines (114 loc) · 3.82 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
#
# Copyright (c) SAS Institute Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script to convert an rbuilder to running out of a checkout and
# install any needed dev tools.
if [ $# -lt 2 ] ; then
echo "usage: $0 <hostname> <rbuilder branch> [type]"
exit 1
fi
hostname=$1
branch=$2
if [ -z $3 ] ; then
group_type="appliance"
else
group_type=$3
fi
if [ "$group_type" != "appliance" -a "$group_type" != "vapp" ] ; then
echo "type must be appengine or vapp"
exit 1
fi
local_checkout=$(dirname $0)
function run() {
ssh -A root@$hostname "$*"
rc=$?
if [ "$rc" != "0" ] ; then
echo "command failed: $*"
exit 1
fi
return $rc
}
function copy() {
source=$1
dest=$2
scp -r $source root@$hostname:$dest
rc=$?
if [ "$rc" != "0" ] ; then
echo "copy failed: $*"
exit 1
fi
return $rc
}
# Deploy my ssh key
#if [ "$group_type" == "vapp" ] ; then
# if [ -e ~/.ssh/id_*.pub ] ; then
# curl -k -F 'files=@~/.ssh/id_*.pub' https://$hostname/SASvAppLedger/authorizedKeys
# else
# curl -k -F "files=$(ssh-add -L | head -n1)" https://$hostname/SASvAppLedger/authorizedKeys
# fi
# ssh -t -A sas@$hostname "su -c 'cp -R /home/sas/.ssh /root/.'"
#else
# ssh-copy-id root@$hostname
#fi
#
## Copy my known hosts to avoid asking later
#copy ~/.ssh/known_hosts /root/.ssh/known_hosts
#
# Get the latest versions of group rbuilder
platform=$(conary rq --labels group-rpath-platform=newton.eng.rpath.com@sas:platform-$branch-devel)
dist=$(conary rq --labels group-rbuilder-dist=newton.eng.rpath.com@sas:rba-$branch-rba)
tmpcnyconf=$(mktemp)
cat << EOF >$tmpcnyconf
proxyMap 10.0.0.0/8 DIRECT
proxyMap 172.16.0.0/12 DIRECT
proxyMap 192.168.0.0/16 DIRECT
proxyMap * conarys://rbuilder.unx.sas.com
proxyMap * conary://rbuilder.unx.sas.com
proxyMap * http://inetgw.fyi.sas.com
EOF
copy $tmpcnyconf /etc/conary/config.d/httpProxy
cat $local_checkout/rbuilder-system-model | \
sed -e "s|^search\ group-rpath-platform.*|search\ $platform|" | \
sed -e "s|^search\ group-rbuilder-dist.*|search\ $dist|" | \
sed -e "s|^install\ group-rbuilder-.*|install\ group-rbuilder-$group_type|" > \
/tmp/rbuilder-system-model
# Configure conary to use rbuilder.unx as a proxy
run "echo 'includeConfigFile http://delphi.unx.sas.com/conaryrc' > /etc/conary/config.d/proxy"
# Copy over the system model and update the system
copy /tmp/rbuilder-system-model /etc/conary/system-model
run echo 'updating system'
run conary updateall
# Write out my hgrc
copy ~/.gitconfig /root/.gitconfig
# Copy vim config
copy ~/.vimrc /root/.vimrc
copy ~/.vim /root/.vim
# fclone the rBuilder forest
checkoutdir="/srv/code/products/rbuilder"
checkout="$checkoutdir/$branch"
run mkdir -p $checkoutdir
#run hg fclone ssh://$USER@scc.unx.sas.com//hg/products/rbuilder/$branch $checkout
run forester init --branch $branch --wms --wmsbase http://wheresmystuff.unx.sas.com --wmspath scc/appengine --subdir /root/git --forest appengine
run forester clone appengine
run ln -sf /root/git/scc/appengine $checkout
run make -C $checkout/appengine
run make -C $checkout/appengine install-pth
# Setup python config
if [ -f ~/.pystartup ] ; then
copy ~/.pystartup /root/.pystartup
run 'echo "export PYTHONSTARTUP=$HOME/.pystartup" >> /root/.bashrc'
fi
run $checkout/mint/scripts/group-script