Skip to content

Commit

Permalink
Added auto-install script (#87)
Browse files Browse the repository at this point in the history
Added autoinstallation script that install all the dependencies a configure a single node fog05, with YAKS and LXD
  • Loading branch information
gabrik committed Nov 26, 2020
1 parent e5f7d37 commit 1b25da0
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 3 deletions.
4 changes: 3 additions & 1 deletion fos_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ rm -rf /tmp/fos.tar.gz

sudo make install

echo 'Update the fog05 configuration file under /etc/fos/agent.json and /etc/fos/plugins/linux/linux_plugins.json'
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"

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



75 changes: 75 additions & 0 deletions install_fos_lxd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash

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

MACHINE_TYPE=`uname -m`


export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
# sudo dpkg-reconfigure locales

sudo apt update
# sudo apt remove --purge lxd lxd-client lxc -y
sudo apt install libev4 libev-dev libssl1.0.0 python3-pip python3-dev curl jq snapd -y
# sudo snap install lxd

# newgrp lxd << EONG
# lxd init --auto
# lxd waitready
# lxc network create lxdbr0 ipv4.address=auto ipv4.nat=true ipv6.address=none ipv6.nat=false
# EONG


sudo pip3 install jsonschema psutil jinja2 netifaces

mkdir -p src/agent/_build/default/fos-agent

if [ ${MACHINE_TYPE} == 'x86_64' ]; then
curl -L -o /tmp/fos.tar.gz https://www.dropbox.com/s/y7hvr7j79ibc4pk/fos.tar.gz
elif [ ${MACHINE_TYPE} == 'armv7l' ]; then
curl -L -o /tmp/fos.tar.gz https://www.dropbox.com/s/uziduncc4v35zj9/fos.tar.gz
elif [ ${MACHINE_TYPE} == 'aarch64' ]; then
curl -L -o /tmp/fos.tar.gz https://www.dropbox.com/s/kcz3pvirb2xmh40/fos.tar.gz
fi



tar -xzvf /tmp/fos.tar.gz -C src/agent/_build/default/fos-agent
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"

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"

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 make -C src/utils/python/rest_proxy install



git clone https://github.com/atolab/yaks-python
cd yaks-python
git checkout 0.2
sudo pip3 uninstall yaks -y
sudo make install

sudo systemctl daemon-reload

sudo systemctl start yaks
sudo systemctl start fos_agent
sudo systemctl start fos_linux
sudo systemctl start fos_linuxbridge
sudo systemctl start fos_lxd
sudo systemctl start fosrest
32 changes: 32 additions & 0 deletions src/utils/python/rest_proxy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*-Makefile-*-

WD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))));

REST_API_DIR = /etc/fos/rest
REST_API_CONFIG = /etc/fos/rest/service.json
all:
echo "Nothing to do"

install:
sudo pip3 install flask
ifeq "$(wildcard $(REST_API_DIR))" ""
sudo mkdir -p $(REST_API_DIR)
sudo mkdir -p $(REST_API_DIR)/imgs
sudo cp -r ./src/service.py $(REST_API_DIR)/service.py
sudo cp -r ./src/service.json $(REST_API_CONFIG)
else
sudo mkdir -p $(REST_API_DIR)
sudo mkdir -p $(REST_API_DIR)/imgs
sudo cp -r ./src/service.py $(REST_API_DIR)/service.py
sudo cp -r ./src/service.json $(REST_API_CONFIG)
sudo ln -sf $(REST_API_DIR)/service.py /usr/bin/fos_rest
endif
sudo cp ./fosrest.service /lib/systemd/system/

sudo chown fos:fos -R $(REST_API_DIR)

uninstall:
sudo systemctl disable fosrest
sudo rm -rf $(REST_API_DIR)
sudo rm /lib/systemd/system/fosrest.service
sudo rm -rf /usr/bin/fos_rest
17 changes: 17 additions & 0 deletions src/utils/python/rest_proxy/fosrest.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[unit]
Description = Eclipse fog05 REST Proxy
After=fos_agent.target


[Service]
Type=simple
PIDFile=/var/fos/rest.pid
ExecStart = /etc/fos/rest/service.py /etc/fos/rest/service.json
KillMode=process
Restart=on-failure
User=fos
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=fos_rest
[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions src/utils/python/rest_proxy/src/service.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"host": "127.0.0.1",
"host": "0.0.0.0",
"port": 8080,
"debug": true,
"yaks": "10.100.1.221",
"yaks": "127.0.0.1",
"sysid": "0",
"tenantid": "0",
"image_path": "imgs"
Expand Down

0 comments on commit 1b25da0

Please sign in to comment.