]> git.plutz.net Git - rpi_small/commitdiff
improved rollout of some config files
authorPaul Hänsch <paul@plutz.net>
Sat, 9 Mar 2019 23:35:32 +0000 (00:35 +0100)
committerPaul Hänsch <paul@plutz.net>
Sat, 9 Mar 2019 23:35:32 +0000 (00:35 +0100)
.gitignore
Makefile
config.example

index 8eb036966e4d7676e74a3e17e2e4edea0dbce870..38d45b617e53043d74b8b22a75452bb1b0520277 100644 (file)
@@ -5,7 +5,5 @@ config.mk
 files/etc/inetd.conf
 files/srv/gummikraken/
 files/usr/local/
 files/etc/inetd.conf
 files/srv/gummikraken/
 files/usr/local/
-files/root/.ssh/authorized_keys
-files/etc/network/interfaces.d/wifi
 id_rsa
 id_rsa.pub
 id_rsa
 id_rsa.pub
index 4b7f0bd2c43ecddbb310a599ca2f69cf6132a022..5d4e7f08728faa4288156166ea9f1269a2adea05 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,18 +26,16 @@ endef
 
 PACKAGES := apt bluez bluez-firmware bluez-tools btrfs-tools busybox-static bzip2 ca-certificates cron debian-archive-keyring deborphan firmware-brcm80211 firmware-linux-free firmware-misc-nonfree gzip htop ifupdown init iputils-ping irqbalance isc-dhcp-client less libraspberrypi-bin libraspberrypi0 make net-tools nmap ntpdate openssh-client openssh-server pi-bluetooth psmisc raspberrypi-bootloader raspberrypi-kernel rsync ssh sshfs sudo systemd traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip
 
 
 PACKAGES := apt bluez bluez-firmware bluez-tools btrfs-tools busybox-static bzip2 ca-certificates cron debian-archive-keyring deborphan firmware-brcm80211 firmware-linux-free firmware-misc-nonfree gzip htop ifupdown init iputils-ping irqbalance isc-dhcp-client less libraspberrypi-bin libraspberrypi0 make net-tools nmap ntpdate openssh-client openssh-server pi-bluetooth psmisc raspberrypi-bootloader raspberrypi-kernel rsync ssh sshfs sudo systemd traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip
 
-# Do not change, only override in config.mk
-WIFI-SSID = 
-WIFI-PASS = 
-
 IMGFILE = raspi.img
 
 config.mk: config.example
        cp -n "$<" "$@"
 include config.mk
 
 IMGFILE = raspi.img
 
 config.mk: config.example
        cp -n "$<" "$@"
 include config.mk
 
-.PHONY: imgfile imgmount root_copy norecommends apt_keys
+.PHONY: imgfile imgmount root_copy norecommends apt_keys wifi_cfg ssh_key
+
 export SOURCES
 export SOURCES
+export WIFI_CFG
 
 raspi_root:
        btrfs subvolume create "$@" || mkdir "$@"
 
 raspi_root:
        btrfs subvolume create "$@" || mkdir "$@"
@@ -72,19 +70,6 @@ raspi_root/: raspi_root norecommends apt_keys .FORCE
        chroot "$@" rm /usr/local/sbin/invoke-rc.d
        touch "$@"
 
        chroot "$@" rm /usr/local/sbin/invoke-rc.d
        touch "$@"
 
-id_rsa.pub:
-       ssh-keygen -b 2048 -t rsa -N '' -f id_rsa
-
-files/etc/network/interfaces.d/wifi: wifi.tmpl
-       sed 's;#WIFI-SSID#;${WIFI-SSID};; s;#WIFI-PASS#;${WIFI-PASS};;' <'$<' >'$@'
-       chmod 644 '$@'
-
-files/root/.ssh/authorized_keys: id_rsa.pub
-       mkdir -p files/root/.ssh/
-       cat '$<' >>'$@'
-       chmod 700 files/root/ files/root/.ssh/
-       chmod 600 '$@'
-
 imgfile: raspi_root/  # do not set up image file before chroot
 imgfile: partitions
        dd bs=1M count=0 seek=1280 of="${IMGFILE}"  # set up sparse file
 imgfile: raspi_root/  # do not set up image file before chroot
 imgfile: partitions
        dd bs=1M count=0 seek=1280 of="${IMGFILE}"  # set up sparse file
@@ -105,11 +90,24 @@ imgmount: imgfile
        losetup -o $$((start * 512)) --sizelimit $$((size * 512)) "$${lo}" "$$image" && \
        mkfs.fat -F 32 -n boot "$$lo" && mount -t vfat "$$lo" "$@/boot";
 
        losetup -o $$((start * 512)) --sizelimit $$((size * 512)) "$${lo}" "$$image" && \
        mkfs.fat -F 32 -n boot "$$lo" && mount -t vfat "$$lo" "$@/boot";
 
-root_copy: files/root/.ssh/authorized_keys files/etc/network/interfaces.d/wifi
 root_copy: imgmount raspi_root/ files/
        cp -a "raspi_root/." "files/." "$</"
 
 root_copy: imgmount raspi_root/ files/
        cp -a "raspi_root/." "files/." "$</"
 
-${IMGFILE}: imgmount root_copy
+id_rsa.pub:
+       ssh-keygen -b 2048 -t rsa -N '' -f id_rsa
+
+ssh_key: imgmount id_rsa.pub
+       mkdir -p "$</root/.ssh/"
+       cat id_rsa.pub >>"$</root/.ssh/authorized_keys"
+       chmod 700 "$</root" "$</root/.ssh"
+       chmod 600 "$</root/.ssh/authorized_keys"
+
+wifi_cfg: imgmount
+       printf '%s\n' "$$WIFI_CFG" >"$</etc/network/interfaces.d/wifi"
+       chmod 644 "$</etc/network/interfaces.d/wifi"
+       chroot "$<" systemctl disable systemd-networkd-wait-online.service
+
+${IMGFILE}: imgmount root_copy wifi_cfg ssh_key
        umount "$</boot/" "$</"
        losetup -a |sed -En '/${IMGFILE}/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d
        losetup -a |sed -En '/${IMGFILE}/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d
        umount "$</boot/" "$</"
        losetup -a |sed -En '/${IMGFILE}/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d
        losetup -a |sed -En '/${IMGFILE}/{s;^([^:]+):.*$$;\1;p;q}' |xargs losetup -d
index 9bf5035fe27adf019b09977126ebbd0505de760b..fe7c4edda158278e59db03828a65d3639c0c96b1 100644 (file)
@@ -5,14 +5,21 @@
 # deb     http://archive.raspberrypi.org/debian stretch main
 # endef
 
 # deb     http://archive.raspberrypi.org/debian stretch main
 # endef
 
+# define WIFI_CFG =
+# auto wlan0
+# allow-hotplug wlan0
+# 
+# iface wlan0 inet dhcp
+#         wpa-ssid        "SSID"
+#         wpa-psk         "PASS"
+# endef
+
 # BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian
 # PACKAGES := ${PACKAGES} foo bar ... additional packages
 
 # include xfce.mk
 # include ws5inch.mk
 # BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian
 # PACKAGES := ${PACKAGES} foo bar ... additional packages
 
 # include xfce.mk
 # include ws5inch.mk
-
-# WIFI-SSID = 
-# WIFI-PASS =
+# include gyro.mk
 
 # PHONY: rootpass
 # ${IMGFILE}: rootpass
 
 # PHONY: rootpass
 # ${IMGFILE}: rootpass