control-import.sh
Automates the import process for cruise data, including downloading files, processing XML, updating WordPress posts, and cleaning up old data.
Usage
./control-import.sh
Description
- Checks if the script is already running to prevent multiple instances.
- Deletes old WordPress posts of type 'cruiseappy-imports' older than 7 days.
- Generates a unique import ID.
- Ensures log files exist.
- Fetches and downloads the latest file from an FTP endpoint.
- Unzips the downloaded file.
- Removes log entries older than 7 days from the database.
- Processes 'simplesearch' XML files and logs cruise data.
- Creates new WordPress posts with import reports using WP-CLI.
- Adds meta data to WordPress posts for each processed file.
- Updates import status for files with 0 cruises.
- Performs cleanup and setup tasks, including directory management and log rotation.
- Backs up booking XML files.
- Runs control scripts for cruise lines, ships, ports, and other data.
- Protects and starts prefetch prices script in the background.
- Updates search index and logs status.
- Sends email notification upon completion.
- Updates import status to 'Completed' in WordPress.
Dependencies
functions.sh: Utility functions.mysql: MySQL commands.wp: WP-CLI for WordPress operations.curl,unzip,rm,mkdir,sleep: Shell utilities.
Notes
- Ensure all required environment variables and plugins are set before running.
- Intended for use by developers or system administrators familiar with WordPress and server scripting.
For further details, refer to the comments in the script or contact the development team.