Last active
November 17, 2021 10:26
-
-
Save sab99r/bf1f38601af86345e1f2a7dab76e3e43 to your computer and use it in GitHub Desktop.
PHP shell_exec Github Webhook Git Pull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```code | |
if($_POST['payload']) { | |
echo shell_exec('cd /var/www/html/RepoFolder/ && git reset --hard HEAD && git pull https://[email protected]/username/RepoName.git 2>&1'); | |
} | |
``` | |
```code | |
//Find the Executing user and give permission | |
echo shell_exec('whoami'); | |
eg. apache | |
//Give write permission to apache | |
sudo chown apache:apache -R RepoFolder | |
//Then give permission to apache for git | |
sudo chown -R apache:apache "$(git rev-parse --show-toplevel)/.git" | |
//source : https://stackoverflow.com/questions/18779442/error-while-pull-from-git-insufficient-permission-for-adding-an-object-to-repo | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment