22
33# Matthew Hutchinson <mhutchinson@45drives.com>
44
5+ if [ $EUID -ne 0 ]; then echo " Must be run as root!" >&2 exit 2 fi
56
67set -e
78
@@ -21,46 +22,46 @@ OS=$(cat /etc/os-release | grep -w NAME)
2122# Update system
2223echo " [1/10] Updating system..."
2324if [ " $OS " == ' NAME="Ubuntu"' ]; then
24- sudo apt update && sudo apt upgrade -y
25+ apt update && apt upgrade -y
2526 PM=apt
2627elif [ " $OS " == ' NAME="Rocky Linux"' ]; then
27- sudo dnf update -y
28+ dnf update -y
2829 PM=dnf
2930else
3031 echo " Unsupported package manager. Please use a system with DNF or APT."
3132 exit 1
3233fi
3334
3435echo " [2/10] Creating minio user..."
35- sudo useradd -r minio-user -s /sbin/nologin || echo " User already exists."
36+ useradd -r minio-user -s /sbin/nologin || echo " User already exists."
3637
3738echo " [3/10] Installing wget..."
38- sudo $PM install -y wget
39+ $PM install -y wget
3940
4041echo " [4/10] Downloading and setting up MinIO binary..."
41- sudo wget https://dl.min.io/community/server/minio/release/linux-amd64/archive/minio.RELEASE.2025-04-22T22-12-26Z -O /usr/local/bin/minio
42- sudo chmod +x /usr/local/bin/minio
42+ wget https://dl.min.io/community/server/minio/release/linux-amd64/archive/minio.RELEASE.2025-04-22T22-12-26Z -O /usr/local/bin/minio
43+ chmod +x /usr/local/bin/minio
4344
4445echo " [5/10] Creating ZFS filesystem ${POOL_NAME} /minio..."
4546
4647# Ensure pool exists
47- if ! sudo zpool list -H -o name | grep -qx " ${POOL_NAME} " ; then
48+ if ! zpool list -H -o name | grep -qx " ${POOL_NAME} " ; then
4849 echo " ERROR: ZFS pool '${POOL_NAME} ' not found. Pools available:"
49- sudo zpool list
50+ zpool list
5051 exit 1
5152fi
5253
5354DATASET=" ${POOL_NAME} /minio"
5455
5556# Existence check with timeout so it cannot "stick"
56- if timeout 10s sudo zfs list -H -o name " $DATASET " > /dev/null 2>&1 ; then
57+ if timeout 10s zfs list -H -o name " $DATASET " > /dev/null 2>&1 ; then
5758 echo " WARNING: The ZFS dataset $DATASET already exists."
5859 read -p " Do you want to delete and recreate it? This will erase all data in it. (y/n): " RECREATE
5960 if [[ " $RECREATE " == " y" ]]; then
6061 echo " Destroying existing dataset $DATASET ..."
61- sudo zfs destroy -r " $DATASET "
62+ zfs destroy -r " $DATASET "
6263 echo " Creating new dataset $DATASET ..."
63- sudo zfs create -o recordsize=1M -o atime=off -o xattr=sa -o compression=lz4 " $DATASET "
64+ zfs create -o recordsize=1M -o atime=off -o xattr=sa -o compression=lz4 " $DATASET "
6465 elif [[ " $RECREATE " == " n" ]]; then
6566 read -p " Do you want to deploy on top of existing data? (y/n): " REUSE
6667 if [[ " $REUSE " != " y" ]]; then
7576 rc=$?
7677 if [ " $rc " -eq 124 ]; then
7778 echo " ERROR: ZFS command timed out. ZFS may be unhealthy or blocked."
78- echo " Try: sudo zpool status ; sudo dmesg -T | tail -n 200 | grep -i zfs"
79+ echo " Try: zpool status ; dmesg -T | tail -n 200 | grep -i zfs"
7980 exit 1
8081 fi
8182 echo " Creating new dataset $DATASET ..."
82- sudo zfs create -o recordsize=1M -o atime=off -o xattr=sa -o compression=lz4 " $DATASET "
83+ zfs create -o recordsize=1M -o atime=off -o xattr=sa -o compression=lz4 " $DATASET "
8384fi
8485
8586
86-
87-
88-
8987echo " [6/10] Setting ownership for ZFS mount..."
90- sudo chown -R minio-user:minio-user /${POOL_NAME} /minio/
88+ chown -R minio-user:minio-user /${POOL_NAME} /minio/
9189
9290echo " [7/10] Creating and setting permissions for config directories..."
93- sudo mkdir -p /etc/minio/certs
94- sudo touch /etc/minio/credentials
95- sudo chown -R minio-user:minio-user /etc/minio/
96- sudo chmod 600 /etc/minio/credentials
91+ mkdir -p /etc/minio/certs
92+ touch /etc/minio/credentials
93+ chown -R minio-user:minio-user /etc/minio/
94+ chmod 600 /etc/minio/credentials
9795
9896echo " [8/10] Creating default config at /etc/default/minio..."
99- sudo bash -c " cat > /etc/default/minio" << EOF
97+ bash -c " cat > /etc/default/minio" << EOF
10098# MinIO Configuration
10199MINIO_VOLUMES="/${POOL_NAME} /minio/"
102100MINIO_ACCESS_KEY="${ACCESS_KEY} "
@@ -105,33 +103,33 @@ MINIO_CERTS_DIR="/etc/minio/certs"
105103EOF
106104
107105echo " [9/10] Creating credentials file..."
108- sudo bash -c " cat > /etc/minio/credentials" << EOF
106+ bash -c " cat > /etc/minio/credentials" << EOF
109107MINIO_ROOT_USER=${MINIO_USER}
110108MINIO_ROOT_PASSWORD=${MINIO_PASSWORD}
111109EOF
112110
113111echo " [10/10] Setting firewall rule for port 7575..."
114112if command -v firewall-cmd & > /dev/null; then
115- sudo firewall-cmd --zone=public --add-port=7575/tcp --permanent || true
116- sudo firewall-cmd --reload || true
113+ firewall-cmd --zone=public --add-port=7575/tcp --permanent || true
114+ firewall-cmd --reload || true
117115else
118116 echo " firewalld not found, skipping firewall configuration."
119117fi
120118
121119read -p " Do you want to create self-signed HTTPS certs? (y/n): " USE_SSL
122120if [[ " $USE_SSL " == " y" ]]; then
123121 echo " Installing OpenSSL and generating certs..."
124- sudo $PM install -y openssl
125- sudo openssl genrsa -out /etc/minio/certs/private.key 2048
126- sudo openssl req -new -x509 -key /etc/minio/certs/private.key -out /etc/minio/certs/public.crt -days 3650
127- sudo chown -R minio-user:minio-user /etc/minio/certs
128- sudo chmod 600 /etc/minio/certs/private.key
122+ $PM install -y openssl
123+ openssl genrsa -out /etc/minio/certs/private.key 2048
124+ openssl req -new -x509 -key /etc/minio/certs/private.key -out /etc/minio/certs/public.crt -days 3650
125+ chown -R minio-user:minio-user /etc/minio/certs
126+ chmod 600 /etc/minio/certs/private.key
129127else
130128echo -e " \033[1;36mPlace SSL certs in \" /etc/minio/certs\" for custom certificates\033[0m"
131129fi
132130
133131echo " Creating systemd service for MinIO..."
134- sudo bash -c " cat > /etc/systemd/system/minio.service" << 'EOF '
132+ bash -c " cat > /etc/systemd/system/minio.service" << 'EOF '
135133[Unit]
136134Description=MinIO
137135Documentation=https://docs.min.io
@@ -166,13 +164,13 @@ EOF
166164
167165
168166echo " Enabling and starting MinIO service..."
169- sudo systemctl daemon-reload
170- sudo systemctl enable --now minio
167+ systemctl daemon-reload
168+ systemctl enable --now minio
171169
172170echo " Installing MinIO client (mc)..."
173- sudo $PM install -y curl
174- sudo curl -fL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
175- sudo chmod +x /usr/local/bin/mc
171+ $PM install -y curl
172+ curl -fL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
173+ chmod +x /usr/local/bin/mc
176174
177175MC_BIN=" /usr/local/bin/mc"
178176if [[ ! -x " $MC_BIN " ]]; then
@@ -189,11 +187,11 @@ if [[ -f /etc/minio/certs/public.crt ]]; then
189187
190188 echo " Trusting MinIO certificate (self-signed)..."
191189 if [[ " $OS " == ' NAME="Rocky Linux"' ]]; then
192- sudo cp /etc/minio/certs/public.crt /etc/pki/ca-trust/source/anchors/minio.crt
193- sudo update-ca-trust
190+ cp /etc/minio/certs/public.crt /etc/pki/ca-trust/source/anchors/minio.crt
191+ update-ca-trust
194192 elif [[ " $OS " == ' NAME="Ubuntu"' ]]; then
195- sudo cp /etc/minio/certs/public.crt /usr/local/share/ca-certificates/minio.crt
196- sudo update-ca-certificates
193+ cp /etc/minio/certs/public.crt /usr/local/share/ca-certificates/minio.crt
194+ update-ca-certificates
197195 fi
198196fi
199197
0 commit comments