mirror of
https://github.com/MatthewL246/pretendo-docker.git
synced 2026-09-30 13:57:45 -05:00
Make the first-run scripts safe to run multiple times
This commit is contained in:
@@ -11,8 +11,12 @@ mc admin info minio
|
||||
|
||||
buckets="pn-cdn"
|
||||
|
||||
# Create buckets allow public access
|
||||
# Create buckets and allow public access
|
||||
for bucket in $buckets; do
|
||||
mc mb "minio/$bucket"
|
||||
mc anonymous set download "minio/$bucket"
|
||||
if ! mc ls "minio/$bucket"; then
|
||||
mc mb "minio/$bucket"
|
||||
mc anonymous set download "minio/$bucket"
|
||||
else
|
||||
echo "Bucket $bucket already exists. Skipping..."
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
try {
|
||||
const status = rs.status();
|
||||
if (status.hasOwnProperty("myState") && status.myState == 1) {
|
||||
print("Replica set is already initiated. Exiting...");
|
||||
quit();
|
||||
}
|
||||
} catch (error) {
|
||||
print("Replica set not initiated. Proceeding with initiation...");
|
||||
}
|
||||
|
||||
// Initiate the replica set. We need to set up the members like this because, by
|
||||
// default, the first member uses the host 127.0.0.1, which causes the other
|
||||
// servers to attempt to connect to their own loopback addresses.
|
||||
@@ -13,13 +23,13 @@ rs.initiate({
|
||||
|
||||
// Wait for the replica set to initiate
|
||||
while (rs.status().hasOwnProperty("myState") && rs.status().myState != 1) {
|
||||
console.log("Waiting for replica set to initiate...");
|
||||
console.log(rs.status());
|
||||
print("Waiting for replica set to initiate...");
|
||||
printjson(rs.status());
|
||||
sleep(1000);
|
||||
}
|
||||
|
||||
// Log replica set configuration
|
||||
console.log("Replica set configuration:");
|
||||
console.log(rs.conf());
|
||||
console.log("Replica set status:");
|
||||
console.log(rs.status());
|
||||
print("Replica set configuration:");
|
||||
printjson(rs.conf());
|
||||
print("Replica set status:");
|
||||
printjson(rs.status());
|
||||
|
||||
4
setup.sh
4
setup.sh
@@ -74,9 +74,9 @@ docker compose build
|
||||
|
||||
stage "Setting up containers with first-run scripts."
|
||||
info "Setting up MongoDB container..."
|
||||
./scripts/firstrun-mongodb-container.sh || warning "MongoDB container is already set up."
|
||||
./scripts/firstrun-mongodb-container.sh
|
||||
info "Setting up MinIO container..."
|
||||
./scripts/firstrun-minio-container.sh || warning "MinIO container is already set up."
|
||||
./scripts/firstrun-minio-container.sh
|
||||
info "Setting up Pretendo account servers database..."
|
||||
./scripts/update-account-servers-database.sh
|
||||
info "Setting up Pretendo Miiverse endpoints database..."
|
||||
|
||||
Reference in New Issue
Block a user