-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a4504a4
Showing
10 changed files
with
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Builds directories | ||
build | ||
.packer.d |
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,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 | ||
<https://github.com/raspberrypi/rpi-imager/blob/ce0b02b823a40ada3cd4a12a257da9506e46dda1/src/OptionsPopup.qml#L589> | ||
|
||
### 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 | ||
|
||
- <https://www.packer.io> | ||
- <https://www.packer.io/docs/builders/community-supported> | ||
- <https://github.com/solo-io/packer-plugin-arm-image> | ||
- <https://github.com/marketplace/actions/packer-github-actions> | ||
- <https://downloads.raspberrypi.org> |
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,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" | ||
} | ||
} | ||
|
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,8 @@ | ||
packer { | ||
required_plugins { | ||
arm-image = { | ||
version = ">= 0.2.6" | ||
source = "github.com/solo-io/arm-image" | ||
} | ||
} | ||
} |
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 @@ | ||
#! /bin/bash | ||
echo "> Installing Docker..." | ||
|
||
curl -sSL https://get.docker.com | sh | ||
usermod -aG docker pi |
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,4 @@ | ||
#! /bin/bash | ||
echo "> Installing Git..." | ||
|
||
apt-get install -y git |
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,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 |
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,4 @@ | ||
#! /bin/bash | ||
echo "> Installing Tmux..." | ||
|
||
apt-get install -y tmux |
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,4 @@ | ||
#! /bin/bash | ||
echo "> Installing Vim..." | ||
|
||
apt-get install -y vim |
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,9 @@ | ||
variable "password" { | ||
sensitive = true | ||
default = "#pi@12345" | ||
} | ||
|
||
variable "user" { | ||
type = string | ||
default = "pi" | ||
} |