-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_cobbler.sh
More file actions
executable file
·91 lines (78 loc) · 2.74 KB
/
install_cobbler.sh
File metadata and controls
executable file
·91 lines (78 loc) · 2.74 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# ==========================================================
# This script install and setup cobbler and TFTP server
# to serve as the PXE server of a given network
# Optionally send proxy server to install packages
# =========================================================
# Uncomment the following line to debug
set -o xtrace
#=================================================
# GLOBAL FUNCTIONS
#=================================================
#echo '<UNDER DEVELOPMENT>' && exit 0
source common_packages
EnsureRoot
SetLocale /root
_PASSWORD='secure123'
# ========================= Processes installation options ===================
while [[ ${1} ]]; do
case "${1}" in
--help|-h)
read -d '' opts <<- EOF
\ --password | -p Cobbler password.
EOF
PrintHelp "Install cobbler" $(basename "$0") \
""
;;
--password|-p)
[[ -z "${2}" ]] && PrintError "Must provide a password."
_PASSWORD="${2}"
shift
;;
*)
HandleOptions "$@"
shift
esac
shift
done
# ============================= Cobbler instalation ==========================
[[ -n $http_proxy ]] && SetProxy $http_proxy
echo '--> Install prereqs'
apt-get -y -qq update
InstallDhcp
echo '--> Ensure SELinux is disabled or in permissive mode'
sudo apt-get install -y policycoreutils
[[ -n $(sestatus | grep enabled) ]] && setenforce 0
echo '--> Installing cobbler and dependencies'.
apt-get install -y cobbler cobbler-web
# Fix issue with apache2 mod_python by dissabling it
a2dismod python
systemctl restart apache2
chown www-data /var/lib/cobbler/webui_sessions
echo 'CONFIGURE COBBLER:'
echo '--> Changing cobbler encrypted password'
echo "$_PASSWORD" > ~/.cryptedPassword
crypt_pass=$(openssl passwd -1 -in ~/.cryptedPassword)
echo "$crypt_pass" > ~/.cryptedPassword
sed -i "s/^default_password_crypted.*$/default_password_crypted: \"$crypt_pass\"/g" /etc/cobbler/settings
echo '--> Setting Server IPs'
HOST_IP=$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')
if [[ -z $(cat /etc/cobbler/settings | grep -e "^server:.*$HOST_IP") ]]; then
sed -i "s/^server:.*/server: $HOST_IP/g" /etc/cobbler/settings
sed -i "s/^next_server:.*/next_server: $HOST_IP/g" /etc/cobbler/settings
fi
echo '--> Configuring DHCP Management'
sed -i "s/^manage_dhcp.*/manage_dhcp: 1/g" /etc/cobbler/settings
# Modify DHCP net/ ip range
# Use default 192.168.1.0/24 (max 254 hosts)
ConfigDhcpapt
# Change data dir from /var/www to /opt/cobbler
# See http://cobbler.github.io/manuals/2.6.0/2/5_-_Relocating_Your_Installation.html
exit 0
cobbler sync
cobbler get-loaders
echo '--> Starting cobbler.'
systemctl enable cobblerd.service
systemctl start cobblerd.service
# Cleanup _proxy from apt if added - first coincedence
UnsetProxy $_ORIGINAL_PROXY