Wordpress automated script

0

I'm in a project where I need to create a script that automates the installation in different.

The code:

#!/bin/bash

cd /home/luis/public_html/1/wordpress/

read to_print

cp -R wp-signup.php wp-login.php wp-config-sample.php license.txt xmlrpc.php wp-settings.php wp-cron.php wp-load.php wp-activate.php wp-comments-post.php licencia.txt wp-trackback.php wp-links-opml.php wp-mail.php index.php readme.html wp-blog-header.php /home/luis/public_html/$to_print/

cp -R /home/luis/public_html/1/wordpress/wp-admin/ /home/luis/public_html/1/wordpress/wp-includes/ /home/luis/public_html/1/wordpress/wp-content/ /home/luis/public_html/$to_print/

What I would like is to be able to take the variable from a CSV or similar, instead of writing it. For now what it does is copy Wordpress locally and take it to the domain folder but I have to define the domain in the script.

Please note that I am learning!

    
asked by redxlus 19.09.2018 в 14:17
source

1 answer

0

Assuming that what you want is to make a script that copies a directory containing the collection of wordpress files to start a clean installation in a destination directory, and you want to avoid entering the destination directories one by one, you can have example, a file directorios.txt

juanito
pedrito
jorgito
dieguito

(note, the file must have a blank line at the end or the last record will not be read)

  

ISO / IEC 9899: 2011 §7.21.2 Streams

     

A text stream is an ordered sequence of characters composed into   lines, each line consisting of zero or more characters plus a   terminating new-line character.

Now your bash script reads line by line from that file:

#!/bin/bash
input="directorios.txt"
while read -r subdirectorio
do
  # rsync -avzr /home/luis/public_html/1/wordpress/ /home/luis/public_html/$subdirectorio/
  echo "rsync -avzr /home/luis/public_html/1/wordpress/ /home/luis/public_html/$subdirectorio/"
done < "$input"

The route of the subdirectory I put hard. That could perfect it. The important thing is that it is copying the content of the source by executing

rsync -avzr /home/luis/public_html/1/wordpress/ /home/luis/public_html/juanito/
rsync -avzr /home/luis/public_html/1/wordpress/ /home/luis/public_html/pedrito/
rsync -avzr /home/luis/public_html/1/wordpress/ /home/luis/public_html/jorgito/
rsync -avzr /home/luis/public_html/1/wordpress/ /home/luis/public_html/dieguito/

I found it more efficient to use rsync than to explicitly put the files.

In the example I left the commented command and in exchange I put a echo of what the command would do.

    
answered by 19.09.2018 в 16:40