-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRPM-chef-cinc.sh
executable file
·96 lines (86 loc) · 2.93 KB
/
RPM-chef-cinc.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
if [ -z "$VERSION" ]; then echo "\$VERSION is unset"; exit; fi
set -xue # xtrace, nounset, errexit
# Chef $VERSION RPM
date
sudo systemctl stop chef-client
sudo systemctl stop chef-client.timer
sudo systemctl stop cinc-client
sudo systemctl stop cinc-client.timer
sudo yum remove omnibus-toolchain -y
sudo yum remove chef-workstation -y
sudo yum remove chef -y
sudo yum remove cinc -y
# Ruby 2.7.4
cd
rm -rf ~/.bundle
rm -rf ~/.gem
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
RUBYVERSION=$(ruby --version)
if [[ $RUBYVERSION =~ 2.7.4 ]]; then
echo "Using existing Ruby 2.7.4 provided by rbenv"
else
echo "Building Ruby 2.7.4"
rm -rf ~/.rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
mkdir plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 2.7.4
rbenv global 2.7.4
eval "$(rbenv init -)"
fi
set -xeuo pipefail #echo on, stop on failures
# Omnibus-Toolchain
cd
rm -rf ~/omnibus-toolchain
sudo rm -rf /opt/omnibus-toolchain /var/cache/omnibus
sudo mkdir /opt/omnibus-toolchain
sudo mkdir /var/cache/omnibus
sudo chown omnibus:omnibus -R /opt/omnibus-toolchain
sudo chown omnibus:omnibus -R /var/cache/omnibus
git clone https://github.com/chef/omnibus-toolchain.git
cd omnibus-toolchain
bundle config set without 'development docs debug'
bundle install --path=.bundle
bundle exec omnibus build omnibus-toolchain -l internal
cp ~/omnibus-toolchain/pkg/omnibus-toolchain*rpm ~/
sudo rm -rf /opt/omnibus-toolchain
sudo rpm -Uvh ~/omnibus-toolchain*rpm
sudo chown omnibus:omnibus -R /opt/omnibus-toolchain
export PATH="/opt/omnibus-toolchain/bin:$PATH"
# Chef $VERSION
cd
rm -rf ~/chef-$VERSION ~/v$VERSION.tar.gz
sudo rm -rf /opt/chef
sudo mkdir /opt/chef
sudo chown omnibus:omnibus -R /opt/chef
wget https://github.com/chef/chef/archive/v$VERSION.tar.gz
tar -xzf v$VERSION.tar.gz
cd ~/chef-$VERSION/omnibus/
bundle config set without 'development docs debug'
bundle install --path=.bundle
bundle exec omnibus build chef -l internal
cp ~/chef-$VERSION/omnibus/pkg/chef*rpm ~/
cp ~/chef-$VERSION/omnibus/pkg/chef*rpm /tmp/
sudo cp ~/chef-$VERSION/omnibus/pkg/chef*rpm /root/
# Cinc $VERSION
cd
rm -rf ~/cinc-full-$VERSION ~/cinc-full-$VERSION.tar.xz
sudo rm -rf /opt/chef /opt/cinc
sudo mkdir /opt/cinc
sudo chown omnibus:omnibus -R /opt/cinc
curl http://downloads.cinc.sh/source/stable/cinc/cinc-full-$VERSION.tar.xz --output cinc-full-$VERSION.tar.xz
tar -xJf cinc-full-$VERSION.tar.xz
cd cinc-full-$VERSION/cinc-$VERSION/omnibus/
bundle lock --update=chef
bundle config set without 'development docs debug'
bundle install --path=.bundle
bundle exec omnibus build cinc -l internal
cp ~/cinc-full-$VERSION/cinc-$VERSION/omnibus/pkg/cinc*rpm ~/
cp ~/cinc-full-$VERSION/cinc-$VERSION/omnibus/pkg/cinc*rpm /tmp/
sudo cp ~/cinc-full-$VERSION/cinc-$VERSION/omnibus/pkg/cinc*rpm /root/
chmod 644 /tmp/*rpm
echo "$VERSION Complete!"
date