I’m not sure what this has to do specifically with ROS 2. The general issue here is how do you source a shell script correctly via a system call.
I recommend asking on a more generic forum. We usually use Python’s subprocess
module to do this kind of thing.