Running the following commands in a shell runs without issues:
ssh user@machine systemctl status my-service.service
ssh user@machine sudo systemctl stop my-service.service
scp -r ./my-service/* user@machine:/home/user/my-service
ssh user@machine chmod +x /home/user/my-service/my-service
ssh user@machine sudo systemctl start my-service.service
ssh user@machine sudo systemctl status my-service.service
However, putting this in a deploy.sh
file results in none of the above being able to execute.
Errors:
- Invalid unit name "my-service" was escaped as "my-service\x0d" (maybe you should use systemd-escape?)
- Unit my-service\x0d.service could not be found.
- Invalid unit name "my-service.service" was escaped as "my-service.service\x0d" (maybe you should use systemd-escape?)
- Failed to stop my-service\x0d.service: Unit my-service.service\x0d.service not loaded.
: No such file or directorynlock/
- chmod: cannot access '/home/user/my-service/my-service'$'\r': No such file or directory
- Invalid unit name "my-service.service" was escaped as "my-service.service\x0d" (maybe you should use systemd-escape?)
- Failed to start my-service.service\x0d.service: Unit my-service.service\x0d.service not found.
Invalid unit name "my-service.service" was escaped as "my-service.service\x0d" (maybe you should use systemd-escape?)
- Unit my-service.service\x0d.service could not be found.
Some were broken up. It seems something related to escaping. For some reason adding a space at the end of the lines makes it sort of work but still not without errors.
Googling on the errors shows some hits about using --
and adding it together with the trailing space makes some commands work but still giving an escaping error.