Last active
December 6, 2024 18:15
-
-
Save austinsonger/9a8fad2200b74b37eacc70057502a198 to your computer and use it in GitHub Desktop.
Automates the installation of Swirl Search Community Edition on a Debian or MacOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Combined Swirl Search Community Installation Script for Debian and macOS | |
# Exit on errors | |
set -e | |
echo "Starting Swirl Search Community installation..." | |
# Detect the operating system | |
OS=$(uname -s) | |
case "$OS" in | |
Linux) | |
echo "Detected OS: Linux" | |
if [ -f /etc/debian_version ]; then | |
echo "Debian-based distribution detected. Proceeding with installation..." | |
# Update and upgrade the system | |
echo "Updating the system..." | |
sudo apt update && sudo apt upgrade -y | |
# Install dependencies | |
echo "Installing dependencies..." | |
sudo apt install -y python3 python3-venv python3-pip git | |
else | |
echo "Unsupported Linux distribution. Exiting." | |
exit 1 | |
fi | |
;; | |
Darwin) | |
echo "Detected OS: macOS" | |
# Check if Homebrew is installed | |
if ! command -v brew &>/dev/null; then | |
echo "Homebrew is not installed. Installing Homebrew..." | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
fi | |
# Update Homebrew | |
echo "Updating Homebrew..." | |
brew update | |
# Install Python 3 and Git | |
echo "Installing Python 3 and Git..." | |
brew install python git | |
;; | |
*) | |
echo "Unsupported operating system. Exiting." | |
exit 1 | |
;; | |
esac | |
# Verify Python and pip installation | |
echo "Verifying Python installation..." | |
python3 --version | |
pip3 --version | |
# Clone the Swirl Search repository | |
echo "Cloning Swirl Search repository..." | |
git clone https://github.com/swirlai/swirl-search.git | |
cd swirl-search | |
# Check out the latest stable release | |
echo "Checking out the latest stable release..." | |
git checkout main | |
# Set up the Python virtual environment | |
echo "Setting up Python virtual environment..." | |
python3 -m venv venv | |
source venv/bin/activate | |
# Install Swirl Search requirements | |
echo "Installing Python dependencies..." | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
# Set up environment variables | |
echo "Configuring environment variables..." | |
cp .env.example .env | |
# Migrate the database | |
echo "Applying database migrations..." | |
python manage.py migrate | |
# Collect static files | |
echo "Collecting static files..." | |
python manage.py collectstatic --noinput | |
# Start the Swirl server | |
echo "Starting Swirl server..." | |
python manage.py runserver 0.0.0.0:8000 & | |
echo "Swirl Search installation completed!" | |
echo "You can now access the server at http://<your-server-ip>:8000 or http://localhost:8000" | |
# Reminder for further steps | |
echo "Remember to configure your .env file and other settings for production use!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment