mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-25 20:25:28 +03:00
190 lines
7.9 KiB
Diff
190 lines
7.9 KiB
Diff
From 74349ec5be7ac9410f265718438c313bf368b93e Mon Sep 17 00:00:00 2001
|
|
From: Mike Crute <mike@crute.us>
|
|
Date: Sat, 10 May 2025 15:14:03 -0700
|
|
Subject: [PATCH 3/4] Support configuring file paths
|
|
|
|
Allow configuring the file paths for storing configuration and state
|
|
through cmake so that Linux distribution packagers can place their files
|
|
in FHS-friendly paths.
|
|
---
|
|
src/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++
|
|
src/api/action.c | 2 +-
|
|
src/config/config.c | 10 +++++-----
|
|
src/config/config.h | 2 +-
|
|
src/config/dnsmasq_config.h | 8 ++++----
|
|
src/files.h | 2 +-
|
|
src/zip/teleporter.c | 4 ++--
|
|
7 files changed, 44 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/FTL-6.2.3/src/CMakeLists.txt b/FTL-6.2.3/src/CMakeLists.txt
|
|
index f9902bec..e6b142ec 100644
|
|
--- a/FTL-6.2.3/src/CMakeLists.txt
|
|
+++ b/FTL-6.2.3/src/CMakeLists.txt
|
|
@@ -15,6 +15,36 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
|
|
endif()
|
|
endif()
|
|
|
|
+if (PIHOLE_STATE_PATH)
|
|
+ add_definitions(-DPIHOLE_STATE_PATH="${PIHOLE_STATE_PATH}")
|
|
+else()
|
|
+ add_definitions(-DPIHOLE_STATE_PATH="/etc/pihole")
|
|
+endif()
|
|
+
|
|
+if (PIHOLE_SHARE_PATH)
|
|
+ add_definitions(-DPIHOLE_SHARE_PATH="${PIHOLE_SHARE_PATH}")
|
|
+else()
|
|
+ add_definitions(-DPIHOLE_SHARE_PATH="/etc/pihole")
|
|
+endif()
|
|
+
|
|
+if (PIHOLE_BIN_PATH)
|
|
+ add_definitions(-DPIHOLE_BIN_PATH="${PIHOLE_BIN_PATH}")
|
|
+else()
|
|
+ add_definitions(-DPIHOLE_BIN_PATH="/usr/local/bin")
|
|
+endif()
|
|
+
|
|
+if (PIHOLE_WEB_PATH)
|
|
+ add_definitions(-DPIHOLE_WEB_PATH="${PIHOLE_WEB_PATH}")
|
|
+else()
|
|
+ add_definitions(-DPIHOLE_WEB_PATH="/var/www/html")
|
|
+endif()
|
|
+
|
|
+if (PIHOLE_RUN_PATH)
|
|
+ add_definitions(-DPIHOLE_RUN_PATH="${PIHOLE_RUN_PATH}")
|
|
+else()
|
|
+ add_definitions(-DPIHOLE_RUN_PATH="/run")
|
|
+endif()
|
|
+
|
|
# Do not add run time path information
|
|
# This ensures CMake does not add rpath information to the binary and
|
|
# subsequently strip it from the binary during install causing the binary
|
|
diff --git a/FTL-6.2.3/src/api/action.c b/FTL-6.2.3/src/api/action.c
|
|
index 4a55d6e5..306e91f8 100644
|
|
--- a/FTL-6.2.3/src/api/action.c
|
|
+++ b/FTL-6.2.3/src/api/action.c
|
|
@@ -117,7 +117,7 @@ static int run_and_stream_command(struct ftl_conn *api, const char *path, const
|
|
|
|
int api_action_gravity(struct ftl_conn *api)
|
|
{
|
|
- return run_and_stream_command(api, "/usr/local/bin/pihole", (const char *const []){ "pihole", "-g", NULL });
|
|
+ return run_and_stream_command(api, PIHOLE_BIN_PATH"/pihole", (const char *const []){ "pihole", "-g", NULL });
|
|
}
|
|
|
|
int api_action_restartDNS(struct ftl_conn *api)
|
|
diff --git a/FTL-6.2.3/src/config/config.c b/FTL-6.2.3/src/config/config.c
|
|
index de65c9ba..9852c7d0 100644
|
|
--- a/FTL-6.2.3/src/config/config.c
|
|
+++ b/FTL-6.2.3/src/config/config.c
|
|
@@ -1065,7 +1065,7 @@ void initConfig(struct config *conf)
|
|
conf->webserver.paths.webroot.a = cJSON_CreateStringReference("<valid path>");
|
|
conf->webserver.paths.webroot.t = CONF_STRING;
|
|
conf->webserver.paths.webroot.f = FLAG_RESTART_FTL;
|
|
- conf->webserver.paths.webroot.d.s = (char*)"/var/www/html";
|
|
+ conf->webserver.paths.webroot.d.s = (char*)PIHOLE_WEB_PATH;
|
|
conf->webserver.paths.webroot.c = validate_filepath;
|
|
|
|
conf->webserver.paths.webhome.k = "webserver.paths.webhome";
|
|
@@ -1232,14 +1232,14 @@ void initConfig(struct config *conf)
|
|
conf->files.pid.a = cJSON_CreateStringReference("<any writable file>");
|
|
conf->files.pid.t = CONF_STRING;
|
|
conf->files.pid.f = FLAG_RESTART_FTL;
|
|
- conf->files.pid.d.s = (char*)"/run/pihole-FTL.pid";
|
|
+ conf->files.pid.d.s = (char*)PIHOLE_RUN_PATH"/FTL.pid";
|
|
conf->files.pid.c = validate_filepath;
|
|
|
|
conf->files.database.k = "files.database";
|
|
conf->files.database.h = "The location of FTL's long-term database";
|
|
conf->files.database.a = cJSON_CreateStringReference("<any FTL database>");
|
|
conf->files.database.t = CONF_STRING;
|
|
- conf->files.database.d.s = (char*)"/etc/pihole/pihole-FTL.db";
|
|
+ conf->files.database.d.s = (char*)PIHOLE_STATE_PATH"/pihole-FTL.db";
|
|
conf->files.database.c = validate_filepath;
|
|
|
|
conf->files.gravity.k = "files.gravity";
|
|
@@ -1247,7 +1247,7 @@ void initConfig(struct config *conf)
|
|
conf->files.gravity.a = cJSON_CreateStringReference("<any Pi-hole gravity database>");
|
|
conf->files.gravity.t = CONF_STRING;
|
|
conf->files.gravity.f = FLAG_RESTART_FTL;
|
|
- conf->files.gravity.d.s = (char*)"/etc/pihole/gravity.db";
|
|
+ conf->files.gravity.d.s = (char*)PIHOLE_STATE_PATH"/gravity.db";
|
|
conf->files.gravity.c = validate_filepath;
|
|
|
|
conf->files.gravity_tmp.k = "files.gravity_tmp";
|
|
@@ -1262,7 +1262,7 @@ void initConfig(struct config *conf)
|
|
conf->files.macvendor.h = "The database containing MAC -> Vendor information for the network table";
|
|
conf->files.macvendor.a = cJSON_CreateStringReference("<any Pi-hole macvendor database>");
|
|
conf->files.macvendor.t = CONF_STRING;
|
|
- conf->files.macvendor.d.s = (char*)"/etc/pihole/macvendor.db";
|
|
+ conf->files.macvendor.d.s = (char*)PIHOLE_SHARE_PATH"/macvendor.db";
|
|
conf->files.macvendor.c = validate_filepath;
|
|
|
|
conf->files.pcap.k = "files.pcap";
|
|
diff --git a/FTL-6.2.3/src/config/config.h b/FTL-6.2.3/src/config/config.h
|
|
index 3c23c7d9..2a580822 100644
|
|
--- a/FTL-6.2.3/src/config/config.h
|
|
+++ b/FTL-6.2.3/src/config/config.h
|
|
@@ -40,7 +40,7 @@
|
|
#define GLOBALCONFFILE_LEGACY "/etc/pihole/pihole-FTL.conf"
|
|
|
|
// Migration target for the legacy (pre-v6.0) config file
|
|
-#define MIGRATION_TARGET_V6 "/etc/pihole/migration_backup_v6"
|
|
+#define MIGRATION_TARGET_V6 PIHOLE_STATE_PATH"/migration_backup_v6"
|
|
|
|
// Location of the legacy (pre-v6.0) setupVars config file
|
|
#define SETUPVARS_CONF "/etc/pihole/setupVars.conf"
|
|
diff --git a/FTL-6.2.3/src/config/dnsmasq_config.h b/FTL-6.2.3/src/config/dnsmasq_config.h
|
|
index 92175ec9..fa05f39c 100644
|
|
--- a/FTL-6.2.3/src/config/dnsmasq_config.h
|
|
+++ b/FTL-6.2.3/src/config/dnsmasq_config.h
|
|
@@ -22,14 +22,14 @@ bool read_legacy_cnames_config(void);
|
|
bool read_legacy_custom_hosts_config(void);
|
|
bool write_custom_list(void);
|
|
|
|
-#define DNSMASQ_PH_CONFIG "/etc/pihole/dnsmasq.conf"
|
|
-#define DNSMASQ_TEMP_CONF "/etc/pihole/dnsmasq.conf.temp"
|
|
+#define DNSMASQ_PH_CONFIG PIHOLE_STATE_PATH"/dnsmasq.conf"
|
|
+#define DNSMASQ_TEMP_CONF PIHOLE_STATE_PATH"/dnsmasq.conf.temp"
|
|
#define DNSMASQ_STATIC_LEASES MIGRATION_TARGET_V6"/04-pihole-static-dhcp.conf"
|
|
#define DNSMASQ_CNAMES MIGRATION_TARGET_V6"/05-pihole-custom-cname.conf"
|
|
-#define DNSMASQ_HOSTSDIR "/etc/pihole/hosts"
|
|
+#define DNSMASQ_HOSTSDIR PIHOLE_STATE_PATH"/hosts"
|
|
#define DNSMASQ_CUSTOM_LIST DNSMASQ_HOSTSDIR"/custom.list"
|
|
#define DNSMASQ_CUSTOM_LIST_LEGACY "/etc/pihole/custom.list"
|
|
#define DNSMASQ_CUSTOM_LIST_LEGACY_TARGET MIGRATION_TARGET_V6"/custom.list"
|
|
-#define DHCPLEASESFILE "/etc/pihole/dhcp.leases"
|
|
+#define DHCPLEASESFILE PIHOLE_STATE_PATH"/dhcp.leases"
|
|
|
|
#endif //DNSMASQ_CONFIG_H
|
|
diff --git a/FTL-6.2.3/src/files.h b/FTL-6.2.3/src/files.h
|
|
index b5f16019..5478d9bf 100644
|
|
--- a/FTL-6.2.3/src/files.h
|
|
+++ b/FTL-6.2.3/src/files.h
|
|
@@ -20,7 +20,7 @@
|
|
#include <pwd.h>
|
|
|
|
#define MAX_ROTATIONS 15
|
|
-#define BACKUP_DIR "/etc/pihole/config_backups"
|
|
+#define BACKUP_DIR PIHOLE_STATE_PATH"/config_backups"
|
|
|
|
bool chmod_file(const char *filename, const mode_t mode);
|
|
bool file_exists(const char *filename);
|
|
diff --git a/FTL-6.2.3/src/zip/teleporter.c b/FTL-6.2.3/src/zip/teleporter.c
|
|
index eb6b5012..f249aa3c 100644
|
|
--- a/FTL-6.2.3/src/zip/teleporter.c
|
|
+++ b/FTL-6.2.3/src/zip/teleporter.c
|
|
@@ -184,11 +184,11 @@ const char *generate_teleporter_zip(mz_zip_archive *zip, char filename[128], voi
|
|
|
|
// Add /etc/pihole/dhcp.lease to the ZIP archive if it exists
|
|
file_comment = "DHCP leases file";
|
|
- file_path = "/etc/pihole/dhcp.leases";
|
|
+ file_path = PIHOLE_STATE_PATH"/dhcp.leases";
|
|
if(file_exists(file_path) && !mz_zip_writer_add_file(zip, file_path+1, file_path, file_comment, (uint16_t)strlen(file_comment), MZ_BEST_COMPRESSION))
|
|
{
|
|
mz_zip_writer_end(zip);
|
|
- return "Failed to add /etc/pihole/dhcp.leases to heap ZIP archive!";
|
|
+ return "Failed to add " PIHOLE_STATE_PATH "/dhcp.leases to heap ZIP archive!";
|
|
}
|
|
|
|
const char *directory = "/etc/dnsmasq.d";
|
|
--
|
|
2.49.0
|
|
|