2020-11-28 10:32:54 +08:00
|
|
|
#!/bin/bash
|
|
|
|
##################################
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 2)Starting up...."
|
|
|
|
echo "Startup Type: $(tput setaf 2)$STARTUP_TYPE"
|
2020-11-28 10:32:54 +08:00
|
|
|
if [ -f "keys/key.txt" ]; then
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 2)Key file detected..."
|
2021-08-09 08:51:15 +08:00
|
|
|
export MINIO_ROOT_USER=`cat keys/key.txt`
|
2020-11-28 10:32:54 +08:00
|
|
|
else
|
|
|
|
echo minioadmin > keys/key.txt
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 3)No key file detected...Preparing First Time Boot"
|
2020-11-28 10:32:54 +08:00
|
|
|
fi
|
|
|
|
if [ -f "keys/secret.txt" ]; then
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 2)Secret file detected..."
|
2021-08-09 08:51:15 +08:00
|
|
|
export MINIO_ROOT_PASSWORD=`cat keys/secret.txt`
|
2020-11-28 10:32:54 +08:00
|
|
|
else
|
|
|
|
echo minioadmin > keys/secret.txt
|
|
|
|
echo "No secret file detected...Preparing First Time Boot"
|
|
|
|
fi
|
|
|
|
if [ -f "keys/oldsecret.txt" ]; then
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 1)Old secret file detected..."
|
2021-08-09 08:51:15 +08:00
|
|
|
export MINIO_ROOT_PASSWORD_OLD=`cat keys/oldsecret.txt`
|
2020-11-28 10:32:54 +08:00
|
|
|
fi
|
|
|
|
if [ -f "keys/oldkey.txt" ]; then
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 1)Old key file detected..."
|
2021-08-09 08:51:15 +08:00
|
|
|
export MINIO_ROOT_USER_OLD=`cat keys/oldkey.txt`
|
2020-11-28 10:32:54 +08:00
|
|
|
fi
|
|
|
|
if [ -f "keys/justrotated.txt" ]; then
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 3)Previous key rotation detected...."
|
|
|
|
echo "$(tput setaf 3)Clearing the Lanes...."
|
2021-08-09 08:51:15 +08:00
|
|
|
unset MINIO_ROOT_USER_OLD
|
|
|
|
unset MINIO_ROOT_PASSWORD_OLD
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 2)Lanes Cleared!"
|
2020-11-28 10:32:54 +08:00
|
|
|
STARTUP_TYPE=normal
|
|
|
|
rm keys/justrotated.txt
|
|
|
|
rm keys/oldsecret.txt
|
|
|
|
rm keys/oldkey.txt
|
|
|
|
fi
|
2021-01-12 04:32:15 +08:00
|
|
|
|
|
|
|
##########################################
|
|
|
|
if [ -z "$STARTUP_TYPE" ] || [ "$STARTUP_TYPE" == "update" ]; then
|
|
|
|
echo "$(tput setaf 3)Performing update...."
|
|
|
|
echo "$(tput setaf 1)Removing old minio version"
|
|
|
|
rm minio
|
|
|
|
echo "$(tput setaf 3)Downloading new minio version"
|
|
|
|
wget https://dl.min.io/server/minio/release/linux-amd64/minio
|
|
|
|
chmod +x minio
|
|
|
|
echo "$(tput setaf 2)Update Complete"
|
|
|
|
fi
|
2020-11-28 10:32:54 +08:00
|
|
|
##########################################
|
|
|
|
if [ -z "$STARTUP_TYPE" ] || [ "$STARTUP_TYPE" == "rotate" ]; then
|
|
|
|
touch keys/justrotated.txt
|
2021-08-09 08:51:15 +08:00
|
|
|
export MINIO_ROOT_USER_OLD=$MINIO_ROOT_USER
|
|
|
|
echo $MINIO_ROOT_USER_OLD > keys/oldkey.txt
|
|
|
|
export MINIO_ROOT_PASSWORD_OLD=$MINIO_ROOT_PASSWORD
|
|
|
|
echo $MINIO_ROOT_PASSWORD_OLD > keys/oldsecret.txt
|
|
|
|
export MINIO_ROOT_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
|
|
|
echo $MINIO_ROOT_USER > keys/key.txt
|
|
|
|
export MINIO_ROOT_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
|
|
|
echo $MINIO_ROOT_PASSWORD > keys/secret.txt
|
|
|
|
echo "Your New Access Key is: $(tput setaf 2)$MINIO_ROOT_USER"
|
|
|
|
echo "Your New Secret Key is: $(tput setaf 2)$MINIO_ROOT_PASSWORD"
|
|
|
|
echo "Your Old Access Key is: $(tput setaf 3)$MINIO_ROOT_USER_OLD"
|
|
|
|
echo "Your Old Access Key is: $(tput setaf 3)$MINIO_ROOT_PASSWORD_OLD"
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 2)Booting..."
|
2021-08-09 08:51:15 +08:00
|
|
|
./minio server data --console-address ":$SERVER_PORT"
|
2020-11-28 10:32:54 +08:00
|
|
|
else
|
2021-01-12 04:32:15 +08:00
|
|
|
echo "$(tput setaf 2)Booting..."
|
2021-08-09 08:51:15 +08:00
|
|
|
./minio server data --console-address ":$SERVER_PORT"
|
2020-11-28 10:32:54 +08:00
|
|
|
fi
|