diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c3baf0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Builds directories +build +.packer.d \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8269912 --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +# Xraspios + +Extended Raspberry Pi OS Lite Image based on Raspios and packaged with Packer. + +This operating system is installed on my Raspberry Pi 4 and serve as a home lab +server. It mainly run IaaS and APIs with Docker. + +## Features + +- [ ] Docker + - [ ] Portainer +- [ ] Git +- [ ] Tmux +- [ ] Vim +- [ ] Security + - [ ] SSH + - [x] User / Password + - [ ] Key + +## Requirements + +- [Packer](https://www.packer.io) (1.8.x) + +## Build Image + +> The image is built from the [Raspios Lite Armhf 2022-09-07](https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-09-07/) + +See `builder.pkr.hcl` + +Initialize the project, update dependencies + +```bash +packer init config.pkr.hcl +``` + +Build the image + +```bash +sudo packer build build.pkr.hcl +``` + +Once the build is finished, the image will be available in thes `build` folder +as `xraspios-lite.img` + +### Docker + +Build with the official Packer Docker [image](https://hub.docker.com/r/hashicorp/packer) + +> Not tested ! + +Initialize + +```bash +docker run \ + -v `pwd`:/workspace -w /workspace \ + -e PACKER_PLUGIN_PATH=/workspace/.packer.d/plugins \ + hashicorp/packer:latest \ + init . +``` + +Build + +```bash +docker run \ + -v `pwd`:/workspace -w /workspace \ + -e PACKER_PLUGIN_PATH=/workspace/.packer.d/plugins \ + hashicorp/packer:latest \ + build . +``` + +## Write Image + +Write the image to and SD card + +### Raspberry Pi Imager + +Use Raspberry Pi Imager to configure WiFi, users and more and write to image to +the card. + +> Check how rpi-imager write config + + + +### DD + +> When rpi-imager no more needed to configure the wifi and user. TODO: Keys and no user?! + +```bash +sudo dd bs=4M if=/dev/zero of=/dev/sdb oflag=sync +``` + +```bash +sudo dd bs=4M if=/path/to/image of=/dev/sdb oflag=sync +``` + +## References + +- +- +- +- +- diff --git a/build.pkr.hcl b/build.pkr.hcl new file mode 100644 index 0000000..1a83994 --- /dev/null +++ b/build.pkr.hcl @@ -0,0 +1,62 @@ +source "arm-image" "raspberry-pi-os-lite" { + iso_checksum = "sha256:28582f75128e426215e2cda8d6be04c57c0d190d5bf2d4bef62201340d5e60cf" + iso_url = "https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-09-07/2022-09-06-raspios-bullseye-armhf-lite.img.xz" + output_filename = "./build/xraspios-lite.img" +} + +build { + name = "xraspios-lite" + sources = [ + "source.arm-image.raspberry-pi-os-lite" + ] + /* + // https://docs.docker.com/engine/install/binaries/ + // /usr/bin/cp: error writing '/usr/bin/dockerd': No space left on device + // /usr/bin/cp: error writing '/usr/bin/runc': No space left on device + provisioner "shell" { + inline = [ + "apt-get update", + "cd /tmp", + "wget -c https://download.docker.com/linux/static/stable/armhf/docker-20.10.9.tgz -O - | sudo tar -xz", + "sudo cp docker/* /usr/bin/" + ] + } + */ + /* + provisioner "shell" { + inline = [ + "lsblk", + ] + } + + provisioner "shell" { + inline = [ + "apt-get update -y", + "sudo apt-get install ca-certificates curl gnupg lsb-release", + "curl -sSL https://get.docker.com | sh", + "sudo usermod -aG docker pi" + ] + } + + provisioner "shell" { + inline = [ + "lsblk", + ] + } + + provisioner "shell" { + scripts = [ + "./scripts/install.sh", + # "./scripts/docker.sh", + # "./scripts/git.sh", + # "./scripts/tmux.sh", + # "./scripts/vim.sh" + ] + } + */ + + provisioner "ansible" { + playbook_file = "playbook.yml" + } +} + \ No newline at end of file diff --git a/config.pkr.hcl b/config.pkr.hcl new file mode 100644 index 0000000..792d459 --- /dev/null +++ b/config.pkr.hcl @@ -0,0 +1,8 @@ +packer { + required_plugins { + arm-image = { + version = ">= 0.2.6" + source = "github.com/solo-io/arm-image" + } + } +} \ No newline at end of file diff --git a/scripts/docker.sh b/scripts/docker.sh new file mode 100644 index 0000000..b431a27 --- /dev/null +++ b/scripts/docker.sh @@ -0,0 +1,5 @@ +#! /bin/bash +echo "> Installing Docker..." + +curl -sSL https://get.docker.com | sh +usermod -aG docker pi \ No newline at end of file diff --git a/scripts/git.sh b/scripts/git.sh new file mode 100644 index 0000000..7cdc78d --- /dev/null +++ b/scripts/git.sh @@ -0,0 +1,4 @@ +#! /bin/bash +echo "> Installing Git..." + +apt-get install -y git \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..e68b290 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,10 @@ +#! /bin/bash +echo "--- XRASPIOS INSTALATION ---" +echo " " + +echo "> Update APT" +sudo apt-get update && sudo apt-get upgrade -y + +echo "> Installing Utils" + +sudo apt-get install -y wget curl \ No newline at end of file diff --git a/scripts/tmux.sh b/scripts/tmux.sh new file mode 100644 index 0000000..8405034 --- /dev/null +++ b/scripts/tmux.sh @@ -0,0 +1,4 @@ +#! /bin/bash +echo "> Installing Tmux..." + +apt-get install -y tmux \ No newline at end of file diff --git a/scripts/vim.sh b/scripts/vim.sh new file mode 100644 index 0000000..d7b0bab --- /dev/null +++ b/scripts/vim.sh @@ -0,0 +1,4 @@ +#! /bin/bash +echo "> Installing Vim..." + +apt-get install -y vim \ No newline at end of file diff --git a/vars.pkr.hcl b/vars.pkr.hcl new file mode 100644 index 0000000..7112c94 --- /dev/null +++ b/vars.pkr.hcl @@ -0,0 +1,9 @@ +variable "password" { + sensitive = true + default = "#pi@12345" +} + +variable "user" { + type = string + default = "pi" +} \ No newline at end of file