Skip to content

Commit 2a62680

Browse files
committed
feat: check existing config file in upgrading process
1 parent 2a18b64 commit 2a62680

1 file changed

Lines changed: 36 additions & 34 deletions

File tree

automated_deploy.sh

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -148,49 +148,51 @@ fi
148148
# Get the directory of the script
149149
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
150150

151-
# Check if config.yaml exists in the script's directory and run Deployer if it does
152-
if [ -f "$SCRIPT_DIR/config.yaml" ]; then
151+
# Check if config.yaml exists in the script's directory or in the config folder
152+
if [ -f "$SCRIPT_DIR/config/config.yaml" ]; then
153+
echo "⚙️ config.yaml found in the config folder. use existing config file."
154+
elif [ -f "$SCRIPT_DIR/config.yaml" ]; then
153155
echo "⚙️ config.yaml found in the script's directory, moving it to config folder..."
154-
155156
mkdir -p "$SCRIPT_DIR/config"
156157
mv "$SCRIPT_DIR/config.yaml" "$SCRIPT_DIR/config/config.yaml"
157158
echo "⚠️ DO NOT DELETE/MOVE THE config FOLDER OR ITS CONTENTS!"
159+
else
160+
echo "⚠️ config.yaml not found, please create a config.yaml file or generate one at https://explorer.rss3.io."
161+
exit 1
162+
fi
158163

159-
# Check for existing services
160-
if $COMPOSE_CMD ps | grep -q "Up"; then
161-
echo "🔄 Existing node services detected. This is an upgrade process."
162-
echo "⏬ Stopping existing services..."
163-
$COMPOSE_CMD down
164-
if [ $? -ne 0 ]; then
165-
echo "❌ Failed to stop existing services."
166-
exit 1
167-
fi
168-
echo "✅ Existing services stopped successfully."
169-
else
170-
echo "🆕 No existing services detected. This is a new node deployment."
164+
# Check for existing services
165+
if $COMPOSE_CMD ps | grep -q "Up"; then
166+
echo "🔄 Existing node services detected. This is an upgrade process."
167+
echo "⏬ Stopping existing services..."
168+
$COMPOSE_CMD down
169+
if [ $? -ne 0 ]; then
170+
echo "❌ Failed to stop existing services."
171+
exit 1
171172
fi
173+
echo "✅ Existing services stopped successfully."
174+
else
175+
echo "🆕 No existing services detected. This is a new node deployment."
176+
fi
172177

173-
export NODE_VERSION
174-
echo "🚀 Running the deployer..."
175-
"$SCRIPT_DIR/node-automated-deployer" > "$SCRIPT_DIR/docker-compose.yaml"
176-
177-
# Check if docker-compose.yaml was successfully created
178-
if [ -f "$SCRIPT_DIR/docker-compose.yaml" ]; then
179-
echo "ℹ️ docker-compose.yaml created, starting Docker Compose..."
180-
(cd "$SCRIPT_DIR" && $COMPOSE_CMD up -d)
181-
182-
# Check if Docker Compose started successfully
183-
if [ $? -eq 0 ]; then
184-
echo "✅ Deployment process completed successfully."
185-
echo "🎉 Welcome to the RSS3 Network!"
186-
else
187-
echo "❌ Failed to start Docker Compose."
188-
exit 1
189-
fi
178+
export NODE_VERSION
179+
echo "🚀 Running the deployer..."
180+
"$SCRIPT_DIR/node-automated-deployer" > "$SCRIPT_DIR/docker-compose.yaml"
181+
182+
# Check if docker-compose.yaml was successfully created
183+
if [ -f "$SCRIPT_DIR/docker-compose.yaml" ]; then
184+
echo "ℹ️ docker-compose.yaml created, starting Docker Compose..."
185+
(cd "$SCRIPT_DIR" && $COMPOSE_CMD up -d)
186+
187+
# Check if Docker Compose started successfully
188+
if [ $? -eq 0 ]; then
189+
echo "✅ Deployment process completed successfully."
190+
echo "🎉 Welcome to the RSS3 Network!"
190191
else
191-
echo "❌ Failed to create docker-compose.yaml."
192+
echo "❌ Failed to start Docker Compose."
192193
exit 1
193194
fi
194195
else
195-
echo "⚠️ config.yaml not found, please create a config.yaml file or generate one at https://explorer.rss3.io."
196+
echo "❌ Failed to create docker-compose.yaml."
197+
exit 1
196198
fi

0 commit comments

Comments
 (0)