Skip to content

Instantly share code, notes, and snippets.

@JanHolger
Created November 20, 2020 22:40
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save JanHolger/cc72b571273b075abb0b4149d06ee9d4 to your computer and use it in GitHub Desktop.
Save JanHolger/cc72b571273b075abb0b4149d06ee9d4 to your computer and use it in GitHub Desktop.
This script will install an s3 snippet storage server for ProxMox (cicustom) using Samba and MinIO
#!/bin/bash
echo "Password for Samba User 'snippets':"
read -s smb_password_snippets
echo "Password for S3 User 'admin':"
read -s s3_password_admin
echo "Password for S3 User 'dev' (min-length: 8):"
read -s s3_password_dev
echo "Password for S3 User 'api' (min-length: 8):"
read -s s3_password_api
wget -O /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x /usr/local/bin/minio
wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x /usr/local/bin/mc
apt-get install -y samba
cat << 'EOF' > /etc/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
WorkingDirectory=/usr/local/
User=snippets
Group=snippets
EnvironmentFile=/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
EOF
cat << EOF > /etc/default/minio
# Volume to be used for MinIO server.
MINIO_VOLUMES="/home/snippets"
# Use if you want to run MinIO on a custom port.
MINIO_OPTS="--address :80"
# Access Key of the server.
MINIO_ACCESS_KEY=admin
# Secret key of the server.
MINIO_SECRET_KEY="${s3_password_admin}"
EOF
cat << EOF > /etc/samba/smb.conf
[global]
workgroup = snippets
server string = %h server (Samba %v)
log file = /var/log/samba/log.%m
max log size = 1000
encrypt passwords = true
invalid users = root
socket options = TCP_NODELAY
security = user
unix extensions = yes
[homes]
comment = Home Directories
browseable = no
valid users = %S
writable = yes
create mode = 0600
directory mode = 0700
EOF
mkdir /root/.mc
cat << EOF > /root/.mc/config.json
{
"version": "10",
"aliases": {
"local": {
"url": "http://localhost:80",
"accessKey": "admin",
"secretKey": "${s3_password_admin}",
"api": "S3v4",
"path": "auto"
}
}
}
EOF
adduser snippets --gecos "" --disabled-password
echo -ne "${smb_password_snippets}\n${smb_password_snippets}\n" | smbpasswd -a -s snippets
mkdir /home/snippets/snippets
chown snippets:snippets /home/snippets/snippets
systemctl restart smbd
systemctl enable minio
systemctl start minio
mc admin user add local dev ${s3_password_dev}
mc admin user add local api ${s3_password_api}
mc admin policy set local readwrite user=dev
mc admin policy set local readwrite user=api
clear
echo "Installation done!"
@Dogg1984
Copy link

on Twitter to stay updated on everything we ship.

→ ~ cd github-changelog
→ ~/github-changelog|main git log main
showing all changes successfully @

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment