Files
ente_setup/setup_minio.sh

79 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Download and install MinIO server
wget https://dl.min.io/server/minio/release/linux-amd64/minio -O /usr/local/bin/minio
# Make the MinIO binary executable
chmod +x /usr/local/bin/minio
# Create a new user and group named 'minio' don't fail if already exists
sudo groupadd -r minio || true
sudo useradd -r -s /sbin/nologin -g minio -d /var/lib/minio minio || true
# Create a directory for MinIO server configuration and data
sudo mkdir -p /etc/minio /var/lib/minio
# Set ownership and permissions for the MinIO data directory
sudo chown minio:minio /var/lib/minio
# Configure MinIO server as a systemd service
sudo tee /etc/systemd/system/minio.service > /dev/null <<EOL
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/var/lib/minio
User=minio
Group=minio
ProtectSystem=full
# Set environment variables for MinIO configuration
Environment=MINIO_SERVER_URL=https://minio.sa.vin/
Environment=MINIO_BROWSER_REDIRECT_URL=https://minio.sa.vin/minio/ui
Environment=MINIO_ROOT_USER=minio_root_user_60c4cbcd
Environment=MINIO_ROOT_PASSWORD=74fcd51acc7bfeca02223ce516324a
EnvironmentFile=-/etc/default/minio
ExecStart=/usr/local/bin/minio server --console-address ":45855" /mnt/md0/minio/
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Specifies the maximum number of threads this process can create
TasksMax=infinity
[Install]
WantedBy=multi-user.target
EOL
# Reload systemd manager configuration
sudo systemctl daemon-reload
# Start the MinIO service
sudo systemctl start minio
# Enable MinIO service to start on boot
sudo systemctl enable minio
echo "MinIO server has been set up successfully. Access the server at http://localhost:9000"
# The setup_minio.sh script installs and configures the MinIO server as a systemd service on a Linux system. It downloads the MinIO binary, creates a new user and group for MinIO, sets up the necessary directories, and configures the MinIO server as a systemd service.
# Key points:
# - The script uses wget to download the MinIO server binary and places it in /usr/local/bin/minio.
# - It creates a new user and group named 'minio' to run the MinIO server.
# - The script creates directories for MinIO server configuration (/etc/minio) and data (/var/lib/minio) and sets the appropriate ownership and permissions.
# - It configures the MinIO server as a systemd service by creating a unit file at /etc/systemd/system/minio.service.
# - The MinIO service is started and enabled to run on boot using systemctl commands.
# - The script provides a message indicating that the MinIO server setup was successful and provides the URL to access the server (http://localhost:9000).
# Overall, the script automates the setup process for the MinIO server, making it easier to deploy and manage the object storage service on a Linux system.
# Note: The script assumes that the system has wget installed and that the necessary dependencies for running the MinIO server are available. It may need to be adjusted based on the specific Linux distribution and environment.