I'm working on a script to sync a folder from Windows to a Linux server with Rsync and I manage to get it work with git bash and the rsync executable.
In Centso I added the
syncinguser to the
sudoer -> syncinguser ALL=NOPASSWD:/usr/bin/rsync to allow the execution of Rsync, how can I allow the same user to run a
.sh file to complete the sync process or a php command?
I want to sync a Laravel application so I need to run the command
php artisan cache:clear and
php artisan config:cache after the sync has finished.
I would also like to change
chown -R user:psacln * but I'm quite happy with the fact that doesn't change the rights on the folders E.g: 0777 permission on the public folder.
This is my script in windows so far:
rsync -rt --chown=user:group (being ignored I think because user's permissions) --exclude ".env" --exclude "storage" --exclude "public/storage" --progress --rsync-path="sudo rsync" -e "ssh -p <port>" '/c/path/to/local/folder/' syncinguser@<ip address>:/remote/path/
how can I add something like this after the sync:
ssh yncinguser@<ip address> php artisan cache:clear ssh syncinguser@<ip address> php artisan config:cache // OR ssh syncinguser@<ip address>:/remote/path/to/completesync.sh
completesync.sh will run the 2 php artisan command and apply recursively the owner:group of all files/folders as when they come from windows they are all root:root
I cannot connect as a root because we blocked it, you need to connect as a normal user and then switch to root.
ssh -p <ssh port> syncinguser@<IP ADDRESSED> '/path/to/script.sh'
permissions denied, same if I connect as a normal user