# How to stop sed from breaking when in combination with apg?

I am writing a script that will install WordPress automatically for me, to make my life easier as I have to deploy WordPress installs constantly.

However, I am trying to make it so I never have to interact with it, and that is taking my sleep away.

To generate the passwords for databases and whatnot, I use apg, and then use sed to replace a string with the correct password. It looks something like this:

DOMAIN="$2" DB_NAME_USER="$  (echo $DOMAIN | sed -e 's/\.//g')" DB_PASSWORD="$  (apg -a 1 -n 1 -m 64 -d -c cl_seed -E \_\"\'\\/\\=)"  sed -i "s/database_name_here/$DB_NAME_USER/g" /srv/"$  DOMAIN"/wp-config.php sed -i "s/username_here/$DB_NAME_USER/g" /srv/"$  DOMAIN"/wp-config.php sed -i "s/password_here/$DB_PASSWORD/g" /srv/"$  DOMAIN"/wp-config.php `

Replacing the database and username works just fine, but when replacing the password, six out of ten times the replace goes bad and I end up with something like this: