Initial overlay for domotica machines
authorKristof Provost <kp@FreeBSD.org>
Wed, 3 May 2023 20:01:15 +0000 (22:01 +0200)
committerKristof Provost <kp@FreeBSD.org>
Wed, 3 May 2023 20:01:15 +0000 (22:01 +0200)
* Console over serial port
* set up 'kp' user & sudo
* crontab presence announcement to sigsegv.be with mac address
* ssh-able as kp

image/overlay/domotica/boot/loader.conf [new file with mode: 0644]
image/overlay/domotica/etc/rc.conf [new file with mode: 0644]
image/overlay/domotica/etc/rc.d/ansibleprep [new file with mode: 0755]
image/overlay/domotica/firstboot [new file with mode: 0644]
image/overlay/domotica/home/kp/.ssh/authorized_keys [new file with mode: 0644]
image/overlay/domotica/home/kp/.zshrc [new file with mode: 0644]
image/overlay/domotica/home/kp/bin/announce_presence [new file with mode: 0755]
image/overlay/domotica/home/kp/bin/utils.subr [new file with mode: 0644]
image/overlay/domotica/usr/local/etc/sudoers [new file with mode: 0644]
image/overlay/domotica/var/cron/tabs/kp [new file with mode: 0644]

diff --git a/image/overlay/domotica/boot/loader.conf b/image/overlay/domotica/boot/loader.conf
new file mode 100644 (file)
index 0000000..7035712
--- /dev/null
@@ -0,0 +1,4 @@
+console="comconsole,vidconsole"
+comconsole_speed="115200"
+boot_multicons="YES"
+boot_serial="YES"
diff --git a/image/overlay/domotica/etc/rc.conf b/image/overlay/domotica/etc/rc.conf
new file mode 100644 (file)
index 0000000..8fa2a5f
--- /dev/null
@@ -0,0 +1,9 @@
+ansibleprep_enable="YES"
+
+sshd_enable="YES"
+sendmail_enable="NONE"
+ntpdate_enable="YES"
+ntpd_enable="YES"
+
+ifconfig_em0="DHCP"
+ifconfig_igb0="DHCP"
diff --git a/image/overlay/domotica/etc/rc.d/ansibleprep b/image/overlay/domotica/etc/rc.d/ansibleprep
new file mode 100755 (executable)
index 0000000..9d2632b
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+
+# PROVIDE: ansibleprep
+# REQUIRE: DAEMON
+# BEFORE: LOGIN
+# KEYWORD: firstboot
+
+. /etc/rc.subr
+
+name="ansibleprep"
+start_cmd="ansibleprep_start"
+
+ansibleprep_start()
+{
+       # Just enough so kp can log in
+       pw user add kp
+       pw user mod kp -s /usr/local/bin/zsh
+       chown -R kp /home/kp
+       chmod 700 /home/kp/.ssh
+
+       # And sudo should work for ansible
+       chown root:wheel /usr/local/etc/sudoers
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/image/overlay/domotica/firstboot b/image/overlay/domotica/firstboot
new file mode 100644 (file)
index 0000000..792d600
--- /dev/null
@@ -0,0 +1 @@
+#
diff --git a/image/overlay/domotica/home/kp/.ssh/authorized_keys b/image/overlay/domotica/home/kp/.ssh/authorized_keys
new file mode 100644 (file)
index 0000000..62f8adc
--- /dev/null
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCPmLVO+sYPkQm36cUDpWcYNC4l7t56YQIEFxGXIUBAgvnzhyYxKpQhpLea0BdnQXzDcqrEGjbIezgBQc3X2qVT3i53lvngtlGMheOMT0LrRXmHj1xUfdSzCgvu+STW+btJ0gq9A5iFI47HsZBExiE9pFBMoBC6uiicS9R5NvtE+Axl5cykX36Sq1vneDKu/dFZvmaiCGxXl77ed7aoLUZQpU+6r1r2IN2Yx6b9jK5m9aUk4HS9+IG3xUAjfK2PPLmxYafiKrbzMD9AhsFqGdnASK5jmspJ47wx3NFpAdnOFijQVQdYMgTEeOqO3tNSyF7Y9IA/kgkzpzPZCcqZH+PCpHSN2LZMRrUxDPdPVPIxboRAY0Q1uZ8iBDXILyhvpJr1DP0zomRE65/4VpIeuVqsyOLD3WdG1lHcK+bzpTT1JTQWNaxe3MwvAc67BItoflutuWZFlytvqr7zyJirCyUJuD0L0j/CTC5O635QQT3sDjQLXLn/T6SsbsRdt4eA2pKX8T95dLS8onPLa7GwUXwEupp5+aUi1G8PchImOv27tcG5yuRcbECosoL/OedX2y0dAP4Eafg9cJMR++h8p4NuhjeYQYxhnpVVhCidRPCSZ7Exj/UpNo/quLvCdFu3nLuAPzfk8NclO5V7jd7WMYiJm0XgKHIWKkD8cfmLWbcrw== GPG SSH key (Yubikey new horizons) (F6532E2ECB7D6E930A8A5B1AA76D86379FFA151A)
diff --git a/image/overlay/domotica/home/kp/.zshrc b/image/overlay/domotica/home/kp/.zshrc
new file mode 100644 (file)
index 0000000..792d600
--- /dev/null
@@ -0,0 +1 @@
+#
diff --git a/image/overlay/domotica/home/kp/bin/announce_presence b/image/overlay/domotica/home/kp/bin/announce_presence
new file mode 100755 (executable)
index 0000000..6fd2e9a
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+. /home/kp/bin/utils.subr
+
+timeout 5 fetch https://www.sigsegv.be/domotica/pennestraat/$(host_id)
diff --git a/image/overlay/domotica/home/kp/bin/utils.subr b/image/overlay/domotica/home/kp/bin/utils.subr
new file mode 100644 (file)
index 0000000..a3d9811
--- /dev/null
@@ -0,0 +1,11 @@
+mac()
+{
+        intf=$1
+
+        ifconfig ${intf} | awk '/ether/ { printf($2); }'
+}
+
+host_id()
+{
+        mac "em0"
+}
diff --git a/image/overlay/domotica/usr/local/etc/sudoers b/image/overlay/domotica/usr/local/etc/sudoers
new file mode 100644 (file)
index 0000000..e2d46a6
--- /dev/null
@@ -0,0 +1,110 @@
+## sudoers file.
+##
+## This file MUST be edited with the 'visudo' command as root.
+## Failure to use 'visudo' may result in syntax or file permission errors
+## that prevent sudo from running.
+##
+## See the sudoers man page for the details on how to write a sudoers file.
+##
+
+##
+## Host alias specification
+##
+## Groups of machines. These may include host names (optionally with wildcards),
+## IP addresses, network numbers or netgroups.
+# Host_Alias   WEBSERVERS = www1, www2, www3
+
+##
+## User alias specification
+##
+## Groups of users.  These may consist of user names, uids, Unix groups,
+## or netgroups.
+# User_Alias   ADMINS = millert, dowdy, mikef
+
+##
+## Cmnd alias specification
+##
+## Groups of commands.  Often used to group related commands together.
+# Cmnd_Alias   PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
+#                          /usr/bin/pkill, /usr/bin/top
+# Cmnd_Alias   REBOOT = /sbin/halt, /sbin/reboot, /sbin/poweroff
+
+##
+## Defaults specification
+##
+## Uncomment if needed to preserve environmental variables related to the
+## FreeBSD pkg utility and fetch.
+# Defaults     env_keep += "PKG_CACHEDIR PKG_DBDIR FTP_PASSIVE_MODE"
+##
+## Additionally uncomment if needed to preserve environmental variables
+## related to portupgrade
+# Defaults     env_keep += "PORTSDIR PORTS_INDEX PORTS_DBDIR PACKAGES PKGTOOLS_CONF"
+##
+## You may wish to keep some of the following environment variables
+## when running commands via sudo.
+##
+## Locale settings
+# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET"
+##
+## Run X applications through sudo; HOME is used to find the
+## .Xauthority file.  Note that other programs use HOME to find   
+## configuration files and this may lead to privilege escalation!
+# Defaults env_keep += "HOME"
+##
+## X11 resource path settings
+# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH"
+##
+## Desktop path settings
+# Defaults env_keep += "QTDIR KDEDIR"
+##
+## Allow sudo-run commands to inherit the callers' ConsoleKit session
+# Defaults env_keep += "XDG_SESSION_COOKIE"
+##
+## Uncomment to enable special input methods.  Care should be taken as
+## this may allow users to subvert the command being run via sudo.
+# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER"
+##
+## Uncomment to use a hard-coded PATH instead of the user's to find commands
+# Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+##
+## Uncomment to send mail if the user does not enter the correct password.
+# Defaults mail_badpass
+##
+## Uncomment to enable logging of a command's output, except for
+## sudoreplay and reboot.  Use sudoreplay to play back logged sessions.
+# Defaults log_output
+# Defaults!/usr/bin/sudoreplay !log_output
+# Defaults!/usr/local/bin/sudoreplay !log_output
+# Defaults!REBOOT !log_output
+
+##
+## Runas alias specification
+##
+
+##
+## User privilege specification
+##
+root ALL=(ALL) ALL
+
+## Uncomment to allow members of group wheel to execute any command
+# %wheel ALL=(ALL) ALL
+
+## Same thing without a password
+# %wheel ALL=(ALL) NOPASSWD: ALL
+kp ALL=(ALL) NOPASSWD: ALL
+Defaults     env_keep += "SSH_AUTH_SOCK"
+
+## Uncomment to allow members of group sudo to execute any command
+# %sudo        ALL=(ALL) ALL
+
+## Uncomment to allow any user to run sudo if they know the password
+## of the user they are running the command as (root by default).
+# Defaults targetpw  # Ask for the password of the target user
+# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'
+
+## Uncomment to show on password prompt which users' password is being expected
+# Defaults passprompt="%p's password:"
+
+## Read drop-in files from /usr/local/etc/sudoers.d
+## (the '#' here does not indicate a comment)
+#includedir /usr/local/etc/sudoers.d
diff --git a/image/overlay/domotica/var/cron/tabs/kp b/image/overlay/domotica/var/cron/tabs/kp
new file mode 100644 (file)
index 0000000..859c03b
--- /dev/null
@@ -0,0 +1 @@
+1 * * * * /home/kp/bin/announce_presence