Skip to content

Instantly share code, notes, and snippets.

@onnimonni
Created June 2, 2016 09:09
Show Gist options
  • Save onnimonni/bd45dcaa5c18d26a43959a5288d64440 to your computer and use it in GitHub Desktop.
Save onnimonni/bd45dcaa5c18d26a43959a5288d64440 to your computer and use it in GitHub Desktop.
Synchronized wpallimport with php-cli. This is really a big hack and I think that wpallimport should be avoided. But if you have to stick with it and need to do multiple imports after each other this works.
#!/bin/bash
set -ex
# This is a hack to use wpallimport without http request.
# We need this to be synchronized so that importers don't overlap and cause too much strain
# Import Asunnot with wpallimport
php -e -r 'parse_str("import_key=XXXXXXXXX&import_id=16&action=trigger", $_GET); include "/data/code/web/wp/wp-cron.php";'
# Wait until importer is ready
while true; do
importer_result=$(php -e -r 'set_time_limit(10); parse_str("import_key=XXXXXXXXX&import_id=16&action=processing", $_GET); include "/data/code/web/wp/wp-cron.php";')
echo $importer_result
if [ "$importer_result" != "" ] && echo $importer_result | grep 'already processing'; then
sleep 60
else
break
fi
done
# Import Henkilot with wpallimport
php -e -r 'parse_str("import_key=XXXXXXXXX&import_id=14&action=trigger", $_GET); include "/data/code/web/wp/wp-cron.php";'
# Wait until importer is ready
while true; do
importer_result=$(php -e -r 'set_time_limit(10); parse_str("import_key=XXXXXXXXX&import_id=14&action=processing", $_GET); include "/data/code/web/wp/wp-cron.php";')
echo $importer_result
if [ "$importer_result" != "" ] && echo $importer_result | grep 'already processing'; then
sleep 60
else
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment