autoinst

scripts to make installation of custom debian easier and more automated
git clone git://deadbeef.fr/autoinst.git
Log | Files | Refs | README | LICENSE

commit 5326df3acb03296d3e8e3b6d6e589c4a83bc5821
parent 6946356c87eaa56e4a61ad84fc6dd9efd73aa4c6
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date:   Sun, 13 Dec 2020 02:09:43 +0100

generic/config: fix cp/paste error + setup name

* fix bb-udhcpc being symlinked for non-dhcp services
* now requires GNU `ip` command for the -br option, makes code cleaner
* use a "machine_list" file containing lines as: MAC\tname to allow
  generating /etc/hostane and patching (or creating) /etc/hosts

Diffstat:
Mtemplates/generic/config | 23+++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/templates/generic/config b/templates/generic/config @@ -1,10 +1,25 @@ +# enable lo and load fr keyboard by /etc/runit/2 sed -i /"$cp_target"/etc/runit/2 \ -e '/^exec env/ iip link set lo up\nloadkeys fr\n' -FIRST_LINK="$(echo $(ip link | awk -F: '/^[0-9]*:/{if($2!=" lo"){print $2;exit}}'))" +FIRST_NIC="$(ip -brief link | awk '$1 !~ /^lo/{printf "%s\t%s\n", $1, $3; exit}')" +# enable basic services: udev, dhcp on 1st nic, klogd, ssh and syslogd (which will probably be removed someday) ln -s /etc/sv/udev /"$cp_target"/etc/service/ -ln -s /etc/sv/bb-udhcpc /"$cp_target"/etc/service/$FIRST_LINK +ln -s /etc/sv/klogd /"$cp_target"/etc/service/klogd +ln -s /etc/sv/ssh /"$cp_target"/etc/service/ssh +ln -s /etc/sv/bb-udhcpc /"$cp_target"/etc/service/$(echo $FIRST_NIC | cut -f1) ln -s /etc/sv/bb-syslogd /"$cp_target"/etc/service/syslogd -ln -s /etc/sv/bb-syslogd /"$cp_target"/etc/service/klogd -ln -s /etc/sv/bb-syslogd /"$cp_target"/etc/service/ssh + +# identify the machine's name by it's 1st MAC +if test -f machine_list +then + HOSTNAME=$(grep machine_list -e $(echo $FIRST_NIC | cut -f2)) + echo $HOSTNAME > /"$cp_target"/etc/hostname + if test -f /"$cp_target"/etc/hosts + then + sed -i /"$cp_target"/etc/hosts -e "s/localhost/& $HOSTNAME/" + else + printf "127.0.0.1 localhost $HOSTNAME\n::1 localhost $HOSTNAME\n" > /etc/hosts + fi +fi