Skip to content

Commit

Permalink
Makefiles and installers corrected in order to automatically transfor…
Browse files Browse the repository at this point in the history
…m the machine-id to a valid UUID prior to save it in the plugins' configuration files (#126)

Signed-off-by: Davide Di Donato <davidedidonato94@gmail.com>
  • Loading branch information
Davide-DD authored and gabrik committed Jul 15, 2019
1 parent fa6eb3f commit 652a2ca
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ These are the contributors to fog05 according to the Github repository.
=============== ==================================
gabrik Gabriele Baldoni (ADLINK)
josrolgil José María Roldán Gil

Davide-DD Davide Di Donato
=============== ==================================

2 changes: 2 additions & 0 deletions fos-plugins/LXD/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*-Makefile-*-

WD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))));
UUID = $(shell ./to_uuid.sh)

ETC_FOS_DIR = /etc/fos/
VAR_FOS_DIR = /var/fos/
Expand All @@ -25,6 +26,7 @@ else
sudo ln -sf /etc/fos/plugins/LXD/LXD_plugin /usr/bin/fos_lxd
endif
sudo cp /etc/fos/plugins/LXD/fos_lxd.service /lib/systemd/system/
sudo sh -c "echo $(UUID) | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/LXD/LXD_plugin.json > /tmp/LXD_plugin.tmp && mv /tmp/LXD_plugin.tmp /etc/fos/plugins/LXD/LXD_plugin.json"


uninstall:
Expand Down
9 changes: 9 additions & 0 deletions fos-plugins/LXD/to_uuid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

id=$(cat /etc/machine-id)
first=$(echo $id | cut -c -8)
second=$(echo $id | cut -c 9-12)
third=$(echo $id | cut -c 13-16)
fourth=$(echo $id | cut -c 17-20)
fifth=$(echo $id | cut -c 21-)
echo $first-$second-$third-$fourth-$fifth
2 changes: 2 additions & 0 deletions fos-plugins/linuxbridge/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*-Makefile-*-

WD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))));
UUID = $(shell ./to_uuid.sh)

LB_PLUGIN_DIR = /etc/fos/plugins/linuxbridge
LB_PLUGIN_CONFFILE = /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json
Expand All @@ -19,6 +20,7 @@ else
sudo ln -sf /etc/fos/plugins/linuxbridge/linuxbridge_plugin /usr/bin/fos_linuxbridge
endif
sudo cp /etc/fos/plugins/linuxbridge/fos_linuxbridge.service /lib/systemd/system/
sudo sh -c "echo $(UUID) | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json > /tmp/linuxbridge_plugin.tmp && mv /tmp/linuxbridge_plugin.tmp /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json"


uninstall:
Expand Down
9 changes: 9 additions & 0 deletions fos-plugins/linuxbridge/to_uuid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

id=$(cat /etc/machine-id)
first=$(echo $id | cut -c -8)
second=$(echo $id | cut -c 9-12)
third=$(echo $id | cut -c 13-16)
fourth=$(echo $id | cut -c 17-20)
fifth=$(echo $id | cut -c 21-)
echo $first-$second-$third-$fourth-$fifth
13 changes: 12 additions & 1 deletion fos_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
# git checkout 0.2-devel


function to_uuid() {
first=$(echo $1 | cut -c -8)
second=$(echo $1 | cut -c 9-12)
third=$(echo $1 | cut -c 13-16)
fourth=$(echo $1 | cut -c 17-20)
fifth=$(echo $1 | cut -c 21-)
echo $first-$second-$third-$fourth-$fifth
}



MACHINE_TYPE=`uname -m`
Expand Down Expand Up @@ -33,7 +42,9 @@ rm -rf /tmp/fos.tar.gz

sudo make install

sudo sh -c "cat /etc/machine-id | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linux/linux_plugin.json > /tmp/linux_plugin.tmp && mv /tmp/linux_plugin.tmp /etc/fos/plugins/linux/linux_plugin.json"
uuid=$(to_uuid $(cat '/etc/machine-id'))

sudo sh -c "echo $uuid | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linux/linux_plugin.json > /tmp/linux_plugin.tmp && mv /tmp/linux_plugin.tmp /etc/fos/plugins/linux/linux_plugin.json"

echo 'You may want to install the other plugins, look at the fos-plugins directory!'

Expand Down
17 changes: 14 additions & 3 deletions install_fos_lxd.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/usr/bin/env bash

function to_uuid() {
first=$(echo $1 | cut -c -8)
second=$(echo $1 | cut -c 9-12)
third=$(echo $1 | cut -c 13-16)
fourth=$(echo $1 | cut -c 17-20)
fifth=$(echo $1 | cut -c 21-)
echo $first-$second-$third-$fourth-$fifth
}

git clone https://github.com/eclipse/fog05
cd fog05

Expand Down Expand Up @@ -41,19 +50,21 @@ rm -rf /tmp/fos.tar.gz

sudo make install

sudo sh -c "cat /etc/machine-id | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linux/linux_plugin.json > /tmp/linux_plugin.tmp && mv /tmp/linux_plugin.tmp /etc/fos/plugins/linux/linux_plugin.json"
uuid=$(to_uuid $(cat '/etc/machine-id'))

sudo sh -c "echo $uuid | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linux/linux_plugin.json > /tmp/linux_plugin.tmp && mv /tmp/linux_plugin.tmp /etc/fos/plugins/linux/linux_plugin.json"

sudo make -C fos-plugins/linuxbridge install

sudo sh -c "cat /etc/machine-id | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json > /tmp/linuxbridge.tmp && mv /tmp/linuxbridge.tmp /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json"
sudo sh -c "echo $uuid | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json > /tmp/linuxbridge.tmp && mv /tmp/linuxbridge.tmp /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json"

DP_FACE=$(awk '$2 == 00000000 { print $1 }' /proc/net/route | head -n 1)

sudo sh -c "jq '.configuration.dataplane_interface = \"$DP_FACE\"' /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json > /tmp/linuxbridge.tmp && mv /tmp/linuxbridge.tmp /etc/fos/plugins/linuxbridge/linuxbridge_plugin.json"

sudo make -C fos-plugins/LXD install

sudo sh -c "cat /etc/machine-id | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/LXD/LXD_plugin.json > /tmp/lxd.tmp && mv /tmp/lxd.tmp /etc/fos/plugins/LXD/LXD_plugin.json"
sudo sh -c "echo $uuid | xargs -i jq '.configuration.nodeid = \"{}\"' /etc/fos/plugins/LXD/LXD_plugin.json > /tmp/lxd.tmp && mv /tmp/lxd.tmp /etc/fos/plugins/LXD/LXD_plugin.json"

sudo make -C src/utils/python/rest_proxy install

Expand Down

0 comments on commit 652a2ca

Please sign in to comment.