-
Notifications
You must be signed in to change notification settings - Fork 164
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
[WIP] Post inventory to server after install #2396
base: master
Are you sure you want to change the base?
Changes from all commits
2238133
492458e
da210d9
db8fc50
7329705
7dcf802
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,7 +168,56 @@ zfs_umount() { | |
umount /root/dev ||: | ||
} | ||
|
||
# XXX post_inventory needs to run in background - do inside client.go? | ||
# XXX change to /persist/inventory | ||
post_inventory() { | ||
if [ ! -d /config/inventory ]; then | ||
return | ||
fi | ||
cd /config/inventory || exit | ||
inventory_server=$(cat ./server) | ||
files=$(find . -type f -print | grep -v ^./server) | ||
for f in $files; do | ||
logmsg "device-steps: posting $f to $inventory_server" | ||
curl -X POST "$inventory_server/$f" -H "Content-Type: text/plain" -d "@$f" || return | ||
done | ||
logmsg "device-steps: done posting $inventory_server" | ||
cd || exit | ||
rm -rf /config/inventory | ||
} | ||
|
||
logmsg "EVE-OS installation started" | ||
|
||
# XXX remove | ||
ip link show | ||
|
||
# Kick off network configuration on eth0 so we can run ntpd and later post | ||
# inventory | ||
mkdir -p /var/run/ | ||
mkdir -p /etc/network/if-up.d/ | ||
mkdir -p /etc/network/if-pre-up.d/ | ||
mkdir -p /etc/network/interfaces.d/ | ||
cat <<EOF >/etc/network/interfaces | ||
auto eth0 | ||
iface eth0 inet dhcp | ||
EOF | ||
mkdir -p /etc/conf.d/ | ||
cat <<EOF >/etc/conf.d/ntpd | ||
NTPD_OPTS="-s" | ||
EOF | ||
ifup -av | ||
# XXX remove | ||
ls -l /etc/network/interfaces* | ||
ifconfig | ||
ip route show | ||
|
||
# XXX This is bogus since not from udhcp | ||
# https://www.unix.com/man-page/suse/8/udhcpc/ - ntpsrv | ||
ls -l /usr/share/udhcpc/default.script | ||
ping -c 1 pool.ntp.org | ||
# Wait until synchronized and force the clock to be set from ntp | ||
/usr/sbin/ntpd -q -n -g -p pool.ntp.org | ||
|
||
# do this just in case | ||
modprobe usbhid && modprobe usbkbd | ||
# clean partition tables on disks defined to nuke | ||
|
@@ -511,6 +560,27 @@ if [ -f $DEVICE_CERT_NAME ] && [ -n "$REPORT" ]; then | |
cat $DEVICE_CERT_NAME > "$REPORT/device.cert.pem" | ||
fi | ||
|
||
# If we have an inventory server then save report so we can push on first | ||
# boot | ||
INVENTORY_SERVER=$(tr ' ' '\012' < /proc/cmdline | sed -n '/eve_inventory_server=/s#eve_inventory_server=##p') | ||
if [ -n "$INVENTORY_SERVER" ]; then | ||
mkdir /config/inventory | ||
echo "$INVENTORY_SERVER" >/config/inventory/server | ||
cp -rp "$REPORT" /config/inventory/ | ||
# XXX | ||
ls -lR /config/inventory | ||
# Try once and if this fails EVE-OS will try again on boot | ||
ping -c 1 192.168.1.2 | ||
ping -c 1 192.168.1.55 | ||
post_inventory | ||
# XXX sleep and try again? | ||
ping -c 1 192.168.1.2 | ||
ping -c 1 192.168.1.254 | ||
ip route show | ||
sleep 5 | ||
post_inventory | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really don't like this to go into /config since we're still trying to make config as small (and immutable) as possible. Why can't we put this into /persist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'd love to change that, but the issues are that when the installer is running we do not have a /persist (that is created by storage-init on first boot), nor do we have a networking configured in the Linux kernel. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While strictly speaking true, as we've discussed this shouldn't be too big of a deal to change that if needed. However, I'd agree -- for the proptotype/WIP it doesn't matter where it is. |
||
|
||
# finally check whether we are collecting a black box | ||
if [ -n "$REPORT" ]; then | ||
# then we can collect our black box | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not mount tmpfs to /persist, we prepare and mount persist partition/pool to /persist during installation.