Skip to content

Commit e330bf1

Browse files
authored
Merge pull request #42 from ohmydevops/main
feat/direct_run_script
2 parents ca6891a + c433794 commit e330bf1

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

README.fa.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474

7575
این اسکریپت بررسی می‌کنه که آینه‌هایی که در فایل mirrors_list.yaml تعریف شدن، واقعاً در دسترس هستند یا نه، مخصوصاً در شرایط داخل ایران.
7676

77+
### اجرای سریع
78+
79+
می‌تونید اسکریپت رو بدون کلون کردن ریپازیتوری اجرا کنید:
80+
81+
```bash
82+
curl -fsSL https://raw.githubusercontent.com/MiravaOrg/Mirava/refs/heads/main/check_mirrors.sh | bash
83+
```
84+
7785
### ویژگی‌ها:
7886

7987
- اجرای موازی برای افزایش سرعت بررسی

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ The following mirrors are well-known, actively maintained, and widely used withi
101101

102102
This script verifies whether the mirrors defined in `mirrors_list.yaml` are actually reachable, especially under Iranian network conditions.
103103

104+
### Quick Run
105+
106+
You can run the script directly without cloning the repository:
107+
108+
```bash
109+
curl -fsSL https://raw.githubusercontent.com/MiravaOrg/Mirava/refs/heads/main/check_mirrors.sh | bash
110+
```
111+
104112
### Features
105113

106114
- Parallel execution for faster checks

check_mirrors.sh

100644100755
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22
set -euo pipefail
33

44
MIRROR_FILE="./mirrors_list.yaml"
5+
MIRROR_URL="https://raw.githubusercontent.com/MiravaOrg/Mirava/refs/heads/main/mirrors_list.yaml"
6+
7+
# Check if curl is installed
8+
if ! command -v curl &> /dev/null; then
9+
echo "❌ Error: curl is not installed."
10+
echo "Please install curl first."
11+
exit 1
12+
fi
13+
14+
# Check if yq is installed
15+
if ! command -v yq &> /dev/null; then
16+
echo "❌ Error: yq is not installed."
17+
echo "Please install yq from: https://github.com/mikefarah/yq/"
18+
exit 1
19+
fi
20+
21+
# Check if mirrors_list.yaml exists, if not fetch it
22+
if [[ ! -f "$MIRROR_FILE" ]]; then
23+
echo "⚠️ mirrors_list.yaml not found. Downloading from repository..."
24+
if curl -fsSL "$MIRROR_URL" -o "$MIRROR_FILE"; then
25+
echo "✅ Successfully downloaded mirrors_list.yaml"
26+
else
27+
echo "❌ Failed to download mirrors_list.yaml"
28+
exit 1
29+
fi
30+
fi
531

632
declare -A PACKAGE_PATHS=(
733
["Ubuntu"]="ubuntu"
@@ -43,7 +69,13 @@ for idx in $(seq 0 $(yq e '.mirrors | length - 1' "$MIRROR_FILE")); do
4369

4470
for j in $(seq 0 $((package_count - 1))); do
4571
package=$(yq e ".mirrors[$idx].packages[$j]" "$MIRROR_FILE")
46-
path=${PACKAGE_PATHS[$package]:-}
72+
73+
# Safely get path with set -u enabled
74+
if [[ -v PACKAGE_PATHS["$package"] ]]; then
75+
path=${PACKAGE_PATHS["$package"]}
76+
else
77+
path=""
78+
fi
4779

4880
if [[ "$package" == "Docker Registry" ]]; then
4981
check_docker_registry "$base_url"

0 commit comments

Comments
 (0)