#!/usr/bin/env bash

# *** [ Ansible managed: DO NOT EDIT DIRECTLY ] ***

declare -i pc_nr=101
pc_nr_max=135
brcast_ip="192.168.2.255"

pc102="6c:4b:90:be:05:ef"
pc105="40:2c:f4:ea:81:6c"
pc112="00:10:c6:b0:d1:3b"
pc133="00:19:99:ac:b3:10"

if [ $# = "1" ]; then
   echo ""
   echo -e "   \033[32mWake up PC '$1'\033[m.."
   _nic=`eval eval echo  '$'$1`
   if [[ -n "$_nic" ]]; then
      for _mac in $_nic ; do
         echo -n "   "
         wakeonlan -i $brcast_ip $_mac
         sleep 1
      done
   else
      echo -e "   \033[1;31mPC '$1' NOT found!\033[m"
   fi
   echo ""
else
   while [[ $pc_nr -le $pc_nr_max ]]; do
      [[ -z "$pc_nr" ]] && continue
      _nic=$(eval eval echo '$pc'$pc_nr)
      if [[ -n "$_nic" ]]; then
         echo ""
         echo -e "   \033[32mWake up PC 'pc$pc_nr'\033[m.."
         for _mac in $_nic ; do
            echo -n "   "
            /usr/bin/wakeonlan -i $brcast_ip $_mac
            sleep 1
         done
      fi
      (( pc_nr++ ))
   done
   echo ""
fi
