This repository has been archived by the owner on Sep 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from pukkamustard/installer
Installer
- Loading branch information
Showing
12 changed files
with
495 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
out ?= build | ||
|
||
# Ubuntu fies | ||
UBUNTU_FILES = $(out)/ubuntu/boot.ipxe $(out)/ubuntu/preseed.cfg | ||
|
||
all: $(out)/installer.usb $(out)/boot.ipxe $(UBUNTU_FILES) | ||
install: all | ||
|
||
$(out)/installer.usb: $(IPXE_USB) | ||
mkdir -p $(out) | ||
cp $(IPXE_USB) $(out)/installer.usb | ||
|
||
# Copy main ipxe script | ||
$(out)/boot.ipxe: boot.ipxe | ||
mkdir -p $(out) | ||
cp boot.ipxe $(out)/boot.ipxe | ||
|
||
# Copy Ubuntu boot script and preseed config | ||
$(out)/ubuntu/boot.ipxe: ubuntu/boot.ipxe | ||
mkdir -p $(out)/ubuntu | ||
cp ubuntu/boot.ipxe $(out)/ubuntu/boot.ipxe | ||
|
||
$(out)/ubuntu/preseed.cfg: ubuntu/preseed.cfg | ||
mkdir -p $(out)/ubuntu | ||
cp ubuntu/preseed.cfg $(out)/ubuntu/preseed.cfg | ||
|
||
# Deploy website to boot.dividat.com | ||
deploy: clean all | ||
aws s3 sync $(out) "s3://boot.dividat.com" --region="eu-central-1" --delete --cache-control max-age=5 | ||
|
||
.PHONY: qemu | ||
qemu: $(out)/installer.usb | ||
@# Qemu requires write access to disk image | ||
chmod +w $< | ||
qemu-system-x86_64 -hda $< | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Play Computer Installer | ||
|
||
Installer for (as much as possible) automized installation of Ubuntu based system for usage with Dividat Play. | ||
|
||
## Overview | ||
|
||
The built artifacts are: | ||
|
||
- `installer.usb`: A bootable USB image | ||
- `boot.ipxe`: An iPXE script | ||
- `ubuntu/`: Ubuntu specific iPXE script and preseed configuration | ||
|
||
The bootable USB image is based on [iPXE](http://ipxe.org/) with an [embeded script](./ipxe/embed.ipxe) that will load the script [`boot.ipxe`](boot.ipxe) which is deployed to <https://boot.dividat.com>. | ||
|
||
The script [`boot.ipxe`](boot.ipxe) will present a menu and ask for confirmation to continue with installation. Installation continues by loading the script [`ubuntu/boot.ipxe`](ubuntu/boot.ipxe). | ||
|
||
The script [`ubunut/boot.ipxe`](ubuntu/boot.ipxe) downloads and starts an Ubuntu installer with [preseed](https://help.ubuntu.com/lts/installation-guide/s390x/apb.html). | ||
|
||
The [preseed configuration](ubuntu/preseed.cfg) will run `ansible-pull` to set up system as play-computer. | ||
|
||
## Development | ||
|
||
### Prerequisites | ||
|
||
- [Nix](https://nixos.org/nix) is required for installing dependencies and providing a suitable development environment. | ||
- Qemu can be used for testing the created boot images | ||
|
||
### Quick start | ||
|
||
`nix-shell --command make` | ||
|
||
### Testing with Qemu | ||
|
||
`nix-shell --command 'make clean && make qemu'` | ||
|
||
### Deploying to `boot.dividat.com` | ||
|
||
`nix-shell --command 'make deploy'` | ||
|
||
### Caveats | ||
|
||
- The iPXE image is built by Nix as a buildInput to this derivation. If you start a `nix-shell`, make changes to the `ipxe/` folder and run `make` the changes in the `ipxe/` folder will not be picked up. This can be fixed by some Makefile hacking. An easy way out: restart your `nix-shell`. A nicer way: build using `nix-build -o build`. A subsequent `make deploy` will work as `awscli` follows symlinks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!ipxe | ||
###################### boot.dividat.com ############################# | ||
|
||
:start | ||
|
||
###################### MAIN MENU #################################### | ||
isset ${menu-default} || set menu-default install | ||
|
||
menu Setup computer for Dividat Play || goto shell | ||
item --gap -- ------------------------- Setup ------------------------------ | ||
item install Remove USB stick and continue with setup. WARNING: THIS WILL DELETE ANY DATA ON HARD DRIVE!!! | ||
item --gap -- ------------------------- Other ------------------------------ | ||
item shell Drop to iPXE shell | ||
item exit Exit iPXE and continue BIOS boot | ||
item reboot Reboot computer | ||
choose selected && goto ${selected} | ||
|
||
:reboot | ||
reboot | ||
|
||
:exit | ||
exit | ||
|
||
:shell | ||
echo Type 'exit' to get the back to the menu | ||
shell | ||
goto :start | ||
|
||
:install | ||
chain --autofree ubuntu/boot.ipxe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
with import <nixpkgs> {}; | ||
let | ||
ipxe = | ||
(import ./ipxe { | ||
inherit stdenv fetchgit; | ||
inherit lzma binutils mtools syslinux perl cdrtools; | ||
}); | ||
in | ||
stdenv.mkDerivation rec { | ||
name = "play-computer-installer"; | ||
buildInputs = [ | ||
awscli | ||
]; | ||
|
||
src = ./.; | ||
|
||
shellHook = '' | ||
export IPXE_USB=${ipxe} | ||
# Setup build directory | ||
export out=$(pwd)/build | ||
''; | ||
|
||
configurePhase = '' | ||
export IPXE_USB=${ipxe} | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ stdenv, fetchgit | ||
, lzma, binutils, mtools, syslinux, perl, cdrtools | ||
, name ? "ipxe.usb" | ||
}: | ||
stdenv.mkDerivation { | ||
inherit name; | ||
|
||
buildInputs = [ lzma binutils mtools syslinux perl cdrtools ]; | ||
|
||
src = fetchgit { | ||
url = "git://git.ipxe.org/ipxe.git"; | ||
rev = "d2063b7693e0e35db97b2264aa987eb6341ae779"; | ||
sha256 = "16sv591607v0anap63mw13d6gf4p98hb7w78npv3m041c2gbaldw"; | ||
}; | ||
|
||
hardeningDisable = [ | ||
"stackprotector" | ||
]; | ||
|
||
patches = [ | ||
./init-reg.diff | ||
./download-proto-https.diff | ||
./makefile-echo.diff | ||
]; | ||
|
||
buildPhase = '' | ||
cd src/ | ||
make bin/ipxe.usb EMBED=${./embed.ipxe} | ||
''; | ||
|
||
installPhase = '' | ||
cp bin/ipxe.usb $out | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/config/general.h b/src/config/general.h | ||
index 3c14a2cd..8867f152 100644 | ||
--- a/src/config/general.h | ||
+++ b/src/config/general.h | ||
@@ -54,7 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); | ||
|
||
#define DOWNLOAD_PROTO_TFTP /* Trivial File Transfer Protocol */ | ||
#define DOWNLOAD_PROTO_HTTP /* Hypertext Transfer Protocol */ | ||
-#undef DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */ | ||
+#define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */ | ||
#undef DOWNLOAD_PROTO_FTP /* File Transfer Protocol */ | ||
#undef DOWNLOAD_PROTO_SLAM /* Scalable Local Area Multicast */ | ||
#undef DOWNLOAD_PROTO_NFS /* Network File System Protocol */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!ipxe | ||
|
||
dhcp | ||
|
||
chain --autofree https://boot.dividat.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c | ||
index 2cd41d4cab51..fa696694639a 100644 | ||
--- a/src/drivers/net/etherfabric.c | ||
+++ b/src/drivers/net/etherfabric.c | ||
@@ -2210,7 +2210,7 @@ falcon_reset_xaui ( struct efab_nic *efab ) | ||
static int | ||
falcon_xaui_link_ok ( struct efab_nic *efab ) | ||
{ | ||
- efab_dword_t reg; | ||
+ efab_dword_t reg = { 0 }; | ||
int align_done, lane_status, sync; | ||
int has_phyxs; | ||
int link_ok = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping | ||
index f8334921..ea9577d4 100644 | ||
--- a/src/Makefile.housekeeping | ||
+++ b/src/Makefile.housekeeping | ||
@@ -10,8 +10,8 @@ | ||
TAB := $(shell $(PRINTF) '\t') | ||
ECHO_E_ECHO := $(ECHO) | ||
ECHO_E_ECHO_E := $(ECHO) -e | ||
-ECHO_E_BIN_ECHO := /bin/echo | ||
-ECHO_E_BIN_ECHO_E := /bin/echo -e | ||
+ECHO_E_BIN_ECHO := echo | ||
+ECHO_E_BIN_ECHO_E := echo -e | ||
ECHO_E_ECHO_TAB := $(shell $(ECHO_E_ECHO) '\t' | cat) | ||
ECHO_E_ECHO_E_TAB := $(shell $(ECHO_E_ECHO_E) '\t' | cat) | ||
ECHO_E_BIN_ECHO_TAB := $(shell $(ECHO_E_BIN_ECHO) '\t') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!ipxe | ||
|
||
|
||
set ubuntu_version artful | ||
set arch amd64 | ||
set ubuntu_mirror ch.archive.ubuntu.com | ||
|
||
#set kickstart_config http://boot.dividat.com/ubuntu/ks.cfg | ||
#set params ks=${kickstart_config} | ||
|
||
set install_params auto=true priority=critical locale=en_US keyboard-configuration/layoutcode=us preseed/url=http://boot.dividat.com/ubuntu/preseed.cfg preseed/interactive=false | ||
|
||
set dir ubuntu/dists/${ubuntu_version}/main/installer-${arch}/current/images/netboot/ubuntu-installer/${arch} | ||
|
||
echo Loading Ubuntu ${ubuntu_version} ${arch} | ||
kernel http://${ubuntu_mirror}/${dir}/linux ${install_params} ${netcfg} ${mirrorcfg} ${console} -- quiet ${params} initrd=initrd.gz || goto error | ||
initrd http://${ubuntu_mirror}/${dir}/initrd.gz || goto error | ||
|
||
boot | ||
|
||
:error | ||
echo "Error! Starting shell." | ||
shell |
Oops, something went wrong.