forked from sebaxakerhtc/ipxe-simple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renew.sh
91 lines (91 loc) · 6.24 KB
/
renew.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
#! /bin/bash
git -C /ipxe pull
VAR1=$(git -C /ipxe log -1 --pretty=format:"%h" --abbrev-commit --abbrev=4)
grep -q "${VAR1}" /var/www/html/index.html && echo "There is no changes at `date`" && exit ||
rm -rf /ipxe
rm /config-backup/branding.h
rm /config-backup/general.h
rm /config-backup/console.h
echo "ipxe dir removed"
cp /config-backup/wait.html /var/www/html/index.html
rm /var/www/html/bin/*
git clone git://git.ipxe.org/ipxe.git
sed -i "s/gitversion/${VAR1}/" /var/www/html/index.html
echo "SETTINGS"
echo BackUp files
cp ipxe/src/config/branding.h /config-backup/
cp ipxe/src/config/general.h /config-backup/
cp ipxe/src/config/console.h /config-backup/
echo "Editing branding.h"
sed -i 's/#define\ PRODUCT_NAME\ ""/#define\ PRODUCT_NAME\ "iPXE\ project"/' ipxe/src/config/branding.h
sed -i 's/#define\ PRODUCT_SHORT_NAME\ "iPXE"/#define\ PRODUCT_SHORT_NAME\ "ipxe-latest"/' ipxe/src/config/branding.h
echo "Editing general.h"
sed -i 's/#undef\tDOWNLOAD_PROTO_HTTPS/#define\ DOWNLOAD_PROTO_HTTPS/' ipxe/src/config/general.h
sed -i 's/#undef\tDOWNLOAD_PROTO_FTP/#define\ DOWNLOAD_PROTO_FTP/' ipxe/src/config/general.h
sed -i 's/#undef\tDOWNLOAD_PROTO_NFS/#define\ DOWNLOAD_PROTO_NFS/' ipxe/src/config/general.h
sed -i 's/\/\/#undef\tSANBOOT_PROTO_ISCSI/#define\ SANBOOT_PROTO_ISCSI/' ipxe/src/config/general.h
sed -i 's/\/\/#undef\tSANBOOT_PROTO_HTTP/#define\ SANBOOT_PROTO_HTTP/' ipxe/src/config/general.h
sed -i 's/\/\/#define\tIMAGE_PXE/#define\ IMAGE_PXE/' ipxe/src/config/general.h
sed -i 's/\/\/#define\tIMAGE_SCRIPT/#define\ IMAGE_SCRIPT/' ipxe/src/config/general.h
sed -i 's/\/\/#define\tIMAGE_BZIMAGE/#define\ IMAGE_BZIMAGE/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ DIGEST_CMD/#define\ DIGEST_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ REBOOT_CMD/#define\ REBOOT_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ POWEROFF_CMD/#define\ POWEROFF_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ IMAGE_TRUST_CMD/#define\ IMAGE_TRUST_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ PING_CMD/#define\ PING_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ CONSOLE_CMD/#define\ CONSOLE_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ IPSTAT_CMD/#define\ IPSTAT_CMD/' ipxe/src/config/general.h
sed -i 's/\/\/#define\ CERT_CMD/#define\ CERT_CMD/' ipxe/src/config/general.h
echo "Editing console.h"
sed -i 's/\/\/#undef\tCONSOLE_PCBIOS/#define\ CONSOLE_PCBIOS/' ipxe/src/config/console.h
sed -i 's/\/\/#define\tCONSOLE_FRAMEBUFFER/#define\ CONSOLE_FRAMEBUFFER/' ipxe/src/config/console.h
sed -i 's/\/\/#define\tCONSOLE_DIRECT_VGA/#define\ CONSOLE_DIRECT_VGA/' ipxe/src/config/console.h
echo "Runing make..."
sleep 3
make -C ipxe/src
echo "Adding scripts"
cp /config-backup/Legacy.ipxe /ipxe/src/
cp /config-backup/EFI.ipxe /ipxe/src/
echo "Creating Legacy BIOS Images"
sleep 3
make bin/ipxe.iso EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.iso /var/www/html/bin/
make bin/ipxe.dsk EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.dsk /var/www/html/bin/
make bin/ipxe.lkrn EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.lkrn /var/www/html/bin/
make bin/ipxe.usb EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.usb /var/www/html/bin/
make bin/ipxe.pxe EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.pxe /var/www/html/bin/
make bin/ipxe.kpxe EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.kpxe /var/www/html/bin/
make bin/ipxe.kkpxe EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.kkpxe /var/www/html/bin/
make bin/ipxe.kkkpxe EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/ipxe.kkkpxe /var/www/html/bin/
make bin/undionly.kpxe EMBED=Legacy.ipxe -C ipxe/src && mv ipxe/src/bin/undionly.kpxe /var/www/html/bin/
echo "Compress BIOS Images to archive"
zip -0 -j /var/www/html/bin/ipxe_all_bios_mages /var/www/html/bin/ipxe.iso /var/www/html/bin/ipxe.dsk /var/www/html/bin/ipxe.lkrn /var/www/html/bin/ipxe.usb /var/www/html/bin/ipxe.pxe /var/www/html/bin/ipxe.kpxe /var/www/html/bin/ipxe.kkpxe /var/www/html/bin/ipxe.kkkpxe /var/www/html/bin/undionly.kpxe
echo "BIOS Images compressed"
echo "SETTINGS EFI"
echo "Editing general.h"
sed -i 's/#define\ IMAGE_PXE/\/\/#define\ IMAGE_PXE/' ipxe/src/config/general.h
sed -i 's/#define\ IMAGE_BZIMAGE/\/\/#define\ IMAGE_BZIMAGE/' ipxe/src/config/general.h
sed -i 's/\/\/#define\tIMAGE_EFI/#define\ IMAGE_EFI/' ipxe/src/config/general.h
echo "Editing console.h"
sed -i 's/#define\ CONSOLE_PCBIOS/\/\/#define\ CONSOLE_PCBIOS/' ipxe/src/config/console.h
sed -i 's/\/\/#undef\tCONSOLE_EFI/#define\tCONSOLE_EFI/' ipxe/src/config/console.h
echo "Creating EFI Images"
make bin-x86_64-efi/ipxe.efi EMBED=EFI.ipxe -C ipxe/src && cp ipxe/src/bin-x86_64-efi/ipxe.efi /var/www/html/bin/bootx64.efi
make bin-x86_64-efi/ipxe.usb EMBED=EFI.ipxe -C ipxe/src && mv ipxe/src/bin-x86_64-efi/ipxe.usb /var/www/html/bin/ipxe-efi-x64.usb
make bin-x86_64-efi/ipxe.iso EMBED=EFI.ipxe -C ipxe/src && mv ipxe/src/bin-x86_64-efi/ipxe.iso /var/www/html/bin/ipxe-efi-x64.iso
make bin-x86_64-efi/snponly.efi EMBED=EFI.ipxe -C ipxe/src && cp ipxe/src/bin-x86_64-efi/snponly.efi /var/www/html/bin/snponly-x64.efi
make bin-i386-efi/ipxe.efi EMBED=EFI.ipxe -C ipxe/src && cp ipxe/src/bin-i386-efi/ipxe.efi /var/www/html/bin/bootia32.efi
make bin-i386-efi/ipxe.usb EMBED=EFI.ipxe -C ipxe/src && mv ipxe/src/bin-i386-efi/ipxe.usb /var/www/html/bin/ipxe-efi-x86.usb
make bin-i386-efi/ipxe.iso EMBED=EFI.ipxe -C ipxe/src && mv ipxe/src/bin-i386-efi/ipxe.iso /var/www/html/bin/ipxe-efi-x86.iso
make bin-i386-efi/snponly.efi EMBED=EFI.ipxe -C ipxe/src && cp ipxe/src/bin-i386-efi/snponly.efi /var/www/html/bin/snponly-x86.efi
echo "Compress EFI Images to archive"
zip -0 -j /var/www/html/bin/ipxe_all_uefi_mages /var/www/html/bin/bootx64.efi /var/www/html/bin/ipxe-efi-x64.usb /var/www/html/bin/ipxe-efi-x64.iso /var/www/html/bin/snponly-x64.efi /var/www/html/bin/bootia32.efi /var/www/html/bin/ipxe-efi-x86.usb /var/www/html/bin/ipxe-efi-x86.iso /var/www/html/bin/snponly-x86.efi
echo "EFI Images compressed"
echo "Cleaning project"
make clean -C ipxe/src
rm /var/www/html/index.html
cp /config-backup/orig.html /var/www/html/index.html
sed -i "s/gitversion/${VAR1}/" /var/www/html/index.html
cp /config-backup/branding.h ipxe/src/config/branding.h
cp /config-backup/general.h ipxe/src/config/general.h
cp /config-backup/console.h ipxe/src/config/console.h
echo "Script completed"