-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwizard.sh
More file actions
executable file
·73 lines (64 loc) · 2.24 KB
/
wizard.sh
File metadata and controls
executable file
·73 lines (64 loc) · 2.24 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
#!/bin/bash
# Copyright 2014, Dell
#
# 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.
date
export RAILS_ENV=production
# Hack to clean out docker container for now.
rm -rf /etc/yum.repos.d/crowbar-open*
cd /opt/opencrowbar/core
. ./bootstrap.sh
set -e
set -o pipefail
if [[ $http_proxy && !$upstream_proxy ]] && ! pidof squid; then
export upstream_proxy=$http_proxy
fi
hostname_re='([[:alnum:]]+\.){2,}[[:alnum:]]+'
FQDN=$(hostname)
if [[ $1 ]]; then
if [[ $1 != $FQDN ]]; then
if ! [[ $1 =~ $hostname_re ]]; then
echo "Cannot set system hostname to $1, it is not a valid hostname!"
exit 1
fi
if [[ -f /.dockerenv ]]; then
FQDN="$(hostname -s).${1#*.}"
else
FQDN="$1"
# Fix Ubuntu/Debian Hostname
echo "$FQDN" > /etc/hostname
fi
echo "Changing system hostname from $(hostname) to $FQDN"
hostname $FQDN
fi
elif ! [[ $FQDN =~ $hostname_re ]]; then
echo "$FQDN is not a valid FQDN"
echo "Please pass one as the first parameter to this script so we can set it."
exit 1
fi
# Fix up the localhost address mapping.
if [[ ! -f /.dockerenv ]]; then
sed -i -e "s/\(127\.0\.0\.1.*\)/127.0.0.1 $FQDN $HOSTNAME localhost.localdomain localhost/" /etc/hosts
sed -i -e "s/\(127\.0\.1\.1.*\)/127.0.1.1 $FQDN $HOSTNAME localhost.localdomain localhost/" /etc/hosts
fi
# Fix CentOs/RedHat Hostname
if [ -f /etc/sysconfig/network ] ; then
sed -i -e "s/HOSTNAME=.*/HOSTNAME=$FQDN/" /etc/sysconfig/network
fi
# Set domainname (for dns)
echo "${FQDN#*.}" > /etc/domainname
export FQDN
mkdir -p /var/log/crowbar
for stage in boot consul database chef-server core config ; do
"./crowbar-${stage}.sh" 2>&1 |tee "/var/log/crowbar/install-${stage}.log"
done