-
Notifications
You must be signed in to change notification settings - Fork 0
/
prep-server.sh
executable file
·57 lines (44 loc) · 1.55 KB
/
prep-server.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
#!/usr/bin/env bash
. $(dirname $0)/install.conf
# configure subscription repositories
subscription-manager register --username="$RHSM_USER" --password="$RHSM_PASS" \
|| exit 1
if [ -z "$POOL_ID" ]
then
POOL_ID=$(subscription-manager list --available | \
grep 'Subscription Name\|Pool ID\|System Type' | \
grep -A2 'Employee SKU' | \
grep -B1 Physical | \
grep 'Pool ID' | awk '{print $NF; exit}')
fi
subscription-manager attach --pool="$POOL_ID" || exit 1
subscription-manager repos --disable='*'
subscription-manager repos \
--enable=rhel-7-server-rpms \
--enable=rhel-7-server-extras-rpms \
--enable=rhel-7-server-ose-3.11-rpms \
--enable=rhel-7-server-ansible-2.6-rpms
# update the system
yum -y update
# configure a separate volume group for docker (e.g. docker-vg)
DISK=$(parted -l | grep Disk | grep -v 'mapper\|Flags' | awk '{print $2; exit}' | cut -d: -f1)
FREESPACE=$(parted $DISK print free | grep 'Free Space' | tail -1)
START=$(echo $FREESPACE | awk '{print $1}')
END=$(echo $FREESPACE | awk '{print $2}')
PREBLKLIST=$(mktemp)
POSTBLKLIST=$(mktemp)
blkid | grep $DISK | cut -d: -f1 | sort > $PREBLKLIST
parted $DISK mkpart primary $START $END
PARTNUM=$(parted $DISK print | sort -n | tail -1 | awk '{print $1}')
parted $DISK set $PARTNUM lvm on
blkid | grep $DISK | cut -d: -f1 | sort > $POSTBLKLIST
PARTNAME=$(comm -13 $PREBLKLIST $POSTBLKLIST)
if [[ -z "$PARTNAME" ]]
then
PARTNAME=$DISK$PARTNUM
fi
pvcreate $PARTNAME
vgcreate docker-vg $PARTNAME
rm -f $PREBLKLIST $POSTBLKLIST
yum -y clean all
systemctl reboot