Сценарий оболочки для хостов на Mac не работает - PullRequest
0 голосов
/ 01 февраля 2019

Я работал над некоторыми файлами хоста, чтобы добавить локальные сетевые ips к хостам, чтобы моим коллегам было проще получить доступ к нашим внутренним устройствам, не помня ips

Файл Hosts.sh

#!/bin/sh
if grep -Fxq "wiki" /etc/hosts
then
echo 'wiki er allerede tilføjet'
else
echo 'Tilføjer wiki til hosts'
sudo bash -c 'echo -e "192.168.2.13\twiki\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "taxatilbus-docs" /etc/hosts
then
echo 'taxatilbus-docs er allerede tilføjet'
else
echo 'Tilføjer taxatilbus-docs til hosts'
sudo bash -c 'echo -e "192.168.2.12\ttaxatilbus-docs\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "docucolor" /etc/hosts
then
echo 'docucolor er allerede tilføjet'
else
echo 'Tilføjer docucolor til hosts'
sudo bash -c 'echo -e "192.168.1.7\tdocucolor\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "epson" /etc/hosts
then
echo 'epson er allerede tilføjet'
else
echo 'Tilføjer epson til hosts'
sudo bash -c 'echo -e "192.168.1.8\tepson\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "brother" /etc/hosts
then
echo 'brother er allerede tilføjet'
else
echo 'Tilføjer brother til hosts'
sudo bash -c 'echo -e "192.168.1.9\tbrother\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "mathias-laptop" /etc/hosts
then
echo 'mathias-laptop er allerede tilføjet'
else
echo 'Tilføjer mathias-laptop til hosts'
sudo bash -c 'echo -e "192.168.1.18\tmathias-laptop\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "mathias-desktop" /etc/hosts
then
echo 'mathias-desktop er allerede tilføjet'
else
echo 'Tilføjer mathias-desktop til hosts'
sudo bash -c 'echo -e "192.168.1.19\tmathias-desktop\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi
if grep -Fxq "unifi" /etc/hosts
then
echo 'unifi er allerede tilføjet'
else
echo 'Tilføjer unifi til hosts'
sudo bash -c 'echo -e "192.168.1.11\tunifi\n" >> /etc/hosts'
echo 'wiki er blevet tilføjet'
fi

Я сообщаю им, чтобы поместить файл hosts.sh на рабочий стол, а затем перейти к терминалу и написать

cd Desktop
./hosts.sh

, но тогда он просто говорит, что команда не найдена, и вставляетвесь скрипт в терминал добавляет вики в хост-файл, но не остальные

...