Skip to content

Commit

Permalink
minio #99
Browse files Browse the repository at this point in the history
  • Loading branch information
toulousain79 committed Oct 2, 2019
1 parent cf574a0 commit f614cd0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion inc/funcs_by_script/funcs_MySB_CreateUser
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ gfnMinioUsersBuckets() {
sed -i "s/bucketname/${sUser}-${sBucket}/g;" /tmp/getonly.json
mc admin policy add mysb readonly /tmp/getonly.json

if [ -n "${sSecretKey}" ] && [ -n "${sPolicy}" ]; then
if [ -n "${sSecretKey}" ] && [ -n "${sSecretKey}" ] && [ -n "${sPolicy}" ]; then
# Create a new user
mc admin user add mysb "${sAccessKey}" "${sSecretKey}"
mc admin policy set mysb "${sPolicy}" user="${sAccessKey}"
Expand Down
29 changes: 29 additions & 0 deletions install/Minio
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ case "${gsSwitch}" in
install -v -o minio -g minio -m 0644 "${MySB_InstallDir}/ssl/mysb.key" /etc/minio/certs/private.key
install -v -o minio -g minio -m 0644 "${MySB_InstallDir}/ssl/mysb.cert" /etc/minio/certs/public.crt
fi

# Seedbox user
sUserValues="$(cmdMySQL 'MySB_db' "SELECT access_key,secret_key FROM minio WHERE id_users='999;" | sed 's/\t/|/g;')"
sAccessKey="$(echo "${sUserValues}" | awk '{split($0,a,"|"); print a[1]}')"
sSecretKey="$(echo "${sUserValues}" | awk '{split($0,a,"|"); print a[2]}')"
if [ -z "${sAccessKey}" ] && [ -z "${sSecretKey}" ]; then
sAccessKey="${sAccessKey:-$(gfnGenPassword 16)}"
sSecretKey="${sSecretKey:-$(gfnGenPassword 32)}"
cmdMySQL 'MySB_db' "INSERT INTO minio (id_users, access_key, secret_key) VALUES ('999', '${sAccessKey}', '${sSecretKey}');"
elif [ -z "${sAccessKey}" ] || [ -z "${sSecretKey}" ]; then
sAccessKey="${sAccessKey:-$(gfnGenPassword 16)}"
sSecretKey="${sSecretKey:-$(gfnGenPassword 32)}"
cmdMySQL 'MySB_db' "UPDATE minio SET access_key='${sAccessKey}',secret_key='${sSecretKey}' WHERE id_users='999';"
fi

# Create a new user with canned policy
install -v -o root -g root -m 0644 "${MySB_InstallDir}"/templates/minio/getonly.json.tmpl /tmp/getonly.json
# sed -i "s/2012-10-17/$(/bin/date '+%Y-%m-%d')/g;" /tmp/getonly.json
sed -i "s/bucketname/*-complete/g;" /tmp/getonly.json
mc admin policy add mysb readonly /tmp/getonly.json

if [ -n "${sSecretKey}" ] && [ -n "${sSecretKey}" ] && [ -n "${sPolicy}" ]; then
# Create a new user
mc admin user add mysb "${sAccessKey}" "${sSecretKey}"
mc admin policy set mysb "readonly" user="${sAccessKey}"
fi

# Group
mc admin group add mysb MySB_users "${sAccessKey}"
;;
esac

Expand Down
2 changes: 0 additions & 2 deletions templates/mysql/Schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ CREATE TABLE IF NOT EXISTS `minio` (
`id_users` int(11) NOT NULL,
`access_key` varchar(16) NOT NULL,
`secret_key` varchar(32) NOT NULL,
`bucket` varchar(32) NOT NULL,
`mountpoint` varchar(256) NOT NULL,
PRIMARY KEY (`id_minio`),
KEY `id_users` (`id_users`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Expand Down
3 changes: 3 additions & 0 deletions upgrade/MySQL.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
cmdMySQL 'MySB_db' "DROP TABLE dnscrypt_config;" -v
# dnscrypt_resolvers
cmdMySQL 'MySB_db' "DROP TABLE dnscrypt_resolvers;" -v
# minio
cmdMySQL 'MySB_db' "ALTER TABLE minio DROP COLUMN bucket;" -v 2>/dev/null
cmdMySQL 'MySB_db' "ALTER TABLE minio DROP COLUMN mountpoint;" -v 2>/dev/null
#### 1 - ALTER some tables - EoF

#### 2 - Import Schema for new tables, triggers & constraints - BoF
Expand Down

0 comments on commit f614cd0

Please sign in to comment.