Forked from JanHolger/install-proxmox-s3-snippet-storage.sh
Created
March 11, 2021 14:08
-
-
Save bilalinamdar/56ac3b18da72fe24f154f482abde2c77 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
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 | |
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!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment