mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
this is a very early script to support cloudinit, it does not intend to be a full featured cloudinit client, but will support a good enough subset to be viable in most case. It support nocloud and openstack config-2 config drive mode (iso9660 or msdosfs) The following features are currently supported: - adding users (including a default user named 'freebsd' with password 'freebsd' - adding groups - adding ssh keys - static ipv4, static ipv6, dynamic ipv4 With this one is able to use the 'bring your own image feature" out of box. It is expected that the script grows the support of other clouds supporting cloud-init, contributions are welcomed. It is designed to be only run once via the firstboot mecanism. Sponsored by: OVHCloud Differential Revision: https://reviews.freebsd.org/D44141 (cherry picked from commit a42d6f76018e4ed8324e319ab48aac904bda437c) (cherry picked from commit c051f22bce42d920abba61bd7cf4ef5b6a270ffa) (cherry picked from commit b8c053c9a612651d4909f7a323088f3e92485b7b) (cherry picked from commit 9eae9233fdcc946945f4191e1413f548adfa2943)
52 lines
1.8 KiB
Bash
52 lines
1.8 KiB
Bash
atf_test_case sethostname
|
|
atf_test_case addsshkey
|
|
atf_test_case adduser
|
|
atf_test_case addgroup
|
|
|
|
sethostname_body() {
|
|
export NUAGE_FAKE_ROOTDIR="$(pwd)"
|
|
atf_check /usr/libexec/flua $(atf_get_srcdir)/sethostname.lua
|
|
if [ ! -f etc/rc.conf.d/hostname ]; then
|
|
atf_fail "hostname not written"
|
|
fi
|
|
atf_check -o inline:"hostname=\"myhostname\"\n" cat etc/rc.conf.d/hostname
|
|
}
|
|
|
|
addsshkey_body() {
|
|
atf_check /usr/libexec/flua $(atf_get_srcdir)/addsshkey.lua
|
|
if [ ! -f .ssh/authorized_keys ]; then
|
|
atf_fail "ssh key not added"
|
|
fi
|
|
atf_check -o inline:"mykey\n" cat .ssh/authorized_keys
|
|
atf_check /usr/libexec/flua $(atf_get_srcdir)/addsshkey.lua
|
|
atf_check -o inline:"mykey\nmykey\n" cat .ssh/authorized_keys
|
|
}
|
|
|
|
adduser_body() {
|
|
export NUAGE_FAKE_ROOTDIR="$(pwd)"
|
|
if [ $(id -u) -ne 0 ]; then
|
|
atf_skip "root required"
|
|
fi
|
|
mkdir etc
|
|
printf "root:*:0:0::0:0:Charlie &:/root:/bin/csh\n" > etc/master.passwd
|
|
pwd_mkdb -d etc etc/master.passwd
|
|
printf "wheel:*:0:root\n" > etc/group
|
|
atf_check -e inline:"Argument should be a table\nArgument should be a table\n" /usr/libexec/flua $(atf_get_srcdir)/adduser.lua
|
|
test -d home/impossible_username || atf_fail "home not created"
|
|
atf_check -o inline:"impossible_username::1001:1001::0:0:impossible_username User:/home/impossible_username:/bin/sh\n" grep impossible_username etc/master.passwd
|
|
}
|
|
|
|
addgroup_body() {
|
|
export NUAGE_FAKE_ROOTDIR="$(pwd)"
|
|
mkdir etc
|
|
printf "wheel:*:0:root\n" > etc/group
|
|
atf_check -e inline:"Argument should be a table\nArgument should be a table\n" /usr/libexec/flua $(atf_get_srcdir)/addgroup.lua
|
|
atf_check -o inline:"impossible_groupname:*:1001:\n" grep impossible_groupname etc/group
|
|
}
|
|
|
|
atf_init_test_cases() {
|
|
atf_add_test_case sethostname
|
|
atf_add_test_case addsshkey
|
|
atf_add_test_case adduser
|
|
atf_add_test_case addgroup
|
|
}
|