-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (57 loc) · 2.09 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
NETBOX_ROOT = /opt/netbox
PY_INIT_FILES = $(NETBOX_ROOT)/netbox/local/__init__.py $(NETBOX_ROOT)/netbox/scripts/__init__.py $(NETBOX_ROOT)/netbox/reports/__init__.py
MANUAL_UPGRADE := true
install:
@echo ""
@if [ "$(shell id -u)" -ne "0" ]; then \
echo "Error: This command must be run as root."; \
exit 1; \
fi
@mkdir -p $(NETBOX_ROOT)/netbox/scripts
@mkdir -p $(NETBOX_ROOT)/netbox/reports
@mkdir -p $(NETBOX_ROOT)/netbox/local/tests
@echo "Created Directories"
@for file in $(PY_INIT_FILES); do \
if [ ! -e "$$file" ]; then \
touch "$$file"; \
echo "Created $$file"; \
fi \
done
@echo "Validated/Created __init__.py files"
@make --no-print-directory MANUAL_UPGRADE=false upgrade
@echo "Updating Permissions.."
@make -s update_permissions
@echo ""
@echo "Install Complete!"
@echo "Make sure you update $(NETBOX_ROOT)/netbox/local/display_fields.py with your bun_root_path!"
@echo ""
upgrade:
@if [ "$(shell id -u)" -ne "0" ]; then \
echo "Error: This command must be run as root."; \
exit 1; \
fi
@echo "Copying files.."
@cp ./scripts/nice_circuit_scripts.py $(NETBOX_ROOT)/netbox/scripts/
@cp ./reports/nice_reports.py $(NETBOX_ROOT)/netbox/reports/
@cp ./local/tests/test_nice_circuit_scripts.py $(NETBOX_ROOT)/netbox/local/tests/
@cp ./local/display_fields.py $(NETBOX_ROOT)/netbox/local/
@cp ./local/nice_circuits.py $(NETBOX_ROOT)/netbox/local/
@cp ./local/utils.py $(NETBOX_ROOT)/netbox/local/
@cp ./local/validators.py $(NETBOX_ROOT)/netbox/local/
@echo "Successfully copied files."
@if [ "$(MANUAL_UPGRADE)" = "true" ]; then \
echo "Updating Permissions.."; \
make --no-print-directory update_permissions; \
echo ""; \
echo "Upgrade Complete!"; \
echo "Make sure you update $(NETBOX_ROOT)/netbox/local/display_fields.py with your bun_root_path!"; \
echo ""; \
fi
update_permissions:
@if [ "$(shell id -u)" -ne "0" ]; then \
echo "Error: This command must be run as root."; \
exit 1; \
fi
@chown --recursive netbox $(NETBOX_ROOT)/netbox/local
@chown --recursive netbox $(NETBOX_ROOT)/netbox/scripts
@chown --recursive netbox $(NETBOX_ROOT)/netbox/reports