forked from hashicorp/puppet-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
legacy.sh
executable file
·81 lines (67 loc) · 2.65 KB
/
legacy.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
#!/usr/bin/env bash
#
# Detect and purge any known legacy puppet installs
#
set -e
FORCE_LEGACY_ITS_PUPPET=${FORCE_LEGACY_ITS_PUPPET:-""}
FORCE_LEGACY_DFY_PUPPET=${FORCE_LEGACY_DFY_PUPPET:-""}
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." >&2
exit 1
fi
if hash rvm 2>/dev/null; then
echo "[RVM Found]"
echo "Clearing rvm default and using system ruby..."
rvm alias delete default
unset GEM_HOME IRBRC MY_RUBY_HOME GEM_PATH RUBY_VERSION
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/rvm/bin
echo ""
fi
# IT Services Legacy Puppet installed with rvm
if [ -e /usr/local/bin/puppetcheckin.sh ] || [ -n "${FORCE_LEGACY_ITS_PUPPET}" ]; then
echo "[Legacy ITS Puppet Found]"
# crons
echo "Removing Cron..."
crontab -u root -l |
grep -v '/usr/local/bin/puppetcheckin.sh' |
grep -v '# Puppet Name: reportingcron' |
grep -v '/var/reporting && ./report.pl' |
crontab -u root -
# preserve old puppet ssl certs, as tivoli and possible other use this
echo "Preserving legacy SSL (in /var/lib/puppet/ssl_legacy)..."
if [ ! -e /var/lib/puppet/ssl_legacy ]; then
mv /var/lib/puppet/ssl /var/lib/puppet/ssl_legacy
fi
if [ -e /etc/init.d/tivoli ]; then
echo "Editing to reflect legacy SSL/facter location (/etc/init.d/tivoli)"
sed -i 's~/usr/local/bin/facter~/usr/bin/facter~g' /etc/init.d/tivoli
sed -i 's~/var/lib/puppet/ssl/~/var/lib/puppet/ssl_legacy/~g' /etc/init.d/tivoli
fi
echo "You probably want to edit anything else using Legacy SSL/facter..."
# binaries/scripts/config/etc
echo "Removing Files (in /usr/local/bin/ /etc/sysconfig/)..."
rm -rf /usr/local/bin/facter* /usr/local/bin/puppetcheckin*.sh* /etc/sysconfig/puppet
echo ""
fi
# Dragonfly Legacy Puppet installed with rvm
if [ -e /usr/local/dragonfly/puppet ] || [ -n "${FORCE_LEGACY_DFY_PUPPET}" ]; then
echo "[Legacy Dragonfly Puppet Found]"
# crons
echo "Removing Cron..."
crontab -u root -l |
grep -v 'Puppet Name: puppet-agent' |
grep -v 'http_proxy=http://webproxy.mcs.miamioh.edu:80' |
grep -v 'https_proxy=http://webproxy.mcs.miamioh.edu:80' |
grep -v 'no_proxy=localhost,127.0.0.0/8,\*.local,\*.mcs.miamioh.edu' |
grep -v '/usr/local/dragonfly/puppet/bin/puppet-agent' |
crontab -u root -
if [ -e /etc/profile.d/http_proxy.sh ]; then
echo "Removing legacy proxy profile (/etc/profile.d/http_proxy.sh)"
rm -rf /etc/profile.d/http_proxy.sh
fi
# binaries/scripts/config/etc
echo "Removing Files (in /usr/local/dragonfly/puppet/)..."
rm -rf /usr/local/dragonfly/bin/filebucket-find /usr/local/dragonfly/bin/puppet-agent
rm -rf /usr/local/dragonfly/puppet
echo ""
fi