Make static site from wordpress site using bash

1

I have tried a few other scripts that can make a static version of a wordpress site but none of them are designed for bulk sites and I haven't found any that will just serve a static version while keeping the original. Here was my attempt but now I'm getting a bash error line 10: syntax error near unexpected token ('

Here's my current code:

#!/bin/bash
for DOMAIN in "$@"
do
  cd /var/www/$DOMAIN/web/
  wget -m -r -p -N -F -E http://www.$DOMAIN
  mv www.$DOMAIN static-site
  mkdir _wordpress-site
  mv !(error|stats|_wordpress-site|static-site) _wordpress-site
  mv .htaccess _wordpress-site
  echo '
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ static-site/$1 [L]
</IfModule>
   ' > .htaccess
done

if I escape the line with a parentheses like: mv !\(error|stats|_wordpress-site|static-site\) _wordpress-site I get 3 command not found errors

I have also tried escaping like: mv '!(error|stats|_wordpress-site|static-site) _wordpress-site' which gives me mv: missing destination file operand after ‘!(error|stats|_wordpress-site|static-site) _wordpress-site’

bartle_man

Posted 2015-07-07T23:05:00.673

Reputation: 11

No answers