Skip to content

Instantly share code, notes, and snippets.

@airbornelamb
Created September 27, 2018 07:09
Show Gist options
  • Save airbornelamb/a84582b47f313ee210799e3d9508f17d to your computer and use it in GitHub Desktop.
Save airbornelamb/a84582b47f313ee210799e3d9508f17d to your computer and use it in GitHub Desktop.
Minio installer
#!/usr/bin/env bash
# Variable declarations
baseurl="https://dl.minio.io/server/minio/release/"
arch="linux-amd64"
# Or use other archs such as linux-arm, linux-arm64, darwin-amd64, windows-amd64
dlstring="$baseurl$arch/minio"
minio_user="minio-user"
minio_binary="/usr/local/bin/minio"
minio_data_dir="/usr/local/share/minio"
minio_config_dir="/etc/minio"
minio_volumes="$minio_data_dir"
# Can reference multiple mountpoints with spaces between them
minio_address=""
minio_port="9000"
# Download, verify hash, and move to /usr/local/bin
curl -O $dlstring
curl $dlstring.sha256sum | cut -d " " -f 1 | sed 's/$/ minio/' > minio.sha256sum
sha256sum -c minio.sha256sum || { echo 'Hash verification failed' ; exit 1; }
rm minio.sha256sum
sudo chmod +x minio
sudo mv minio $minio_binary
# Add minio_user, make folders and give ownership
sudo useradd -r $minio_user -s /sbin/nologin
sudo mkdir -p $minio_data_dir $minio_config_dir
sudo chown $minio_user:$minio_user $minio_binary $minio_data_dir $minio_config_dir
# Write and chown conf file
cat << EOF | sudo tee /etc/default/minio
MINIO_VOLUMES="${minio_volumes}"
MINIO_OPTS="-C ${minio_config_dir} --address ${minio_address}:${minio_port}"
EOF
sudo chown $minio_user:$minio_user /etc/default/minio
# Download service file, enable + start service, open firewall
curl https://raw.githubusercontent.com/minio/minio-service/master/linux-systemd/minio.service | sed "s/minio-user/$minio_user/g" > minio.service
sudo mv minio.service /etc/systemd/system
sudo ufw allow $minio_port
sudo systemctl restart ufw
sudo systemctl daemon-reload
sudo systemctl enable minio
sudo systemctl start minio
sudo systemctl status minio | grep 'active\|config'
echo "Access info is displayed in above line"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment