Skip to content

OpenBSD 6.5 image builder updates #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This must be run on a OpenBSD machine or VirtualMachine.
The following packages are required:

```
pkg_add bash cdrtools git rsync
pkg_add bash cdrtools git rsync
```

## Usage
Expand All @@ -36,3 +36,7 @@ To build the OpenBSD KVM image run the `create-image` script:
```

see `./create-image -h` for usage

```
doas ./create-iso -r 6.5 -m cloudflare.cdn.openbsd.org -p /pub/OpenBSD -i install65.iso -d $(pwd)/iso -M $(pwd)/iso -l $(pwd)/layout/ -f openbsd65.iso -c SHA256
```
5 changes: 4 additions & 1 deletion auto_install.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
System hostname = openbsd
Password for root = *************
Change the default console to com0 = no
Start sshd(8) by default = yes
Do you expect to run the X Window System = no
Setup a user = no
Allow root ssh login = prohibit-password
What timezone are you in = UTC
Location of sets = cd0
Set name(s) = +bsd.mp +site* -game* done
Set name(s)? = -x*
Set name(s)? = site*
Set name(s)? = done
Continue without verification = yes
3 changes: 1 addition & 2 deletions create-image
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,11 @@ cat << MANIFEST > $BLANK_MANIFEST
"nics": [
{
"interface": "net0",
"nic_tag": "external",
"nic_tag": "$VLAN_ID",
"ip": "$IP",
"primary": "true",
"netmask": "$NETMASK",
"gateway": "$GATEWAY",
"vlan_id": $VLAN_ID,
"model": "virtio",
"network_uuid": "$NETWORK_UUID"
}
Expand Down
2 changes: 1 addition & 1 deletion create-image-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ cat <<EOF
"homepage": "${homepage}",
"published_at": "${now}",
"os": "${os}",
"image_size": "${image_size}",
"image_size": ${image_size},
"files": [
{
"sha1": "${shasum}",
Expand Down
25 changes: 14 additions & 11 deletions create-iso
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ IFS=$'\n\t'

AUTO_INST="auto_install.conf"
RAMDISK=/mnt/ramdisk
RDSETROOT=/usr/local/bin/rdsetroot
TRITON_DIST_FILE="site61.tgz"
RDSETROOT=/usr/sbin/rdsetroot

RELEASE=
MIRROR=
MIRROR_PATH=
MIRROR=cdn.openbsd.org
MIRROR_PATH=/pub/OpenBSD
ISO=
ISO_DIR=
ISO_MOUNT=
ISO_LAYOUT=
ISO_CHECKSUM=
ISO_CHECKSUM=SHA256
ISO_FILENAME=



DEFVER=6.4
DEFOVER=$(echo ${DEFVER} | sed -e 's;\.;;g')
usage() {
cat <<EOF

Expand All @@ -38,10 +37,10 @@ Usage:
$0 -r <RELEASE> -m <MIRROR> -p <MIRROR_PATH> -i <ISO> -c <ISO_CHECKSUM> -d <ISO_DIR> -M <ISO_MOUNT> -l <ISO_LAYOUT> -f <ISO_FILENAME>

Example:
$0 -r 6.1 -m ftp5.usa.openbsd.org -p /pub/OpenBSD -i install61.iso -c SHA256 -d /data/openbsd-6.1-iso -M /mnt/openbsd-6.1-iso -l /data/openbsd-custom-6.1 -f openbsd-6.1-custom.iso
$0 -r ${DEFVER} -m cdn.openbsd.org -p /pub/OpenBSD -i install${DEFOVER}.iso -c SHA256 -d /tmp/openbsd-${DEFOVER}-iso -M /mnt/openbsd-${DEFOVER}-iso -l /tmp/openbsd-custom-${DEFOVER} -f openbsd-${DEFOVER}-joyent.iso

OPTIONS:
-r The desired OpenBSD release (e.g., 6.1)
-r The desired OpenBSD release (e.g., ${DEFVER})
-m The mirror to use when downloading the release ISO. Do not include protocol (e.g., http://). Assumes http mirror
-p The desired mirror path to the ISO (e.g., /pub/OpenBSD)
-i The ISO filename
Expand Down Expand Up @@ -96,6 +95,10 @@ do
esac
done

# do this again here to get the new RELEASE
OVER=$(echo ${RELEASE} | sed -e 's;\.;;g')
TRITON_DIST_FILE="site${OVER}.tgz"

if [[ "$#" -eq 0 ]]; then
usage
exit 1
Expand Down Expand Up @@ -166,7 +169,7 @@ fetch_iso() {

echo "==> Verifying $ISO with ${ISO_CHECKSUM}"

(cd $ISO_DIR && signify -C -p /etc/signify/openbsd-61-base.pub -x ${ISO_CHECKSUM}.sig ${ISO})
(cd $ISO_DIR && signify -C -p /etc/signify/openbsd-${OVER}-base.pub -x ${ISO_CHECKSUM}.sig ${ISO})
if [[ $? != 0 ]]; then
exit 1
fi
Expand All @@ -180,7 +183,7 @@ fetch_iso() {

echo "==> Verifying $ISO with ${ISO_CHECKSUM}"

(cd $ISO_DIR && signify -C -p /etc/signify/openbsd-61-base.pub -x ${ISO_CHECKSUM}.sig ${ISO})
(cd $ISO_DIR && signify -C -p /etc/signify/openbsd-${OVER}-base.pub -x ${ISO_CHECKSUM}.sig ${ISO})
if [[ $? != 0 ]]; then
exit 1
fi
Expand Down
23 changes: 10 additions & 13 deletions triton-openbsd-guesttools/etc/rc.firsttime
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/sh

set -o xtrace
#set -o xtrace

echo "==> Running rc.firsttime..."

echo "===> Enable serial and internal consoles"
echo "stty com0 38400" > /etc/boot.conf
echo "set tty com0" >> /etc/boot.conf
echo "tty00 \"/usr/libexec/getty std.38400\" vt220 on secure" >> /etc/ttys

sed -i 's;^tty00.*$;tty00 "/usr/libexec/getty std.38400" vt220 on secure;' /etc/ttys

echo "===> Linking old libc.so for mdata tools"
ln -sf /usr/lib/libc.so.* /usr/lib/libc.so.89.3

echo "===> Updating installed packages..."
echo "http://ftp3.usa.openbsd.org/pub/OpenBSD" > /etc/installurl
echo "http://cdn.openbsd.org/pub/OpenBSD" > /etc/installurl
pkg_check -I
pkg_add -I -u
pkg_add -I bash

echo "===> Deleting /etc/myname"
rm -rf /etc/myname
Expand All @@ -25,7 +28,7 @@ echo "===> Removing /root/.ssh/authorized_keys"
rm -rf /root/.ssh/authorized_keys

echo "===> Disable tunneled clear text passwords"
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
sed -i 's;^#PasswordAuthentication.*$;PasswordAuthentication no;g' /etc/ssh/sshd_config

echo "===> Cleaning up dhcp leases"
find /var/db -type f -name "dhclient.leases.*" | xargs rm -f
Expand All @@ -35,21 +38,15 @@ rm -rf /etc/hostname.*

## Build date used for motd and product file
BUILDDATE=$(date +%Y%m%d)
RELEASE="6.1"
RELEASE=`uname -r`
DOC_URL="https://docs.joyent.com/images/kvm/openbsd"

# Create MOTD
echo "===> Creating /etc/motd"
mv /etc/motd /etc/motd-backup
cat << MOTD > /etc/motd


__ . .
_| |_ | .-. . . .-. :--. |-
|_ _| ;| || |(.-' | | |
|__| \`--' \`-' \`;-| \`-' ' ' \`-'
/ ; Instance (OpenBSD $RELEASE $BUILDDATE)
\`-' $DOC_URL
Welcome to OpenBSD $RELEASE ($BUILDDATE)

MOTD

Expand Down
5 changes: 0 additions & 5 deletions triton-openbsd-guesttools/etc/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ if [[ ! -e $LOG ]] ; then
touch $LOG
fi

exec 4<> $LOG
export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
export BASH_XTRACEFD=4
set -o xtrace

(/lib/smartdc/set-hostname)
(/lib/smartdc/set-root-authorized-keys)
if [[ ! -f /lib/smartdc/.firstboot-complete-do-not-delete ]] ; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
# This script checks new network interfaces for and enables via DHCP at boot.
Expand Down
8 changes: 4 additions & 4 deletions triton-openbsd-guesttools/lib/smartdc/common.lib
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand All @@ -8,7 +8,7 @@
LOGGER=/usr/bin/logger
MDATA_GET='/usr/sbin/mdata-get'

set -o xtrace
#set -o xtrace

# Common functions used by scripts /lib/smartdc

Expand All @@ -23,5 +23,5 @@ lib_triton_info() {
$LOGGER "(info) - $0 - $@"
}

export -f lib_triton_fatal
export -f lib_triton_info
export lib_triton_fatal
export lib_triton_info
2 changes: 1 addition & 1 deletion triton-openbsd-guesttools/lib/smartdc/firstboot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
# For scripts that should be run on first boot only
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion triton-openbsd-guesttools/lib/smartdc/get-user-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion triton-openbsd-guesttools/lib/smartdc/run-operator-script
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion triton-openbsd-guesttools/lib/smartdc/run-user-script
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion triton-openbsd-guesttools/lib/smartdc/set-hostname
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
# Set the hostname of the VM if it's not already configured by the user.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion triton-openbsd-guesttools/lib/smartdc/set-rootpassword
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/bin/ksh
#
# Copyright (c) 2017 Joyent Inc., All rights reserved.
#
Expand Down