mirror of
https://github.com/0x1d/terraform-docker-packer.git
synced 2025-12-15 06:12:25 +01:00
provision image through Terraform
This commit is contained in:
7
examples/raspios/rootfs/lib/firstboot.sh
Executable file
7
examples/raspios/rootfs/lib/firstboot.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Generate a unique hostname
|
||||
NEW_HOSTNAME="rpi-$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2 | tail -c 5)"
|
||||
echo "$NEW_HOSTNAME" > /etc/hostname
|
||||
sed -i "s/raspberrypi/$NEW_HOSTNAME/g" /etc/hosts
|
||||
hostname "$NEW_HOSTNAME"
|
||||
14
examples/raspios/rootfs/lib/systemd/system/firstboot.service
Normal file
14
examples/raspios/rootfs/lib/systemd/system/firstboot.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=FirstBoot
|
||||
After=network.target apt-daily.service apt-daily-upgrade.service
|
||||
Before=rc-local.service
|
||||
ConditionFileNotEmpty=/lib/firstboot.sh
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash /lib/firstboot.sh
|
||||
ExecStartPost=/bin/mv /lib/firstboot.sh /lib/firstboot.sh.done
|
||||
Type=oneshot
|
||||
RemainAfterExit=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user