Adding some comments and echo for -sh

This commit is contained in:
root
2025-11-07 22:02:48 +00:00
parent 389f5b1046
commit a61236ff13

View File

@@ -295,32 +295,41 @@ create_host() {
_build_hosts_file() { _build_hosts_file() {
out="$1" out="$1"
if [ "$out" = "-" ]; then if [ "$out" = "-" ]; then
echo "# --- localhost generate ---#"
printf "127.0.0.1" printf "127.0.0.1"
refresh_arrays refresh_arrays
for a in "${alias_names[@]}"; do for a in "${alias_names[@]}"; do
printf " %s" "$a" printf " %s" "$a"
done done
printf "\n\n" printf "\n\n"
echo "# --- main not dynamic part --- #"
[ -f "$MAINFOLD/main.conf" ] && sed -n '1,200p' "$MAINFOLD/main.conf" && printf "\n" [ -f "$MAINFOLD/main.conf" ] && sed -n '1,200p' "$MAINFOLD/main.conf" && printf "\n"
refresh_arrays refresh_arrays
echo "# --- dynamic hosts --- #"
for en in "${en_files[@]}"; do for en in "${en_files[@]}"; do
[ -f "$ENFOLD/$en.conf" ] && sed -n '1,500p' "$ENFOLD/$en.conf" && printf "\n" [ -f "$ENFOLD/$en.conf" ] && sed -n '1,500p' "$ENFOLD/$en.conf" && printf "\n"
done done
echo "# --- end part ---#"
[ -f "$MAINFOLD/endfile.conf" ] && sed -n '1,200p' "$MAINFOLD/endfile.conf" && printf "\n" [ -f "$MAINFOLD/endfile.conf" ] && sed -n '1,200p' "$MAINFOLD/endfile.conf" && printf "\n"
else else
tmp="$out" tmp="$out"
: > "$tmp" : > "$tmp"
echo "# --- localhost generate ---#" >> $tmp
printf "127.0.0.1" >> "$tmp" printf "127.0.0.1" >> "$tmp"
refresh_arrays refresh_arrays
for a in "${alias_names[@]}"; do for a in "${alias_names[@]}"; do
printf " %s" "$a" >> "$tmp" printf " %s" "$a" >> "$tmp"
done done
printf "\n\n" >> "$tmp" printf "\n\n" >> "$tmp"
echo "# --- main not dynamic part --- #" >> $tmp
[ -f "$MAINFOLD/main.conf" ] && sed -n '1,200p' "$MAINFOLD/main.conf" >> "$tmp" && printf "\n" >> "$tmp" [ -f "$MAINFOLD/main.conf" ] && sed -n '1,200p' "$MAINFOLD/main.conf" >> "$tmp" && printf "\n" >> "$tmp"
refresh_arrays refresh_arrays
echo "# --- dynamic hosts --- #" >> $tmp
for en in "${en_files[@]}"; do for en in "${en_files[@]}"; do
[ -f "$ENFOLD/$en.conf" ] && sed -n '1,500p' "$ENFOLD/$en.conf" >> "$tmp" && printf "\n" >> "$tmp" [ -f "$ENFOLD/$en.conf" ] && sed -n '1,500p' "$ENFOLD/$en.conf" >> "$tmp" && printf "\n" >> "$tmp"
done done
echo "# --- end part ---#" >> $tmp
[ -f "$MAINFOLD/endfile.conf" ] && sed -n '1,200p' "$MAINFOLD/endfile.conf" >> "$tmp" && printf "\n" >> "$tmp" [ -f "$MAINFOLD/endfile.conf" ] && sed -n '1,200p' "$MAINFOLD/endfile.conf" >> "$tmp" && printf "\n" >> "$tmp"
fi fi
} }
@@ -342,7 +351,9 @@ regenerate_hosts() {
} }
simulate_hosts() { simulate_hosts() {
echo "###### HOST SIMULATION ######"
_build_hosts_file "-" _build_hosts_file "-"
echo "###### HOST OVER ######"
} }
#### RUN #### #### RUN ####