linux: Fix logic error in prepare_paths function
Refactor daemon logic