#!/bin/sh
mkdir -p /usr/local/etc/pkg/repos
mkdir -p /usr/local/etc/ssl/certs
cat > /usr/local/etc/pkg/repos/freebsd.conf <<-EOF
FreeBSD: {
    enabled: no
}
EOF
cat > /usr/local/etc/pkg/repos/poudriere.conf <<-EOF
poudriere: {
    url: "https://poudriere.digiworks.se/packages/freebsd_13_0x64-HEAD",
    mirror_type: "https",
    signature_type: "pubkey",
    pubkey: "/usr/local/etc/ssl/certs/poudriere.cert",
    enabled: yes,
}
EOF
cat > /usr/local/etc/ssl/certs/poudriere.cert <<-EOF
-----BEGIN PUBLIC KEY-----
[payload removed: 736 characters in 12 lines]
-----END PUBLIC KEY-----
EOF
env ASSUME_ALWAYS_YES=YES pkg bootstrap
env ASSUME_ALWAYS_YES=YES pkg install ca_root_nss
env ASSUME_ALWAYS_YES=YES pkg upgrade
env ASSUME_ALWAYS_YES=YES pkg install puppet7
cat > /usr/local/etc/puppet/puppet.conf <<-EOF
[main]
vardir = /var/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = /var/puppet/ssl

[agent]
pluginsync      = true
report          = true
ignoreschedules = true
ca_server       = foreman.server.pink
environment     = production
server          = foreman.server.pink 
EOF
service pf onestart
puppet agent -t
