-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateiso.sh
executable file
·105 lines (91 loc) · 2.28 KB
/
createiso.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
#!/bin/sh
###############################################################################
# HARDENED CentOS 7 DVD CREATOR
#
# This script was written by Frank Caviggia
# Last update was 23 July 2016
#
# Author: Frank Caviggia ([email protected])
# Copyright: Frank Caviggia, (c) 2016
# Version: 1.2
# License: GPLv2
# Description: Creates embedded kickstart from CentOS ISO that can preform
# a hardened installation based on DISA STIG
###############################################################################
# GLOBAL VARIABLES
DIR=`pwd`
# USAGE STATEMENT
function usage() {
cat << EOF
usage: $0 centos-7.X-x86_64-dvd.iso
EOF
}
while getopts ":vhq" OPTION; do
case $OPTION in
h)
usage
exit 0
;;
?)
echo "ERROR: Invalid Option Provided!"
echo
usage
exit 1
;;
esac
done
# Check for root user
if [[ $EUID -ne 0 ]]; then
if [ -z "$QUIET" ]; then
echo
tput setaf 1;echo -e "\033[1mPlease re-run this script as root!\033[0m";tput sgr0
fi
exit 1
fi
# Check for required packages
rpm -q genisoimage &> /dev/null
if [ $? -ne 0 ]; then
yum install -y genisoimage
fi
rpm -q isomd5sum &> /dev/null
if [ $? -ne 0 ]; then
yum install -y isomd5sum
fi
# Determine if DVD is Bootable
`file $1 | grep 9660 | grep -q bootable`
if [[ $? -eq 0 ]]; then
echo "Mounting CentOS DVD Image..."
mkdir -p /centos
mkdir $DIR/centos-dvd
mount -o loop $1 /centos
echo "Done."
if [ ! -e /centos/.treeinfo ]; then
echo "ERROR: Image is not CentOS"
exit 1
fi
echo -n "Copying CentOS DVD Image..."
cp -a /centos/* $DIR/centos-dvd/
cp -a /centos/.*info $DIR/centos-dvd/
echo " Done."
umount /centos
rm -rf /centos
else
echo "ERROR: ISO image is not bootable."
exit 1
fi
echo -n "Modifying CentOS DVD Image..."
cp -a $DIR/config/* $DIR/centos-dvd/
echo " Done."
echo "Remastering CentOS DVD Image..."
cd $DIR/centos-dvd
chmod u+w isolinux/isolinux.bin
find . -name TRANS.TBL -exec rm '{}' \;
genisoimage -l -r -J -V "CentOS 7 x86_64" -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -o $DIR/hardened-centos7-x86_64.iso .
cd $DIR
rm -rf $DIR/centos-dvd
echo "Done."
echo "Signing CentOS DVD Image..."
/usr/bin/implantisomd5 $DIR/hardened-centos7-x86_64.iso
echo "Done."
echo "DVD Created. [hardened-centos7-x86_64.iso]"
exit 0