Bug 16291

Summary: koha-remove --purge should also delete '/etc/koha/sites/$instance' dir
Product: Koha Reporter: Mason James <mtj>
Component: PackagingAssignee: Robin Sheat <robin>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, mirko, robin
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13902
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9754
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the koha-remove --purge package command so that the instance name's directory is completely removed, even if it has additional files in it. Previously, the instance's directory wasn't removed if there were other files in it, which could cause problems when creating a new instance with the same name.
Version(s) released in:
Circulation function:
Bug Depends on: 9754    
Bug Blocks:    
Attachments: Bug 16291: remove /etc/koha/sites/$name on koha-remove --purge-all
Bug 16291: Remove /etc/koha/sites/$name on koha-remove --purge-all

Description Mason James 2016-04-19 04:27:51 UTC
It would be useful if 'koha-remove --purge' also deleted a /etc/koha/sites/instance dir
Comment 1 Mason James 2016-05-18 02:06:54 UTC
*** Bug 13902 has been marked as a duplicate of this bug. ***
Comment 2 Robin Sheat 2025-11-23 01:15:58 UTC
Created attachment 189899 [details] [review]
Bug 16291: remove /etc/koha/sites/$name on koha-remove --purge-all

A purge leaves behind some traces in /etc/koha/sites/$name, which can cause problems because the directory isn't deleted. This deletes the whole shebang when purge is requested.

Test plan:
1. With the packages installed, make an instance.
2. Make a file in there, e.g. `# cat hello > /etc/koha/sites/$name/foo.txt`
3. Delete the instance with `koha-remove $name --purge-all`
4. Verify that `/etc/koha/sites/$name no longer exists
Comment 3 David Nind 2025-11-28 23:57:28 UTC
Created attachment 190041 [details] [review]
Bug 16291: Remove /etc/koha/sites/$name on koha-remove --purge-all

A purge leaves behind some traces in /etc/koha/sites/$name, which
can cause problems because the directory isn't deleted. This deletes
the whole shebang when purge is requested.

Test plan:
1. With the packages installed, make an instance.
2. Make a file in there, e.g. `# cat hello > /etc/koha/sites/$name/foo.txt`
3. Delete the instance with `koha-remove $name --purge-all`
4. Verify that `/etc/koha/sites/$name no longer exists

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2025-11-29 00:01:33 UTC
Testing notes (using KTD):

1. Create an instance: sudo koha-create --create-db testkoha 

2. Create a file: sudo vi /etc/koha/sites/testkoha/foo.txt

3. Change permissions: sudo chown root:testkoha-koha /etc/koha/sites/testkoha/foo.txt

4. Remove: sudo koha-remove testkoha --purge-all

5. I shut down KTD and restarted it with the patch applied, but I'm not sure if that was necessary.