feat(goose): optimize init status

This commit is contained in:
2025-03-25 23:06:57 +01:00
parent a50336487a
commit 909ba03a7a

View File

@@ -1,25 +1,13 @@
#!/bin/bash #!/bin/bash
# Script to check and display initialization status # Script to check and display initialization status - optimized version
# Function to display initialization logs # Quick check instead of full logic
show_init_logs() { if grep -q "INIT_COMPLETE=true" "/init.status" 2>/dev/null; then
echo "MC initialization has completed."
else
echo "MC initialization is still in progress."
# Only follow logs if initialization is incomplete
if [ -f "/init.log" ]; then if [ -f "/init.log" ]; then
echo "Displaying initialization logs:"
echo "----------------------------------------"
cat /init.log
echo "----------------------------------------"
else
echo "No initialization logs found."
fi
}
# Function to follow logs until initialization completes
follow_init_logs() {
if [ ! -f "/init.log" ]; then
echo "No initialization logs found."
return
fi
echo "Initialization is still in progress. Showing logs:" echo "Initialization is still in progress. Showing logs:"
echo "----------------------------------------" echo "----------------------------------------"
tail -f /init.log & tail -f /init.log &
@@ -27,7 +15,7 @@ follow_init_logs() {
# Check every second if initialization has completed # Check every second if initialization has completed
while true; do while true; do
if [ -f "/init.status" ] && grep -q "INIT_COMPLETE=true" "/init.status"; then if grep -q "INIT_COMPLETE=true" "/init.status" 2>/dev/null; then
kill $tail_pid 2>/dev/null kill $tail_pid 2>/dev/null
echo "----------------------------------------" echo "----------------------------------------"
echo "Initialization completed." echo "Initialization completed."
@@ -35,31 +23,7 @@ follow_init_logs() {
fi fi
sleep 1 sleep 1
done done
}
# Check if we're in an interactive shell
if [ -t 0 ]; then
INTERACTIVE=true
else
INTERACTIVE=false
fi
# Check initialization status
if [ -f "/init.status" ]; then
if grep -q "INIT_COMPLETE=true" "/init.status"; then
echo "MC initialization has completed."
# No longer prompt to show logs when initialization is complete
else else
echo "MC initialization is still in progress." echo "No initialization logs found."
follow_init_logs
fi
else
echo "Cannot determine initialization status."
# Ask if user wants to see logs if they exist (only in interactive mode)
if [ -f "/init.log" ] && [ "$INTERACTIVE" = true ]; then
read -p "Do you want to see initialization logs? (y/n): " show_logs
if [[ "$show_logs" =~ ^[Yy] ]]; then
show_init_logs
fi
fi fi
fi fi