-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathautoinstall.sh
executable file
·62 lines (59 loc) · 2.2 KB
/
autoinstall.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
#!/bin/bash
SERVER_IP=$1
DHCP_RANGE=$2
ROOT_PASSWORD=$3
DHCP_SUBNET=$4
DHCP_ROUTER=$5
DHCP_DNS=$6
if [ ! $SERVER_IP ]
then
echo "Please set the IP address of the need to monitor."
elif [ ! $DHCP_RANGE ]
then
echo "Please set up DHCP network segment."
elif [ ! $ROOT_PASSWORD ]
then
echo "Please set the root password."
elif [ ! $DHCP_SUBNET ]
then
echo "Please set the dhcp subnet."
elif [ ! $DHCP_ROUTER ]
then
echo "Please set the dhcp router."
elif [ ! $DHCP_DNS ]
then
echo "Please set the dhcp dns."
else
#install cobbler and config it auto
cp -fr ./config /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum install -y cobbler cobbler-web dnsmasq syslinux pykickstart dhcp fence-agents
rpm -Uvh ftp://rpmfind.net/linux/epel/6/x86_64/debmirror-2.14-2.el6.noarch.rpm --nodeps --force
systemctl enable cobblerd
systemctl start cobblerd
systemctl enable httpd
systemctl start httpd
cobbler get-loaders
cp -fr ./settings /etc/cobbler/settings
cp -fr ./modules.conf /etc/cobbler/modules.conf
systemctl enable xinetd
systemctl start xinetd
cp -fr ./rsync /etc/xinetd.d/rsync
cp -fr ./debmirror.conf /etc/debmirror.conf
PASSWORD=`openssl passwd -1 -salt hLGoLIZR $ROOT_PASSWORD`
sed -i "s/^server: 127.0.0.1/server: $SERVER_IP/g" /etc/cobbler/settings
sed -i "s/^next_server: 127.0.0.1/next_server: $SERVER_IP/g" /etc/cobbler/settings
# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings
# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
sed -i "s#^default_password.*#default_password_crypted: \"$PASSWORD\"#g" /etc/cobbler/settings
sed -i "s/192.168.1.0/$DHCP_SUBNET/" /etc/cobbler/dhcp.template
sed -i "s/192.168.1.5/$DHCP_ROUTER/" /etc/cobbler/dhcp.template
sed -i "s/192.168.1.1;/$DHCP_DNS;/" /etc/cobbler/dhcp.template
sed -i "s/192.168.1.100 192.168.1.254/$DHCP_RANGE/" /etc/cobbler/dhcp.template
sed -i "s/192.168.1.100 192.168.1.254/$DHCP_RANGE/" /etc/cobbler/dnsmasq.template
systemctl restart cobblerd
# cobbler check
cobbler sync
fi