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