make rc.d file dynamic
This commit is contained in:
		
							parent
							
								
									851009e1ef
								
							
						
					
					
						commit
						8262e792d4
					
				
							
								
								
									
										6
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										6
									
								
								Makefile
								
								
								
								
							|  | @ -22,6 +22,7 @@ endif | ||||||
| 
 | 
 | ||||||
| # rpm is wierd and changes - to _ in versions.
 | # rpm is wierd and changes - to _ in versions.
 | ||||||
| RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) | RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) | ||||||
|  | BINARYU:=$(shell echo $(BINARY) | tr -- - _) | ||||||
| 
 | 
 | ||||||
| PACKAGE_SCRIPTS= | PACKAGE_SCRIPTS= | ||||||
| ifeq ($(FORMULA),service) | ifeq ($(FORMULA),service) | ||||||
|  | @ -257,7 +258,10 @@ package_build_freebsd: readme man freebsd | ||||||
| 	cp examples/$(CONFIG_FILE).example $@/usr/local/etc/$(BINARY)/$(CONFIG_FILE) | 	cp examples/$(CONFIG_FILE).example $@/usr/local/etc/$(BINARY)/$(CONFIG_FILE) | ||||||
| 	cp LICENSE *.html examples/*?.?* $@/usr/local/share/doc/$(BINARY)/ | 	cp LICENSE *.html examples/*?.?* $@/usr/local/share/doc/$(BINARY)/ | ||||||
| 	[ "$(FORMULA)" != "service" ] || mkdir -p $@/usr/local/etc/rc.d | 	[ "$(FORMULA)" != "service" ] || mkdir -p $@/usr/local/etc/rc.d | ||||||
| 	[ "$(FORMULA)" != "service" ] || cp init/bsd/unifi-poller.rc $@/usr/local/etc/rc.d/unifi-poller | 	[ "$(FORMULA)" != "service" ] || \
 | ||||||
|  | 			sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{BINARYU}}/$(BINARYU)/g" -e "s/{{CONFIG_FILE}}/$(CONFIG_FILE)/g" \
 | ||||||
|  | 			init/bsd/unifi-poller.rc > $@/usr/local/etc/rc.d/unifi-poller | ||||||
|  | 	[ "$(FORMULA)" != "service" ] || chmod +x $@/usr/local/etc/rc.d/unifi-poller | ||||||
| 
 | 
 | ||||||
| package_build_freebsd_386: package_build_freebsd freebsd386 | package_build_freebsd_386: package_build_freebsd freebsd386 | ||||||
| 	mkdir -p $@ | 	mkdir -p $@ | ||||||
|  |  | ||||||
|  | @ -1,6 +1,11 @@ | ||||||
| #!/bin/sh | #!/bin/sh | ||||||
| # | # | ||||||
| # rc.d startup script for unifi-poller. Written for FreeBSD. | # FreeBSD rc.d startup script for unifi-poller. | ||||||
|  | # Target like so: | ||||||
|  | #   sed -e "s/{{BINARY}}/app-name/g" | ||||||
|  | #     -e "s/{{BINARYU}}/app_name/g" \ | ||||||
|  | #     -e "s/{{CONFIG_FILE}}/app-name.conf/g" \ | ||||||
|  | #     thisfile.rc > /usr/local/etc/rc.d/unifi-poller | ||||||
| # | # | ||||||
| # PROVIDE: unifi-poller | # PROVIDE: unifi-poller | ||||||
| # REQUIRE: networking syslog | # REQUIRE: networking syslog | ||||||
|  | @ -8,15 +13,23 @@ | ||||||
| 
 | 
 | ||||||
| . /etc/rc.subr | . /etc/rc.subr | ||||||
| 
 | 
 | ||||||
| name="unifipoller" | name="{{BINARYU}}" | ||||||
| rcvar="unifipoller_enable" | rcvar="{{BINARYU}}_enable" | ||||||
| command="/usr/local/bin/unifi-poller" | {{BINARYU}}_command="/usr/local/bin/{{BINARY}}" | ||||||
| unifipoller_user="nobody" | {{BINARYU}}_user="nobody" | ||||||
| unifipoller_config="/usr/local/etc/unifi-poller/up.conf" | {{BINARYU}}_config="/usr/local/etc/{{BINARY}}/{{CONFIG_FILE}}" | ||||||
|  | pidfile="/var/run/{{BINARY}}/pid" | ||||||
| 
 | 
 | ||||||
| start_cmd="/usr/sbin/daemon -T $name -l daemon -u $unifipoller_user $command -c $unifipoller_config" | # This runs `daemon` as the `{{BINARYU}}_user` user. | ||||||
|  | command="/usr/sbin/daemon" | ||||||
|  | command_args="-P ${pidfile} -r -t {{BINARY}} -T {{BINARY}} -l daemon ${{{BINARYU}}_command} -c ${{{BINARYU}}_config}" | ||||||
| 
 | 
 | ||||||
| load_rc_config $name | load_rc_config ${name} | ||||||
| : ${unifipoller_enable:=no} | : ${{{BINARYU}}_enable:=no} | ||||||
| 
 | 
 | ||||||
|  | # Make a place for the pid file. | ||||||
|  | mkdir -p $(dirname ${pidfile}) | ||||||
|  | chown -R ${{BINARYU}}_user $(dirname ${pidfile}) | ||||||
|  | 
 | ||||||
|  | # Go! | ||||||
| run_rc_command "$1" | run_rc_command "$1" | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| # Homebrew Formula Template. Built by Makefile: `make fomula` | # macOS Homebrew Formula Template. Built by Makefile: `make fomula` | ||||||
| # This is part of Application Builder. | # This is part of Application Builder. | ||||||
| # https://github.com/golift/application-builder | # https://github.com/golift/application-builder | ||||||
| class {{Class}} < Formula | class {{Class}} < Formula | ||||||
|  |  | ||||||
|  | @ -1,2 +1,2 @@ | ||||||
| This file isn't used by the build or for any packages. The homebrew launchd is | This file isn't used by the build or for any packages. The homebrew launchd is | ||||||
| in the [homebrew](../homebrew) folder. This file is for reference only. | in the [homebrew](../homebrew) folder. This macOS launchd file is for reference only. | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| # Systemd service unit for {{BINARY}}. | # Linux Systemd service unit for {{BINARY}}. | ||||||
| # This is part of Application Builder. | # This is part of Application Builder. | ||||||
| # https://github.com/golift/application-builder | # https://github.com/golift/application-builder | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue