1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bash Scripting anyone?

Discussion in 'Hire a Freelancer' started by nuhll, Sep 16, 2015.

  1. nuhll

    nuhll Junior Member

    Joined:
    Jul 8, 2015
    Messages:
    196
    Likes Received:
    17
    Hi,
    i have this script:
    http://blog.rimuhosting.com/2013/10...shell-script-plugins-themes-crontab-and-more/

    it updates all wordpress, just one problem: i have to enter everytime y (yes to start update).

    1.) Could someone skip this question?
    2.) And maybe some email like updated 20/20 wordpress, no errors...
    3.) this script doesnt do the last step, when you update wordpress u need to click "update your wordpress db" before you can login into admin. This shoudl also be automatic.

    So i can use this in cronjob...

    Tell me what you want for it... no skype.
     
    Last edited: Sep 16, 2015
  2. derevo

    derevo Newbie

    Joined:
    Dec 25, 2014
    Messages:
    30
    Likes Received:
    2
    To skip question change this part



    Code:
    checkdeps() {
    
    DEPSTOINSTALL='curl zip'
    NEEDSINSTALL=""
    
    for PKGSTOINSTALL in $DEPSTOINSTALL ; do
      if ! command -v $PKGSTOINSTALL &> /dev/null ; then
        NEEDSINSTALL="$NEEDSINSTALL $PKGSTOINSTALL"
      fi
    done
    
      if [[ ! -z "$NEEDSINSTALL" ]]; then
        echo -e "$NEEDSINSTALL not installed, Install? (y/n) \c"
        read REPLY
        if [[ "$REPLY" = "y" ]]; then
              # Debian based
              if  command -v dpkg &> /dev/null; then
            apt-get install $NEEDSINSTALL 
              # RPM based
              elif command -v rpm &> /dev/null; then
            yum install $NEEDSINSTALL
              else
            echo "Your distro is not supported!"
            exit 1
              fi               
        
          fi
      fi
    
    }

    to this one



    Code:
    checkdeps() {
    
    
    DEPSTOINSTALL='curl zip'
    NEEDSINSTALL=""
    REPLY = "y"
    
    
    for PKGSTOINSTALL in $DEPSTOINSTALL ; do
      if ! command -v $PKGSTOINSTALL &> /dev/null ; then
        NEEDSINSTALL="$NEEDSINSTALL $PKGSTOINSTALL"
      fi
    done
    
    
      if [[ ! -z "$NEEDSINSTALL" ]]; then
        if [[ "$REPLY" = "y" ]]; then
              # Debian based
              if  command -v dpkg &> /dev/null; then
            apt-get install $NEEDSINSTALL 
              # RPM based
              elif command -v rpm &> /dev/null; then
            yum install $NEEDSINSTALL
              else
            echo "Your distro is not supported!"
            exit 1
              fi               
        
          fi
      fi
    
    
    }
    

    Im don't test it but i'm sure it should works;)


    P.S:also check this tool in google "WP-CLI" A command line interface for WordPress
     
    Last edited: Sep 16, 2015
  3. nuhll

    nuhll Junior Member

    Joined:
    Jul 8, 2015
    Messages:
    196
    Likes Received:
    17
    Thanks, still "You have version 4.3 Standard Wordpress located at /home/ftp/XXX/ that needs updating to 4.3.1Would you like me to upgrade it? [y/N]"

    PS:
    wordpress-upgrade.sh: line 47: REPLY: command not found
     
  4. derevo

    derevo Newbie

    Joined:
    Dec 25, 2014
    Messages:
    30
    Likes Received:
    2
    try this one

    Code:
    checkdeps() {
    
    
    DEPSTOINSTALL='curl zip'
    NEEDSINSTALL=""
    
    
    for PKGSTOINSTALL in $DEPSTOINSTALL ; do
      if ! command -v $PKGSTOINSTALL &> /dev/null ; then
    	NEEDSINSTALL="$NEEDSINSTALL $PKGSTOINSTALL"
      fi
    done
    
    
      if [[ ! -z "$NEEDSINSTALL" ]]; then
    
    
    	      # Debian based
    	      if  command -v dpkg &> /dev/null; then
    		apt-get install $NEEDSINSTALL 
    	      # RPM based
    	      elif command -v rpm &> /dev/null; then
    		yum install $NEEDSINSTALL
    	      else
    		echo "Your distro is not supported!"
    		exit 1
    	      fi               
      fi
    
    
    }
    
    
    
     
  5. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    the question is in line 123-125
    change it
    Code:
    	echo "You have version $your_ver ${thisis} located at $wp_root that needs updating to ${WPCURRENT_VER}"
    	#echo -n "Would you like me to upgrade it? [y/N] "
    	yn="y"
    	if [ $yn == "y" ];then
    		echo "Upgrading $wp_root"
    
     
  6. nuhll

    nuhll Junior Member

    Joined:
    Jul 8, 2015
    Messages:
    196
    Likes Received:
    17
    Does still not work, no one an idea?

    If i # the echo, it just hangs.
     
  7. nuhll

    nuhll Junior Member

    Joined:
    Jul 8, 2015
    Messages:
    196
    Likes Received:
    17
    Sry, i reverted all changes and just did what sockpuppet wrote, its now working, thanks.
     
  8. handmadebots

    handmadebots Senior Member

    Joined:
    Nov 8, 2012
    Messages:
    962
    Likes Received:
    217
    Home Page:
    People would be probably more helpful if you could give out more details.
    Like, what does it output when you do the changes sockpuppet suggested ?

     
  9. nuhll

    nuhll Junior Member

    Joined:
    Jul 8, 2015
    Messages:
    196
    Likes Received:
    17
    1.) read everything and
    2.) since there was NO OUTPUT and it just hangs, what else i can tell?
     
  10. handmadebots

    handmadebots Senior Member

    Joined:
    Nov 8, 2012
    Messages:
    962
    Likes Received:
    217
    Home Page:
    1. Check the time of my post, when you clicked Post, I was taking my time to write my post, in order to help you out (mofugga!)
    2. "no output" - lowercase
     
  11. nuhll

    nuhll Junior Member

    Joined:
    Jul 8, 2015
    Messages:
    196
    Likes Received:
    17
    no need to fuck around.

    Thanks for your help