-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinstall-rhel7.sh
107 lines (85 loc) · 2.99 KB
/
install-rhel7.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
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Reset Color
NC='\033[0m'
# Regular Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
echo -n "FQDN: "
hostname -f
read -p "Do you see valid FQDN (e.g. puppet.atomia.local)? y/n: " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Exiting without any action. Please correct FQDN in /etc/hosts file."
exit
fi
read -p "This script will remove any previous Atomia installations on this server. Is this ok? y/n: " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "${GREEN}Starting the installation${NC}"
else
echo "${RED}Exiting without any action${NC}"
exit
fi
sudo yum -y install epel-release
sudo yum -y install gcc-c++ make openssl wget jq
sudo yum -y install nodejs
sudo yum -y install git npm mariadb-server python-pip
sudo pip install pywinrm
# Disable firewalld
systemctl disable firewalld
systemctl stop firewalld
sudo systemctl enable mariadb
sudo systemctl start mariadb
cd /opt
sudo git clone https://github.com/atomia/puppetmaster-gui.git
if [ $? -eq 0 ]; then
echo -e "${GREEN}puppetmaster-gui repo cloned successfuly${NC}"
else
echo -e "${RED}puppetmaster-gui repo cloning failed!!!${NC}"
fi
cd puppetmaster-gui
git checkout master
if [ $? -eq 0 ]; then
echo -e "${GREEN}Successfully switched to master branch${NC}"
else
echo -e "${RED}Switching to master branch failed!!!${NC}"
fi
cd app
sudo npm install
MYSQL_PASSWORD=`openssl rand -base64 16`
sudo mysql --defaults-file=/etc/my.cnf -e "GRANT USAGE ON *.* TO 'puppetgui'@'localhost'; DROP USER 'puppetgui'@'localhost';"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Granted usage to puppetgui@localhost on *.*${NC}"
else
echo -e "${RED}Grant usage to puppetgui@localhost on *.* failed!!!${NC}"
fi
sudo mysql --defaults-file=/etc/my.cnf -e "CREATE USER 'puppetgui'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';GRANT ALL PRIVILEGES ON hiera.* TO 'puppetgui'@'localhost';FLUSH PRIVILEGES;"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Created user puppetgui@localhost with ${YELLOW}${MYSQL_PASSWORD}${GREEN} password, and granted all privileges to hiera.*${NC}"
else
echo -e "${RED}Creation of puppetgui@localhost user failed!!!${NC}"
fi
cd /opt/puppetmaster-gui/app
sudo mysqldump --defaults-file=/etc/my.cnf -A > mysql_backup_`date +%F_%H%M`.sql
sudo mysql --defaults-file=/etc/my.cnf < schema.sql
if [ $? -eq 0 ]; then
echo -e "${GREEN}DB schema imported successfully${NC}"
else
echo -e "${RED}DB schema import failed!!!${NC}"
fi
sudo bash -c 'echo "{
\"database\" : {
\"user\": \"puppetgui\",
\"password\": \"'$MYSQL_PASSWORD'\",
\"database\": \"hiera\"
}
}" > /opt/puppetmaster-gui/app/config.json'
if [ $? -eq 0 ]; then
echo -e "${GREEN}Created /opt/puppetmaster-gui/app/config.json${NC}"
else
echo -e "${RED}Creation of /opt/puppetmaster-gui/app/config.json failed!!!${NC}"
fi
sudo cp /opt/puppetmaster-gui/puppetmaster-gui-sysd.service /lib/systemd/system/puppetmaster-gui.service
sudo systemctl enable puppetmaster-gui.service
sudo service puppetmaster-gui start