Created
November 7, 2017 17:17
-
-
Save melissacoleman/2c2b7dbade76b8728515a6f1bf9a1f78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source .env | |
set -eo pipefail | |
cd "$(dirname "$0")" | |
if [[ ! $UID -eq 0 ]]; then | |
echo "you must run this as root:" | |
echo "sudo $0" | |
exit 1 | |
fi | |
if [ ! -e /sys/class/net/wlan0/address ]; then | |
echo "Are you sure you're running this on the pi?" | |
exit 1 | |
fi | |
export DEVICE_NAME=`cat /sys/class/net/wlan0/address | sed 's/://g'` | |
# Remove last line of hostfile | |
sudo sed -i '$ d' /etc/hosts | |
echo "127.0.0.1 ${DEVICE_NAME}" | sudo tee -a /etc/hosts | |
echo "${DEVICE_NAME}" | sudo tee /etc/hostname | |
sudo /etc/init.d/hostname.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment