2025-05-30 23:28:48 -03:00
|
|
|
#!/bin/bash
|
2025-06-01 17:08:15 -03:00
|
|
|
|
|
|
|
DATA_PATH="/opt/gbo/tenants/$PARAM_TENANT/drive/data"
|
2025-05-30 23:28:48 -03:00
|
|
|
LOGS_PATH="/opt/gbo/tenants/$PARAM_TENANT/drive/logs"
|
|
|
|
|
2025-06-01 17:08:15 -03:00
|
|
|
mkdir -p "${DATA_PATH}" "${LOGS_PATH}"
|
|
|
|
chmod -R 770 "${DATA_PATH}" "${LOGS_PATH}"
|
|
|
|
chown -R 100999:100999 "${DATA_PATH}" "${LOGS_PATH}"
|
2025-05-30 23:28:48 -03:00
|
|
|
|
|
|
|
lxc launch images:debian/12 "${PARAM_TENANT}-drive" -c security.privileged=true
|
|
|
|
sleep 15
|
|
|
|
|
2025-06-01 17:08:15 -03:00
|
|
|
lxc config device add "${PARAM_TENANT}-drive" storage disk source="${DATA_PATH}" path=/opt/gbo/data
|
|
|
|
lxc config device add "${PARAM_TENANT}-drive" logs disk source="${LOGS_PATH}" path=/opt/gbo/logs
|
2025-05-30 23:28:48 -03:00
|
|
|
|
|
|
|
lxc exec "${PARAM_TENANT}-drive" -- bash -c '
|
|
|
|
|
2025-06-01 17:08:15 -03:00
|
|
|
mkdir -p /opt/gbo/logs /opt/gbo/data /opt/gbo/bin
|
|
|
|
useradd -r -s /bin/false gbuser || true
|
|
|
|
chown -R gbuser:gbuser /opt/gbo/logs /opt/gbo/data
|
|
|
|
|
|
|
|
apt-get update && apt-get install -y wget
|
|
|
|
wget https://dl.min.io/server/minio/release/linux-amd64/minio -O /opt/gbo/bin/minio
|
|
|
|
chmod +x /opt/gbo/bin/minio
|
2025-05-30 23:28:48 -03:00
|
|
|
|
2025-06-01 17:08:15 -03:00
|
|
|
cat > /etc/systemd/system/drive.service <<EOF
|
2025-05-30 23:28:48 -03:00
|
|
|
[Unit]
|
2025-06-01 17:08:15 -03:00
|
|
|
Description=drive
|
2025-05-30 23:28:48 -03:00
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
2025-06-01 17:08:15 -03:00
|
|
|
User=gbuser
|
|
|
|
Group=gbuser
|
2025-05-31 14:00:12 -03:00
|
|
|
Environment="MINIO_ROOT_USER='"${PARAM_DRIVE_USER}"'"
|
|
|
|
Environment="MINIO_ROOT_PASSWORD='"${PARAM_DRIVE_PASSWORD}"'"
|
2025-06-01 17:08:15 -03:00
|
|
|
ExecStart=/opt/gbo/bin/minio server --console-address ":'"${PARAM_DRIVE_PORT}"'" /opt/gbo/data
|
|
|
|
StandardOutput=append:/opt/gbo/logs/output.log
|
|
|
|
StandardError=append:/opt/gbo/logs/error.log
|
2025-05-30 23:28:48 -03:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
2025-06-01 17:08:15 -03:00
|
|
|
systemctl enable drive
|
|
|
|
systemctl start drive
|
2025-05-30 23:28:48 -03:00
|
|
|
'
|
|
|
|
|
2025-06-01 17:08:15 -03:00
|
|
|
lxc config device remove "${PARAM_TENANT}-drive" drive-proxy 2>/dev/null || true
|
|
|
|
lxc config device add "${PARAM_TENANT}-drive" drive-proxy proxy \
|
2025-05-31 14:00:12 -03:00
|
|
|
listen=tcp:0.0.0.0:"${PARAM_DRIVE_API_PORT}" \
|
|
|
|
connect=tcp:127.0.0.1:"${PARAM_DRIVE_API_PORT}"
|
2025-05-30 23:28:48 -03:00
|
|
|
|
|
|
|
lxc config device remove "${PARAM_TENANT}-drive" console-proxy 2>/dev/null || true
|
|
|
|
lxc config device add "${PARAM_TENANT}-drive" console-proxy proxy \
|
2025-05-31 14:00:12 -03:00
|
|
|
listen=tcp:0.0.0.0:"${PARAM_DRIVE_PORT}" \
|
|
|
|
connect=tcp:127.0.0.1:"${PARAM_DRIVE_PORT}"
|