public_html/ being recreated automatically via non-interactive shell?
I am deploying an application using a tool like Capistrano, sending individual commands to the server via a non-interactive shell.
public_html/ for the cPanel account is configured as a symlink, pointing to a path like
When sending 2 commands back to back to 1) remove the existing symlink or the default directory cPanel created and then 2) create a new symlink
Instead of seeing the symlink I expect
I see the following
It seems when the non-interactive shell connection is established to send the command creating the symlink, something is noticing the public_html/ directory no longer exists and is recreating it. I've checked thoroughly to make sure none of my application code or deployment code is doing this, so I'm wondering: what is causing this behavior?
/home/acctname/public_html -> /home/acctname/app/revisions/201402221245When sending 2 commands back to back to 1) remove the existing symlink or the default directory cPanel created and then 2) create a new symlink
rm -rf /home/acctname/public_html
ln -fs /home/acctname/app/revisions/201402221245 /home/acctname/public_htmlInstead of seeing the symlink I expect
/home/acctname/public_html -> /home/acctname/app/revisions/201402221245I see the following
/home/acctname/public_html/201402221245 -> /home/acctname/app/revisions/201402221245It seems when the non-interactive shell connection is established to send the command creating the symlink, something is noticing the public_html/ directory no longer exists and is recreating it. I've checked thoroughly to make sure none of my application code or deployment code is doing this, so I'm wondering: what is causing this behavior?
-
It looks like /etc/bashrc has the following, which is most definitely the source of my problem if [ ! -e ~/public_html/cgi-bin ]; then mkdir -p ~/public_html/cgi-bin fi0 -
First, can you clarity what 'non-interactive' shell you are using? There are a couple scripts that will recreate docroots, but it's possible perhaps the public_htm isn't actually getting removed in the first place. I'm curious though - why do an rm -rf instead of an unlink? Unlink is safer for symlinks: unlink /home/acctname/public_html ln -fs /home/acctname/app/revisions/201402221245 /home/acctname/public_html0 -
public_html/ is definitely getting removed. I say "non-interactive" because I have mostly default ssh settings for Capistrano, and it's docs say it assigns a non-login, /http://capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/ I am not an expert in which startup files are included for login/non-login & interactive/non-interactive shells, but so far /etc/bashrc is the only one I've come across which is definitely trying to recreate the public_html/ directory. Thank you for your tip about using unlink. A follow-up question I have is: will /etc/bashrc be reset by cPanel when cPanel updates are performed? 0 -
Manually modifications to /etc/bashrc should not be overwritten by cPanel updates. It's often done to prevent the automatic creation of the cgi-bin directory. Thank you. 0 -
Have you tried executing in succession? rm -rf /home/acctname/public_html && ln -fs /home/acctname/app/revisions/201402221245 /home/acctname/public_html
I had the same issue when developing my Capistrano deployment scripts. The above solved my problem.0
Please sign in to leave a comment.
Comments
5 comments