makefile install and uninstall, use different config path

This commit is contained in:
Murphy 2023-04-12 11:56:55 -04:00
parent 435b32948b
commit 9c19aa4d33
4 changed files with 38 additions and 2 deletions

View file

@ -34,3 +34,16 @@ $(BIN)/%.o: %.c
clean:
rm -rf $(APP)
rm -rf $(BIN)
install:
cp bin/app /usr/local/bin/wrapper
uninstall:
rm /usr/local/bin/wrapper
openrc-install: install
cp service/openrc /etc/init.d/wrapper
chmod +x /etc/init.d/wrapper
openrc-uninstall: uninstall
rm /etc/init.d/wrapper

13
service/openrc Normal file
View file

@ -0,0 +1,13 @@
#!/sbin/openrc-run
name="WrapperDNS"
description="Wrapper dns server"
command=/usr/local/bin/wrapper
supervisor=supervise-daemon
depend() {
need net
}
#start_pre() {
# export PORT=53
#}

View file

@ -475,10 +475,11 @@ static void config_push_record(Record** buf, Record record, uint16_t* capacity,
bool load_config(const char* path, RecordMap* map) {
FILE* file = fopen(path, "r");
if (file == NULL) {
ERROR("Failed to open file %s: %s", path, strerror(errno));
return false;
}
INFO("Using config file at path: %s", path);
line = 0;
record_map_init(map);

View file

@ -21,7 +21,16 @@ void server_init(uint16_t port, Server* server) {
INFO("Server port set to %hu", port);
create_binding(UDP, port, &server->udp);
create_binding(TCP, port, &server->tcp);
load_config("config", &map);
if (load_config("/etc/wrapper.conf", &map)) {
return;
}
if (load_config("config", &map)) {
return;
}
WARN("No dns config files were found");
}
struct DnsRequest {