Handle different ADMIN_INTERFACE_DIR path in update

Now that the new version has its own embed webserver, I don't need to keep the /admin/ directory in the lighttpd root, that I use for other purposes on the home server.

I found that I can edit the pihole.toml file easily to reflect that:

[...]
 740   [webserver.paths]
 741     # Server root on the host
 742     #
 743     # Possible values are:
 744     #     <valid path>
 745     webroot = "/var/www/pihole" ### CHANGED, default = "/var/www/html"
 746
 747     # Sub-directory of the root containing the web interface
 748     #
 749     # Possible values are:
 750     #     <valid subpath>, both slashes are needed!
 751     webhome = "/admin/"
 752
 753   [webserver.interface]
 754     # Should the web interface use the boxed layout?
 755     boxed = false ### CHANGED, default = true
[...]

And it worked like a charm. The problem is that the update script don't consider this change and when trying to run pihole -up it fails and asks me to reinstall Pi-Hole from the website.

I suggest adding a function like this to update.sh so it can handle this scenario:

#!/bin/bash

# Read webroot and webhome path from /etc/pihole/pihole.toml
get_admin_interface_dir() {
    local webroot_path webhome_path
    webroot_path=$(sed -n 's/^\s*webroot\s*=\s*"\(.*\)"/\1/p' /etc/pihole/pihole.toml)
    webhome_path=$(sed -n 's/^\s*webhome\s*=\s*"\(.*\)"/\1/p' /etc/pihole/pihole.toml)
    echo "${webroot_path}${webhome_path}" # Construct the full path
}

    echo $(get_admin_interface_dir)

Please, note I'm not very good with sed and bash script and I know this is not a proper way to read the .toml file, just a boilerplate code to demonstrate the idea.

This is not working as expected.

The code still expects the web interface to be on the same place (/var/www/html/admin). Some paths are still hard-coded in a few places (in Core, web and FTL).

Even with your suggested changes some things will still broke.

This will need to be fixed in a future release.

1 Like

Thanks for the explanation.

So, to avoid problems here, I moved what I was serving in the /var/www/html to other directory and leave that default directory just for Pi-Hole.

Glad you found a solution.

I hope this is a temporary issue and we can fix the missing bits necessary for the web interface to work in a different path.

1 Like