- Error Handling: Added try-except blocks to handle file operations, subprocess commands, and permission issues. Logs detailed error messages for debugging.
- Path Handling: Used pathlib.Path for better path manipulation and readability. Made paths configurable via environment variables.
- File Permissions: Ensured the target directory is created with parents=True to handle nested directories. Checked if files already exist in the target directory to avoid unnecessary overwrites.
- Logging: Added more detailed logging for better transparency and debugging.
- Subprocess Security: Added checks for apachectl and systemctl commands to ensure compatibility with supported systems.
- Input Validation: Validated the existence of .conf files before copying them.
- Code Structure: Encapsulated the main logic in a main() function for better organization.
- Added docstrings to functions for clarity.
Initially tried to add all files ending in .conf in correct dir to a
string in {a,b,c,d} form for cp, but ran into a char limit for cp so
sadly went with the slower for loop method