forked from eclipse-fog05/fog05
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
105 lines (89 loc) · 3.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# -*-Makefile-*-
WD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))));
ETC_FOS_DIR = /etc/fos/
VAR_FOS_DIR = /var/fos/
FOS_CONF_FILE = /etc/fos/agent.json
LINUX_PLUGIN_DIR = /etc/fos/plugins/linux
LINUX_PLUGIN_CONFFILE = /etc/fos/plugins/linux/linux_plugin.json
all:
make -C src/im/ocaml install
make -C src/core/ocaml install
make -C src/agent/;
install:
make -C src/api/python/api install
# make -C src/api/ocaml/api install
ifeq "$(wildcard $(ETC_FOS_DIR))" ""
sudo mkdir -p /etc/fos/plugins
endif
sudo id -u fos >/dev/null 2>&1 || sudo useradd -r -s /bin/false fos
sudo usermod -aG sudo fos
ifeq ($(shell uname -m), x86_64)
curl -L -o /tmp/yaks.tar.gz https://www.dropbox.com/s/g4tnzvjwlx3zcr2/yaksd.tar.gz
else ifeq ($(shell uname -m), armv7l)
curl -L -o /tmp/yaks.tar.gz https://www.dropbox.com/s/lo4s72rc5uoowxw/yaksd_armv7l.tar.gz
else ifeq ($(shell uname -m), aarch64)
curl -L -o /tmp/yaks.tar.gz https://www.dropbox.com/s/j29g35zb9cy28ph/yaksd_arm64.tar.gz
endif
tar -xzvf /tmp/yaks.tar.gz -C /etc/fos
rm -rf /tmp/yaks.tar.gz
ifeq "$(wildcard $(VAR_FOS_DIR))" ""
sudo mkdir -p /var/fos
sudo chown fos:fos /var/fos
endif
echo "fos ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null
sudo cp src/agent/_build/default/fos-agent/fos_agent.exe /etc/fos/agent
ifeq "$(wildcard $(LINUX_PLUGIN_DIR))" ""
sudo cp -r fos-plugins/linux /etc/fos/plugins/
else
sudo cp -r fos-plugins/linux/scripts /etc/fos/plugins/linux/
sudo cp fos-plugins/linux/__init__.py /etc/fos/plugins/linux/
sudo cp fos-plugins/linux/linux_plugin /etc/fos/plugins/linux/
sudo cp fos-plugins/linux/README.md /etc/fos/plugins/linux/
endif
ifeq "$(wildcard $(FOS_CONF_FILE))" ""
sudo cp etc/agent.json /etc/fos/agent.json
endif
sudo cp etc/fos_agent.service /lib/systemd/system/
sudo cp etc/fos_agent.target /lib/systemd/system/
sudo cp etc/yaks.service /lib/systemd/system/
sudo cp etc/yaks.target /lib/systemd/system/
sudo cp /etc/fos/plugins/linux/fos_linux.service /lib/systemd/system/
sudo ln -sf /etc/fos/yaksd /usr/bin/yaksd
sudo ln -sf /etc/fos/agent /usr/bin/fagent
sudo ln -sf /etc/fos/plugins/linux/linux_plugin /usr/bin/fos_linux
lldp:
sudo mkdir -p /etc/fos/lldpd
sudo ./etc/lldp/build.sh
sudo ./etc/lldp/config.sh
sudo cp ./etc/lldp/run.sh /etc/fos/lldpd/run.sh
sudo systemctl disable lldpd
sudo systemctl stop lldpd
cli:
make -C src/api/ocaml/api install
make -C src/utils/ocaml/cli install
uninstall:
sudo systemctl stop fos_agent
sudo systemctl disable fos_agent
sudo systemctl disable fos_linux
sudo rm -rf /etc/fos
sudo rm -rf /var/fos
sudo rm /lib/systemd/system/fos_agent.service
sudo rm /lib/systemd/system/fos_agent.target
sudo rm /lib/systemd/system/yaks.target
sudo rm /lib/systemd/system/yaks.service
sudo rm /lib/systemd/system/fos_linux.service
sudo rm -rf /etc/fos/yaksd
sudo rm -rf /etc/fos/agent
sudo rm -rf /usr/bin/fos_linux
sudo userdel fos
sudo pip3 uninstall fog05 -y
clean:
opam remove fos-im -y
make -C src/im/ocaml clean
make -C src/core/ocaml clean
make -C src/agent clean
make -C src/api/ocaml/api clean
sudo rm -rf lldpd
sudo rm -rf src/pyhton/fog05.egg-info
sudo rm -rf src/pyhton/build
sudo rm -rf src/pyhton/dist