-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-vm.sh
executable file
·99 lines (76 loc) · 2.53 KB
/
setup-vm.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
97
#!/usr/bin/env bash
# Copyright (c) 201 IBM Corp.
#
# All Rights Reserved.
#
# Note(dkehn): this should be set by the caller.
PROJECT_NAME=${PROJECT_NAME:-"icp"}
export INSTALL_ANSIBLE=${INSTALL_ANSIBLE:-""}
PROG=$(basename $0)
# Make sure custom grep options don't get in the way
unset GREP_OPTIONS
# NOTE(dkehn): uncomment for debug puposes.
# set -x xtrace
VERBOSE="True"
# Sanitize language settings to avoid commands bailing out
# with "unsupported locale setting" errors.
unset LANG
unset LANGUAGE
LC_ALL=C
export LC_ALL
# Make sure umask is sane
umask 022
# Not all distros have sbin in PATH for regular users.
PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
# Keep track of the project directory
TOP_DIR=$(cd $(dirname "$0") && pwd)
source $TOP_DIR/functions
msgout "INFO" "line:$LINENO:******************** RUNNING $TOP_DIR/$PROG*********************"
msgout "INFO" "line:$LINENO: make sure sytem is updated."
GetOSVersion
if [ "$os_VENDOR" == 'Ubuntu' ]; then
exact_vers=`cat /etc/lsb-release |grep DISTRIB_DESCRIPTION |awk '{split($0, b," "); print b[2];}'`
major=`echo $exact_vers | awk '{split($0, b, "."); print b[1];}'`
minor=`echo $exact_vers | awk '{split($0, b, "."); print b[2];}'`
patch=`echo $exact_vers | awk '{split($0, b, "."); print b[3];}'`
msgout "INFO" "exact version number: $exact_vers"
if [ "$patch" -lt "3" ]; then
msgout "WARN" "upgrading ............"
sudo apt-get update
sudo apt-get upgrade -y
msgout "INFO" "You must reboot, NOW!"
exit 1
else
msgout "INFO" "no upgrade necessary"
fi
fi
os_installer='apt-get'
if is_fedora; then
os_install='yum'
fi
if [ "$INSTALL_ANSIBLE" == "Yes" ]; then
msgout "INFO" "line:$LINENO install ansible"
sudo $os_installer install ansible
fi
msgout "INFO" "line:$LINENO install necessary docker packages"
if is_fedora; then
sudo yum install libvirt-daemon-kvm qemu-kvm
else
sudo apt install libvirt-bin qemu-kvm docker.io
fi
msgout "INFO" "line:$LINENO installing minikube and packages"
source $TOP_DIR/minikube-functions.sh
install_minikube
msgout "INFO" "Make sure we are part of the groups"
my_groups=`id -Gn $USER`
for grp in "libvirt" "docker" "libvirtd"; do
if [[ $my_groups != *"$grp"* ]]; then
sudo gpasswd -a $USER $grp
fi
done
# NOTE [dkehn]:I'm keeping this here for preservation.
# ansible-playbook --user=$USER --ask-become-pass ansible-minikube-db/site.yml -vvv
msgout "INFO" "Starting minikube"
# start_minikube
# setup_kubectl
msgout "INFO" "Completed in $SECONDS seconds"