2020-11-28 09:02:38 +08:00
|
|
|
#!/bin/bash
|
|
|
|
##################################
|
|
|
|
echo Starting up....
|
|
|
|
echo "Startup Type: (normal/rotate)"
|
|
|
|
echo Detected $STARTUP_TYPE
|
2020-11-28 09:33:10 +08:00
|
|
|
if [ -f "keys/key.txt" ]; then
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "Key file detected..."
|
2020-11-28 09:33:10 +08:00
|
|
|
export MINIO_ACCESS_KEY=`cat keys/key.txt`
|
2020-11-28 09:02:38 +08:00
|
|
|
else
|
2020-11-28 09:33:10 +08:00
|
|
|
echo minioadmin > keys/key.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "No key file detected...Preparing First Time Boot"
|
|
|
|
fi
|
2020-11-28 09:33:10 +08:00
|
|
|
if [ -f "keys/secret.txt" ]; then
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "Secret file detected..."
|
2020-11-28 09:33:10 +08:00
|
|
|
export MINIO_SECRET_KEY=`cat keys/secret.txt`
|
2020-11-28 09:02:38 +08:00
|
|
|
else
|
2020-11-28 09:33:10 +08:00
|
|
|
echo minioadmin > keys/secret.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "No secret file detected...Preparing First Time Boot"
|
|
|
|
fi
|
2020-11-28 09:33:10 +08:00
|
|
|
if [ -f "keys/oldsecret.txt" ]; then
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "Old secret file detected..."
|
2020-11-28 09:33:10 +08:00
|
|
|
export MINIO_SECRET_KEY_OLD=`cat keys/oldsecret.txt`
|
2020-11-28 09:02:38 +08:00
|
|
|
else
|
|
|
|
echo ".."
|
|
|
|
fi
|
2020-11-28 09:33:10 +08:00
|
|
|
if [ -f "keys/oldkey.txt" ]; then
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "Old key file detected..."
|
2020-11-28 09:33:10 +08:00
|
|
|
export MINIO_ACCESS_KEY_OLD=`cat keys/oldkey.txt`
|
2020-11-28 09:02:38 +08:00
|
|
|
else
|
|
|
|
echo "......"
|
|
|
|
fi
|
2020-11-28 09:33:10 +08:00
|
|
|
if [ -f "keys/justrotated.txt" ]; then
|
2020-11-28 09:02:38 +08:00
|
|
|
echo "Previous key rotation detected...."
|
|
|
|
echo "Clearing the Lanes...."
|
|
|
|
unset MINIO_ACCESS_KEY_OLD
|
|
|
|
unset MINIO_SECRET_KEY_OLD
|
|
|
|
STARTUP_TYPE=normal
|
2020-11-28 09:33:10 +08:00
|
|
|
rm keys/justrotated.txt
|
|
|
|
rm keys/oldsecret.txt
|
|
|
|
rm keys/oldkey.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
else
|
|
|
|
echo "......"
|
|
|
|
fi
|
|
|
|
##########################################
|
|
|
|
if [ -z "$STARTUP_TYPE" ] || [ "$STARTUP_TYPE" == "rotate" ]; then
|
2020-11-28 09:33:10 +08:00
|
|
|
touch keys/justrotated.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
export MINIO_ACCESS_KEY_OLD=$MINIO_ACCESS_KEY
|
2020-11-28 09:33:10 +08:00
|
|
|
echo $MINIO_ACCESS_KEY_OLD > keys/oldkey.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
export MINIO_SECRET_KEY_OLD=$MINIO_SECRET_KEY
|
2020-11-28 09:33:10 +08:00
|
|
|
echo $MINIO_SECRET_KEY_OLD > keys/oldsecret.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
export MINIO_ACCESS_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
2020-11-28 09:33:10 +08:00
|
|
|
echo $MINIO_ACCESS_KEY > keys/key.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
export MINIO_SECRET_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
2020-11-28 09:33:10 +08:00
|
|
|
echo $MINIO_SECRET_KEY > keys/secret.txt
|
2020-11-28 09:02:38 +08:00
|
|
|
echo Your New Access Key is: $MINIO_ACCESS_KEY
|
|
|
|
echo Your New Secret Key is: $MINIO_SECRET_KEY
|
|
|
|
echo Your Old Access Key is: $MINIO_ACCESS_KEY_OLD
|
|
|
|
echo Your Old Access Key is: $MINIO_SECRET_KEY_OLD
|
|
|
|
echo Booting...
|
|
|
|
./minio server data --address 0.0.0.0:$SERVER_PORT
|
|
|
|
else
|
|
|
|
./minio server data --address 0.0.0.0:$SERVER_PORT
|
|
|
|
fi
|