Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

public_html/ being recreated automatically via non-interactive shell?

Discussion in 'General Discussion' started by Zbx3x4UyxPy7Ty2, Feb 24, 2014.

  1. Zbx3x4UyxPy7Ty2

    Zbx3x4UyxPy7Ty2 Registered

    Joined:
    Feb 24, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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

    Code:
    /home/acctname/public_html -> /home/acctname/app/revisions/201402221245
    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

    Code:
    rm -rf /home/acctname/public_html
    ln -fs /home/acctname/app/revisions/201402221245 /home/acctname/public_html
    Instead of seeing the symlink I expect

    Code:
    /home/acctname/public_html -> /home/acctname/app/revisions/201402221245
    I see the following

    Code:
    /home/acctname/public_html/201402221245 -> /home/acctname/app/revisions/201402221245
    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?
     
  2. Zbx3x4UyxPy7Ty2

    Zbx3x4UyxPy7Ty2 Registered

    Joined:
    Feb 24, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    It looks like /etc/bashrc has the following, which is most definitely the source of my problem

    Code:
    if [ ! -e ~/public_html/cgi-bin ]; then
        mkdir -p ~/public_html/cgi-bin
    fi
    
     
  3. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    834
    Likes Received:
    28
    Trophy Points:
    178
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    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:

    Code:
    unlink /home/acctname/public_html
    ln -fs /home/acctname/app/revisions/201402221245 /home/acctname/public_html
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Zbx3x4UyxPy7Ty2

    Zbx3x4UyxPy7Ty2 Registered

    Joined:
    Feb 24, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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?
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,749
    Likes Received:
    1,886
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. oldchili

    oldchili Member

    Joined:
    Mar 18, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Have you tried executing in succession?

    Code:
    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.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice