summaryrefslogtreecommitdiffstats
path: root/net/nginx-util/Makefile
blob: 3fc0066f4b94ca6ddc25f6690b4ace9225ef7ca8 (plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
include $(TOPDIR)/rules.mk

PKG_NAME:=nginx-util
PKG_VERSION:=1.7
PKG_RELEASE:=2
PKG_MAINTAINER:=Peter Stadler <peter.stadler@student.uibk.ac.at>

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

CMAKE_OPTIONS+= -DUBUS=y
CMAKE_OPTIONS+= -DVERSION=$(PKG_VERSION)

define Package/nginx-ssl-util/default
  SECTION:=net
  CATEGORY:=Network
  SUBMENU:=Web Servers/Proxies
  TITLE:=Nginx configurator including SSL
  DEPENDS:=+libstdcpp +libuci +libubus +libubox +libpthread +libopenssl
endef


define Package/nginx-ssl-util
  $(Package/nginx-ssl-util/default)
  TITLE+= (using PCRE)
  DEPENDS+= +libpcre2
  CONFLICTS:=nginx-ssl-util-nopcre,
endef


define Package/nginx-ssl-util-nopcre
  $(Package/nginx-ssl-util/default)
  TITLE+= (using <regex>)
  CONFLICTS:=nginx-ssl-util
endef


define Package/nginx-ssl-util/default/description
  Utility that builds dynamically LAN listen directives for Nginx.
  Furthermore, it manages SSL directives for its server parts and can create
  corresponding (self-signed) certificates.
endef


Package/nginx-ssl-util/description = \
  $(Package/nginx-ssl-util/default/description) \
  It uses the PCRE library for performance.


Package/nginx-ssl-util-nopcre/description = \
  $(Package/nginx-ssl-util/default/description) \
  It uses the standard regex library of C++.


define Package/nginx-ssl-util/install/default
	$(INSTALL_DIR) $(1)/etc/nginx/conf.d/

	$(INSTALL_CONF) ./files/uci.conf.template $(1)/etc/nginx/
	$(LN) /var/lib/nginx/uci.conf $(1)/etc/nginx/uci.conf

	$(INSTALL_CONF) ./files/restrict_locally $(1)/etc/nginx/

	$(INSTALL_DIR) $(1)/etc/nginx/module.d/

	$(INSTALL_DIR) $(1)/etc/config/
	$(INSTALL_CONF) ./files/nginx.config $(1)/etc/config/nginx

ifneq ($(CONFIG_IPV6),y) # the used IPv6 directives have `::` in them:
	$(SED) "/::/d" $(1)/etc/nginx/restrict_locally
	$(SED) "/::/d" $(1)/etc/config/nginx
endif
endef


define Package/nginx-ssl-util/install
	$(call Package/nginx-ssl-util/install/default, $(1))
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-ssl-util $(1)/usr/bin/nginx-util
endef


define Package/nginx-ssl-util-nopcre/install
	$(call Package/nginx-ssl-util/install/default, $(1))
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-ssl-util-nopcre \
		$(1)/usr/bin/nginx-util
endef


define Package/nginx-ssl-util/prerm
#!/bin/sh

[ -n "$${IPKG_INSTROOT}" ] && exit 0
[ "$${PKG_UPGRADE}" = "1" ] && exit 0
case "$$(/sbin/uci get "nginx.global.uci_enable" 2>/dev/null)" in
	1|on|true|yes|enabled) ;;
	*) exit 0;;
esac

eval "$$(/usr/bin/nginx-util get_env)" &&
[ "$$(/sbin/uci get "nginx.$${LAN_NAME}.$${MANAGE_SSL}" 2>/dev/null)" = \
	"self-signed" ] &&
cd "/etc/nginx" &&
rm -f "$$(/sbin/uci get "nginx.$${LAN_NAME}.ssl_certificate")" \
	"$$(/sbin/uci get "nginx.$${LAN_NAME}.ssl_certificate_key")"

exit 0
endef


Package/nginx-ssl-util-nopcre/prerm = $(Package/nginx-ssl-util/prerm)


define Package/nginx-ssl-util/conffiles
/etc/config/nginx
/etc/nginx/restrict_locally
/etc/nginx/uci.conf.template
endef


Package/nginx-ssl-util-nopcre/conffiles = $(Package/nginx-ssl-util/conffiles)


$(eval $(call BuildPackage,nginx-ssl-util))
$(eval $(call BuildPackage,nginx-ssl-util-nopcre))