diff --git a/Makefile b/Makefile index e80c3d0fe5aba63448c86562f5a8c4f8b82355f0..c8ce40047b12ce5a07a57782fc3a3634ce0e49bf 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ GOFLAGS := $(EXTRA_GOFLAGS) # target APPS1 := kmesh-daemon APPS2 := kmesh-cmd +APPS3 := mdacore .PHONY: all install uninstall clean @@ -50,33 +51,48 @@ all: $(call printlog, BUILD, "kernel") $(QUIET) make -C kernel/ko_src + $(call printlog, BUILD, $(APPS3)) + $(QUIET) cd oncn-mda && cmake . -B build && make -C build + install: $(QUIET) make install -C api/v2-c $(QUIET) make install -C bpf/deserialization_to_bpf_map $(QUIET) make install -C kernel/ko_src $(call printlog, INSTALL, $(INSTALL_BIN)/$(APPS1)) - #$(QUIET) install -dp -m 0700 $(INSTALL_BIN) $(QUIET) install -Dp -m 0500 $(APPS1) $(INSTALL_BIN) $(call printlog, INSTALL, $(INSTALL_BIN)/$(APPS2)) $(QUIET) install -Dp -m 0500 $(APPS2) $(INSTALL_BIN) + $(call printlog, INSTALL, $(INSTALL_BIN)/$(APPS3)) + $(QUIET) install -Dp -m 0500 oncn-mda/deploy/$(APPS3) $(INSTALL_BIN) + $(QUIET) install -Dp -m 0400 oncn-mda/build/ebpf_src/CMakeFiles/sock_ops.dir/sock_ops.c.o /usr/share/oncn-mda/sock_ops.c.o + $(QUIET) install -Dp -m 0400 oncn-mda/build/ebpf_src/CMakeFiles/sock_redirect.dir/sock_redirect.c.o /usr/share/oncn-mda/sock_redirect.c.o + uninstall: $(QUIET) make uninstall -C api/v2-c $(QUIET) make uninstall -C bpf/deserialization_to_bpf_map $(QUIET) make uninstall -C kernel/ko_src + $(call printlog, UNINSTALL, $(INSTALL_BIN)/$(APPS1)) $(QUIET) rm -rf $(INSTALL_BIN)/$(APPS1) + $(call printlog, UNINSTALL, $(INSTALL_BIN)/$(APPS2)) $(QUIET) rm -rf $(INSTALL_BIN)/$(APPS2) + $(call printlog, UNINSTALL, $(INSTALL_BIN)/$(APPS3)) + $(QUIET) rm -rf $(INSTALL_BIN)/$(APPS3) clean: $(call printlog, CLEAN, $(APPS1)) $(QUIET) rm -rf $(APPS1) $(APPS1) - + $(call printlog, CLEAN, $(APPS2)) $(QUIET) rm -rf $(APPS2) $(APPS2) - + + $(call printlog, CLEAN, $(APPS3)) + $(QUIET) rm -rf oncn-mda/build + $(QUIET) rm -rf oncn-mda/deploy + $(QUIET) make clean -C api/v2-c $(QUIET) make clean -C bpf/deserialization_to_bpf_map $(call printlog, CLEAN, "kernel") diff --git a/build.sh b/build.sh index 80c7940f0d1eebeba09b571d919fdbbb7049a628..f9dee7a98671a7b95c446dc7aa9a1b4355f129c6 100755 --- a/build.sh +++ b/build.sh @@ -13,36 +13,6 @@ function prepare() { cp $ROOT_DIR/depends/include/5.10.0-60.18.0.50.oe2203/bpf_helper_defs_ext.h $ROOT_DIR/bpf/include/ } -function build_mda { - cd oncn-mda - mkdir -p build && cd build - cmake ../ - make -} - -function build() { - make - build_mda -} - -function install_mda { - echo "install mda" - cp $ROOT_DIR/oncn-mda/deploy/mdacore /usr/bin/ - chmod 500 /usr/bin/mdacore - - mkdir -p /usr/share/oncn-mda - chmod 500 /usr/share/oncn-mda - cp $ROOT_DIR/oncn-mda/build/ebpf_src/CMakeFiles/sock_ops.dir/sock_ops.c.o /usr/share/oncn-mda/ - cp $ROOT_DIR/oncn-mda/build/ebpf_src/CMakeFiles/sock_redirect.dir/sock_redirect.c.o /usr/share/oncn-mda/ - chmod 500 /usr/share/oncn-mda/sock_ops.c.o - chmod 500 /usr/share/oncn-mda/sock_redirect.c.o - - mkdir -p /etc/oncn-mda - chmod 700 /etc/oncn-mda - cp $ROOT_DIR/oncn-mda/etc/oncn-mda.conf /etc/oncn-mda/ - chmod 600 /etc/oncn-mda/oncn-mda.conf -} - function install() { mkdir -p /etc/kmesh chmod 700 /etc/kmesh @@ -54,6 +24,11 @@ function install() { cp $ROOT_DIR/build/kmesh-stop-post.sh /usr/bin chmod 500 /usr/bin/kmesh-stop-post.sh + mkdir -p /etc/oncn-mda + chmod 700 /etc/oncn-mda + cp $ROOT_DIR/oncn-mda/etc/oncn-mda.conf /etc/oncn-mda/ + chmod 600 /etc/oncn-mda/oncn-mda.conf + cp $ROOT_DIR/build/kmesh.service /usr/lib/systemd/system/ chmod 600 /usr/lib/systemd/system/kmesh.service systemctl daemon-reload @@ -63,15 +38,10 @@ function uninstall() { rm -rf /etc/kmesh rm -rf /usr/bin/kmesh-start-pre.sh rm -rf /usr/bin/kmesh-stop-post.sh - rm -rf /usr/lib/systemd/system/kmesh.service - systemctl daemon-reload -} - -function uninstall_mda() { - echo "uninstall mda" rm -rf /etc/oncn-mda - rm -rf /usr/bin/mdacore rm -rf /usr/share/oncn-mda + rm -rf /usr/lib/systemd/system/kmesh.service + systemctl daemon-reload } function clean() { @@ -91,28 +61,24 @@ fi if [ -z "$1" -o "$1" == "-b" -o "$1" == "--build" ]; then prepare - build + make exit fi if [ "$1" == "-i" -o "$1" == "--install" ]; then make install install - install_mda exit fi if [ "$1" == "-u" -o "$1" == "--uninstall" ]; then make uninstall uninstall - uninstall_mda exit fi if [ "$1" == "-c" -o "$1" == "--clean" ]; then make clean clean - rm -rf $ROOT_DIR/oncn-mda/build - rm -rf $ROOT_DIR/oncn-mda/deploy exit fi