Commit 025a9bea authored by Leo Le Bouter's avatar Leo Le Bouter

Add metadata-collect dracut module

To install the dracut module on your current system, change into
the dracut.module directory then run:

```
$ ERP5_USER="user" ERP5_PASS="pass" \
  ERP5_BASE_URL="https://example.local/erp5" \
  make
$ sudo make install
```

To uninstall:

```
$ sudo make uninstall
```

Then in a dracut.conf file, to include it you can add:

```
add_dracutmodules="metadata-collect"
```

You will also need to append "ip=dhcp rd.neednet=1" to the
kernel_cmdline directive inside the dracut.conf so that the
initramfs requests networking for the agent to upload results.

Make sure the dracut network modules are installed, on Debian
that is the dracut-network package.
You can otherwise check their presence using:

```
$ dracut --list-modules | grep network
```

There you should see a few modules.
parent 4d94b540
#!/bin/bash
check() {
require_binaries grep head ip || return 1
return 255
}
depends() {
echo network
}
install() {
inst_multiple head ip grep
inst "$moddir"/metadata-collect-agent "/sbin/metadata-collect-agent"
inst_hook pre-pivot 10 "$moddir"/collect.sh
}
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
include collect-sh-template.mk
90metadata-collect/collect.sh: guard-ERP5_USER guard-ERP5_PASS guard-ERP5_BASE_URL
echo "$${collect_sh}" >> 90metadata-collect/collect.sh
90metadata-collect/metadata-collect-agent:
cd ../ && ./rust-build-static.bash
.PHONY: clean
clean:
rm -fv 90metadata-collect/collect.sh 90metadata-collect/metadata-collect-agent
.PHONY: install
install: 90metadata-collect/metadata-collect-agent 90metadata-collect/collect.sh
cp -vLr "90metadata-collect" /usr/lib/dracut/modules.d
.PHONY: uninstall
uninstall:
rm -rfv /usr/lib/dracut/modules.d/90metadata-collect
define collect_sh :=
#!/bin/bash
. /lib/dracut-lib.sh
DEFAULT_IF="$$(ip route show default | grep -Po "(?<=dev )\w+" | head -n 1)"
DEFAULT_IF_MAC="$$(ip link show "$$DEFAULT_IF" | grep -Po '(?<= )\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}(?= )' | head -n 1)"
ERP5_BASE_URL="$(ERP5_BASE_URL)"
ERP5_USER="$(ERP5_USER)"
ERP5_PASS="$(ERP5_PASS)"
REFERENCE="COMP-MAC-$$(echo "$$DEFAULT_IF_MAC" | sed s/:/-/g).Metadata.Snapshot"
/sbin/metadata-collect-agent "$$NEWROOT" "$$ERP5_USER" "$$ERP5_PASS" "$$REFERENCE" "$$ERP5_BASE_URL"
endef
export collect_sh
\ No newline at end of file
......@@ -17,12 +17,16 @@ cd "acl-${ACLVERSION}"
[ -f ./configure ] || ./autogen.sh
[ -f ./config.status ] || ./configure --host "${HOST_TARGET}"
make -j$(nproc)
make -j"$(nproc)"
cd -
RUSTFLAGS="-L native=$(pwd)/acl-${ACLVERSION}/.libs -l static=acl" PKG_CONFIG_ALLOW_CROSS=1 \
cargo build --target "$HOST_TARGET" --release
strip --strip-all "target/$HOST_TARGET/release/$(basename $(pwd))"
objdump -T "target/$HOST_TARGET/release/$(basename $(pwd))"
BINARY="$(pwd)/target/$HOST_TARGET/release/$(basename "$(pwd)")"
strip --strip-all "$BINARY"
objdump -T "$BINARY" || true
ln -s "$BINARY" dracut.module/90metadata-collect/metadata-collect-agent
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment