| 1 |
# Mgmt |
| 2 |
# Copyright (C) 2013-2024+ James Shubin and the project contributors |
| 3 |
# Written by James Shubin <[email protected]> and the project contributors |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 |
# |
| 18 |
# Additional permission under GNU GPL version 3 section 7 |
| 19 |
# |
| 20 |
# If you modify this program, or any covered work, by linking or combining it |
| 21 |
# with embedded mcl code and modules (and that the embedded mcl code and |
| 22 |
# modules which link with this program, contain a copy of their source code in |
| 23 |
# the authoritative form) containing parts covered by the terms of any other |
| 24 |
# license, the licensors of this program grant you additional permission to |
| 25 |
# convey the resulting work. Furthermore, the licensors of this program grant |
| 26 |
# the original author, James Shubin, additional permission to update this |
| 27 |
# additional permission if he deems it necessary to achieve the goals of this |
| 28 |
# additional permission. |
| 29 |
|
| 30 |
# sudo setcap CAP_NET_BIND_SERVICE=+eip mgmt |
| 31 |
# ./mgmt provisioner --mac 01:23:45:67:89:ab |
| 32 |
|
| 33 |
import "fmt" |
| 34 |
import "os" |
| 35 |
import "golang/strings" |
| 36 |
import "embedded/provisioner" # embedded import |
| 37 |
|
| 38 |
# TODO: get all of the values first from the cli config file, and then a webui |
| 39 |
include provisioner.base(struct{ |
| 40 |
interface => provisioner.cli_interface(), |
| 41 |
network => provisioner.cli_network(), |
| 42 |
router => provisioner.cli_router(), |
| 43 |
dns => provisioner.cli_dns(), |
| 44 |
|
| 45 |
prefix => provisioner.cli_prefix(), |
| 46 |
firewalld => provisioner.cli_firewalld(), |
| 47 |
}) as base |
| 48 |
|
| 49 |
include base.repo(struct{ |
| 50 |
distro => provisioner.cli_distro(), |
| 51 |
version => provisioner.cli_version(), # not an int! |
| 52 |
arch => provisioner.cli_arch(), |
| 53 |
flavour => provisioner.cli_flavour(), |
| 54 |
|
| 55 |
# pick one from: https://admin.fedoraproject.org/mirrormanager/ |
| 56 |
mirror => provisioner.cli_mirror(), # eg: https://mirror.csclub.uwaterloo.ca/fedora/linux/ |
| 57 |
rsync => provisioner.cli_rsync(), # eg: rsync://mirror.csclub.uwaterloo.ca/fedora-enchilada/linux/ |
| 58 |
}) #as repo |
| 59 |
$distro = provisioner.cli_distro() |
| 60 |
$version = provisioner.cli_version() |
| 61 |
$arch = provisioner.cli_arch() |
| 62 |
$uid = "${distro}${version}-${arch}" # eg: fedora39-x86_64 |
| 63 |
include base.host("host0", struct{ # TODO: do we need a usable name anywhere? |
| 64 |
#repo => $repo.uid, # type unification performance is very slow here |
| 65 |
repo => $uid, |
| 66 |
flavour => provisioner.cli_flavour(), |
| 67 |
mac => provisioner.cli_mac(), |
| 68 |
ip => provisioner.cli_ip(), |
| 69 |
bios => provisioner.cli_bios(), # false or absent means use uefi |
| 70 |
password => provisioner.cli_password(), # openssl passwd -6 |
| 71 |
part => provisioner.cli_part(), |
| 72 |
packages => provisioner.cli_packages(), |
| 73 |
#provision => true, # default if unspecified |
| 74 |
}) as host0 |
| 75 |
|
| 76 |
#if $host0.provisioned { |
| 77 |
# print "provisioned" { |
| 78 |
# msg => fmt.printf("%s is provisioned!", $host0.name), |
| 79 |
# } |
| 80 |
#} |