优化名称显示
This commit is contained in:
@@ -85,33 +85,38 @@ if [ -t 0 ]; then
|
||||
read -rp "Your choice [1-5]: " CHOICE
|
||||
|
||||
case $CHOICE in
|
||||
1)
|
||||
read -rp "Enter ICMP targets (space separated, e.g. 8.8.8.8 1.1.1.1): " VAL
|
||||
if [ -n "$VAL" ]; then
|
||||
echo "- targets:" | sudo tee "$TARGETS_DIR/icmp.yml" > /dev/null
|
||||
for t in $VAL; do echo " - $t" | sudo tee -a "$TARGETS_DIR/icmp.yml" > /dev/null; done
|
||||
echo "Saved to: $TARGETS_DIR/icmp.yml"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
read -rp "Enter HTTP targets (space separated, e.g. https://google.com): " VAL
|
||||
if [ -n "$VAL" ]; then
|
||||
echo "- targets:" | sudo tee "$TARGETS_DIR/http.yml" > /dev/null
|
||||
for t in $VAL; do echo " - $t" | sudo tee -a "$TARGETS_DIR/http.yml" > /dev/null; done
|
||||
echo "Saved to: $TARGETS_DIR/http.yml"
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
read -rp "Enter TCP targets (space separated, e.g. 1.1.1.1:443 8.8.8.8:53): " VAL
|
||||
if [ -n "$VAL" ]; then
|
||||
echo "- targets:" | sudo tee "$TARGETS_DIR/tcp.yml" > /dev/null
|
||||
for t in $VAL; do echo " - $t" | sudo tee -a "$TARGETS_DIR/tcp.yml" > /dev/null; done
|
||||
echo "Saved to: $TARGETS_DIR/tcp.yml"
|
||||
fi
|
||||
1|2|3)
|
||||
case $CHOICE in
|
||||
1) TYPE="icmp"; DESC="ICMP Ping"; EX="8.8.8.8";;
|
||||
2) TYPE="http"; DESC="HTTP Status"; EX="https://google.com";;
|
||||
3) TYPE="tcp"; DESC="TCP Connect"; EX="1.1.1.1:443";;
|
||||
esac
|
||||
|
||||
read -rp "Clear existing $DESC targets? [y/N]: " CLEAR_EXIST
|
||||
[[ "$CLEAR_EXIST" =~ ^[Yy]$ ]] && sudo rm -f "$TARGETS_DIR/$TYPE.yml"
|
||||
|
||||
while true; do
|
||||
echo "--- Adding $DESC Object ---"
|
||||
read -rp "Enter target (e.g. $EX, leave empty to stop): " T_VAL
|
||||
[ -z "$T_VAL" ] && break
|
||||
read -rp "Enter a descriptive name for this target: " T_NAME
|
||||
|
||||
[ ! -f "$TARGETS_DIR/$TYPE.yml" ] && sudo touch "$TARGETS_DIR/$TYPE.yml"
|
||||
sudo tee -a "$TARGETS_DIR/$TYPE.yml" > /dev/null <<EOF
|
||||
- targets: ['$T_VAL']
|
||||
labels:
|
||||
instance_name: '$T_NAME'
|
||||
EOF
|
||||
echo "Added $T_VAL ($T_NAME)"
|
||||
done
|
||||
;;
|
||||
4)
|
||||
echo "Current Target Files in $TARGETS_DIR:"
|
||||
ls -l "$TARGETS_DIR"/*.yml 2>/dev/null || echo "No targets configured yet."
|
||||
echo "Current Target Configuration in $TARGETS_DIR:"
|
||||
for f in "$TARGETS_DIR"/*.yml; do
|
||||
[ -e "$f" ] || continue
|
||||
echo "--- $(basename "$f") ---"
|
||||
sudo cat "$f"
|
||||
done
|
||||
;;
|
||||
5)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user