diff --git a/makefiles/netbox_inventory_manager/Makefile b/makefiles/netbox_inventory_manager/Makefile index d6afdbca741b7a565175da473a94bbf022037d20..4ff305eb15886c23129c3cde1e2eb88a7a7b4580 100644 --- a/makefiles/netbox_inventory_manager/Makefile +++ b/makefiles/netbox_inventory_manager/Makefile @@ -5,8 +5,8 @@ GIT_REPO=https://github.com/netbox-community/go-netbox.git CLONE_DIR=../../../go-netbox TARGET_DIR=../../../gosdn/internal/netboxapi -NETBOX_VERSION=4.2.8 -NETBOX_DOCKER_VERSION=3.2.0 +NETBOX_VERSION=4.3.1 +NETBOX_DOCKER_VERSION=3.3.0 GOIMPORTS := $(shell go env GOPATH)/bin/goimports USER_NAME := fabi CONFIG_DIR=../../applications/inventory-manager-netbox/config/configNetbox.yaml @@ -19,11 +19,13 @@ reset: dockerDown cleangonetbox clone fixrights make afterreset: down fixrights build copy .PHONY: afterafterreset -afterafterreset: dockerDown build copy +afterafterreset: wait30sec build copy .PHONY: netboxstartingroutin -netboxstartingroutin: netboxstarten netboxsuperuser netboxToken +netboxstartingroutin: netboxdockerclone netboxstarten netboxsuperuser netboxToken +.PHONY: netboxstartingroutinv2 +netboxstartingroutinv2: wait30sec netboxstarten netboxsuperuser netboxToken .PHONY: dockerDown dockerDown: @@ -81,19 +83,25 @@ build: @echo ">> Running 'make build' with NETBOX_VERSION=$(NETBOX_VERSION)..." @echo ">> Fixing permissions (vor dem Build)..." sudo chown -R $(shell whoami):$(shell whoami) $(CLONE_DIR) - + @sleep 10 @echo ">> Installing goimports (if not already installed)..." go install golang.org/x/tools/cmd/goimports@latest - @echo ">> Building NetBox Go SDK..." - cd $(CLONE_DIR) && PATH="$$PATH:$(shell go env GOPATH)/bin" make build NETBOX_VERSION=$(NETBOX_VERSION) NETBOX_DOCKER_VERSION=$(NETBOX_DOCKER_VERSION) - - @echo ">> Fixing permissions (nach dem Build)..." + @sleep 10 + cd $(CLONE_DIR) && PATH="$$PATH:$(shell go env GOPATH)/bin" make build + @sleep 10 + NETBOX_VERSION=$(NETBOX_VERSION) NETBOX_DOCKER_VERSION=$(NETBOX_DOCKER_VERSION) + @sleep 10 + @echo ">> Running goimports selbst (nur auf beschreibbare Dateien)..." + cd $(CLONE_DIR) && \ + find . -name '*.go' -type f -writable -exec $(GOIMPORTS) -w {} + || true + @echo ">> Running goimports selbst..." + @sleep 10 + cd $(CLONE_DIR) && goimports -w . || true + @echo ">> Fixing permissions (nach goimports)..." sudo chown -R $(shell whoami):$(shell whoami) $(CLONE_DIR) - @echo ">> Running goimports selbst..." -#goimports -w $(CLONE_DIR) - goimports -w $$(find . -name '*.go') + .PHONY: copy @@ -110,7 +118,21 @@ clean: #@rm -rf $(TARGET_DIR) - +# -------------------------- +.PHONY: netboxdockerclone +netboxdockerclone: + @echo ">> (Re)Cloning netbox-docker (release branch)..." + @if [ -d "../../../netbox-docker" ]; then \ + echo ">> Stopping and cleaning up old netbox-docker..."; \ + ( cd ../../../netbox-docker && docker compose down || true ); \ + docker volume rm -f netbox-docker_netbox-postgres-data || true; \ + echo ">> Removing existing netbox-docker directory..."; \ + rm -rf ../../../netbox-docker; \ + fi + git clone -b release https://github.com/netbox-community/netbox-docker.git ../../../netbox-docker + @echo ">> Creating docker-compose.override.yml with port mapping..." + echo "services:\n netbox:\n ports:\n - 8000:8080" > ../../../netbox-docker/docker-compose.override.yml + @echo "netbox-docker cloned, cleaned, and override created." .PHONY: netboxstarten @@ -118,10 +140,15 @@ netboxstarten: @echo ">> PULL NetBox Docker with..." cd ../../../netbox-docker && docker compose pull @echo ">> UP NetBox Docker with..." - cd ../../../netbox-docker && docker compose up + cd ../../../netbox-docker && docker compose up -d @echo ">> NetBox Docker started." - @echo ">> http://127.0.0.1:8000/ + @echo ">> http://127.0.0.1:8000/" +.PHONY: wait30sec +wait30sec: + @echo "Warte 30 Sekunden..." + @sleep 30 + @echo "Weiter geht's!" .PHONY: netboxsuperuser netboxsuperuser: