Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate legacy files into /etc/pihole/migration_backup_v6 #2055

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ bool readFTLconf(struct config *conf, const bool rewrite)
const char *path = "";
if((path = readFTLlegacy(conf)) != NULL)
{
const char *target = "/etc/pihole/pihole-FTL.conf.bck";
const char *target = "/etc/pihole/migration_backup_v6/pihole-FTL.conf";
log_info("Moving %s to %s", path, target);
if(rename(path, target) != 0)
log_warn("Unable to move %s to %s: %s", path, target, strerror(errno));
Expand Down
2 changes: 1 addition & 1 deletion src/config/dnsmasq_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ bool read_legacy_custom_hosts_config(void)
{
// Check if file exists, if not, there is nothing to do
const char *path = DNSMASQ_CUSTOM_LIST_LEGACY;
const char *target = DNSMASQ_CUSTOM_LIST_LEGACY".bck";
const char *target = DNSMASQ_CUSTOM_LIST_LEGACY_TARGET;
if(!file_exists(path))
return true;

Expand Down
1 change: 1 addition & 0 deletions src/config/dnsmasq_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bool write_custom_list(void);
#define DNSMASQ_HOSTSDIR "/etc/pihole/hosts"
#define DNSMASQ_CUSTOM_LIST DNSMASQ_HOSTSDIR"/custom.list"
#define DNSMASQ_CUSTOM_LIST_LEGACY "/etc/pihole/custom.list"
#define DNSMASQ_CUSTOM_LIST_LEGACY_TARGET "/etc/pihole/migration_backup_v6/custom.list"
#define DHCPLEASESFILE "/etc/pihole/dhcp.leases"

#endif //DNSMASQ_CONFIG_H
18 changes: 5 additions & 13 deletions src/config/setupVars.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,20 +591,12 @@ void importsetupVarsConf(void)
// Ports may be temporarily stored when importing a legacy Teleporter v5 file
get_conf_string_from_setupVars("WEB_PORTS", &config.webserver.port);

// Move the setupVars.conf file to setupVars.conf.old
char *old_setupVars = calloc(strlen(config.files.setupVars.v.s) + 5, sizeof(char));
if(old_setupVars == NULL)
{
log_warn("Could not allocate memory for old_setupVars");
return;
}
strcpy(old_setupVars, config.files.setupVars.v.s);
strcat(old_setupVars, ".old");
if(rename(config.files.setupVars.v.s, old_setupVars) != 0)
log_warn("Could not move %s to %s", config.files.setupVars.v.s, old_setupVars);
// Move the setupVars.conf file to the migration directory
const char *setupVars_target = "/etc/pihole/migration_backup_v6/setupVars.conf";
if(rename(config.files.setupVars.v.s, setupVars_target) != 0)
log_warn("Could not move %s to %s", config.files.setupVars.v.s, setupVars_target);
else
log_info("Moved %s to %s", config.files.setupVars.v.s, old_setupVars);
free(old_setupVars);
log_info("Moved %s to %s", config.files.setupVars.v.s, setupVars_target);

log_info("Migration complete");
}
Expand Down
Loading