github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/buildscripts/disable-root.sh (about)

     1  #!/bin/bash
     2  
     3  set -x
     4  
     5  export MINIO_CI_CD=1
     6  killall -9 minio
     7  
     8  rm -rf ${HOME}/tmp/dist
     9  
    10  scheme="http"
    11  nr_servers=4
    12  
    13  addr="localhost"
    14  args=""
    15  for ((i = 0; i < $((nr_servers)); i++)); do
    16  	args="$args $scheme://$addr:$((9100 + i))/${HOME}/tmp/dist/path1/$i"
    17  done
    18  
    19  echo $args
    20  
    21  for ((i = 0; i < $((nr_servers)); i++)); do
    22  	(minio server --address ":$((9100 + i))" $args 2>&1 >/tmp/log$i.txt) &
    23  done
    24  
    25  sleep 10s
    26  
    27  if [ ! -f ./mc ]; then
    28  	wget --quiet -O ./mc https://dl.minio.io/client/mc/release/linux-amd64/./mc &&
    29  		chmod +x mc
    30  fi
    31  
    32  set +e
    33  
    34  export MC_HOST_minioadm=http://minioadmin:minioadmin@localhost:9100/
    35  
    36  ./mc ls minioadm/
    37  
    38  ./mc admin config set minioadm/ api root_access=off
    39  
    40  sleep 3s # let things settle a little
    41  
    42  ./mc ls minioadm/
    43  if [ $? -eq 0 ]; then
    44  	echo "listing succeeded, 'minioadmin' was not disabled"
    45  	exit 1
    46  fi
    47  
    48  set -e
    49  
    50  killall -9 minio
    51  
    52  export MINIO_API_ROOT_ACCESS=on
    53  for ((i = 0; i < $((nr_servers)); i++)); do
    54  	(minio server --address ":$((9100 + i))" $args 2>&1 >/tmp/log$i.txt) &
    55  done
    56  
    57  set +e
    58  
    59  sleep 10
    60  
    61  ./mc ls minioadm/
    62  if [ $? -ne 0 ]; then
    63  	echo "listing failed, 'minioadmin' should be enabled"
    64  	exit 1
    65  fi
    66  
    67  killall -9 minio
    68  
    69  rm -rf /tmp/multisitea/
    70  rm -rf /tmp/multisiteb/
    71  
    72  echo "Setup site-replication and then disable root credentials"
    73  
    74  minio server --address 127.0.0.1:9001 "http://127.0.0.1:9001/tmp/multisitea/data/disterasure/xl{1...4}" \
    75  	"http://127.0.0.1:9002/tmp/multisitea/data/disterasure/xl{5...8}" >/tmp/sitea_1.log 2>&1 &
    76  minio server --address 127.0.0.1:9002 "http://127.0.0.1:9001/tmp/multisitea/data/disterasure/xl{1...4}" \
    77  	"http://127.0.0.1:9002/tmp/multisitea/data/disterasure/xl{5...8}" >/tmp/sitea_2.log 2>&1 &
    78  
    79  minio server --address 127.0.0.1:9003 "http://127.0.0.1:9003/tmp/multisiteb/data/disterasure/xl{1...4}" \
    80  	"http://127.0.0.1:9004/tmp/multisiteb/data/disterasure/xl{5...8}" >/tmp/siteb_1.log 2>&1 &
    81  minio server --address 127.0.0.1:9004 "http://127.0.0.1:9003/tmp/multisiteb/data/disterasure/xl{1...4}" \
    82  	"http://127.0.0.1:9004/tmp/multisiteb/data/disterasure/xl{5...8}" >/tmp/siteb_2.log 2>&1 &
    83  
    84  sleep 20s
    85  
    86  export MC_HOST_sitea=http://minioadmin:minioadmin@127.0.0.1:9001
    87  export MC_HOST_siteb=http://minioadmin:minioadmin@127.0.0.1:9004
    88  
    89  ./mc admin replicate add sitea siteb
    90  
    91  ./mc admin user add sitea foobar foo12345
    92  
    93  ./mc admin policy attach sitea/ consoleAdmin --user=foobar
    94  
    95  ./mc admin user info siteb foobar
    96  
    97  killall -9 minio
    98  
    99  echo "turning off root access, however site replication must continue"
   100  export MINIO_API_ROOT_ACCESS=off
   101  
   102  minio server --address 127.0.0.1:9001 "http://127.0.0.1:9001/tmp/multisitea/data/disterasure/xl{1...4}" \
   103  	"http://127.0.0.1:9002/tmp/multisitea/data/disterasure/xl{5...8}" >/tmp/sitea_1.log 2>&1 &
   104  minio server --address 127.0.0.1:9002 "http://127.0.0.1:9001/tmp/multisitea/data/disterasure/xl{1...4}" \
   105  	"http://127.0.0.1:9002/tmp/multisitea/data/disterasure/xl{5...8}" >/tmp/sitea_2.log 2>&1 &
   106  
   107  minio server --address 127.0.0.1:9003 "http://127.0.0.1:9003/tmp/multisiteb/data/disterasure/xl{1...4}" \
   108  	"http://127.0.0.1:9004/tmp/multisiteb/data/disterasure/xl{5...8}" >/tmp/siteb_1.log 2>&1 &
   109  minio server --address 127.0.0.1:9004 "http://127.0.0.1:9003/tmp/multisiteb/data/disterasure/xl{1...4}" \
   110  	"http://127.0.0.1:9004/tmp/multisiteb/data/disterasure/xl{5...8}" >/tmp/siteb_2.log 2>&1 &
   111  
   112  sleep 20s
   113  
   114  export MC_HOST_sitea=http://foobar:foo12345@127.0.0.1:9001
   115  export MC_HOST_siteb=http://foobar:foo12345@127.0.0.1:9004
   116  
   117  ./mc admin user add sitea foobar-admin foo12345
   118  
   119  sleep 2s
   120  
   121  ./mc admin user info siteb foobar-admin