-
Notifications
You must be signed in to change notification settings - Fork 0
/
donkey-init.sh
executable file
·37 lines (25 loc) · 1 KB
/
donkey-init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
CONFIG_FILE="$SRC_DIR/resources/donkey.cfg"
HOSTAPD_CONF="/etc/hostapd/hostapd.conf"
echo $CONFIG_FILE
. $CONFIG_FILE
if [ "$DONKEY_RESET" = true ] ; then
HWADDR=$(ip link show wlan0 | awk 'NR==2{print $2}' | sed 's/://g' | cut -c 7- )
echo $HWADDR
sed -i "s/ssid=donkey.*/ssid=donkey-$HWADDR/g" $HOSTAPD_CONF
sed -i "s/127.0.1.1.*/127.0.1.1\tdonkey-$HWADDR/g" /etc/hosts
echo "donkey-$HWADDR" > /etc/hostname
sed -i "s/DONKEY_RESET.*/DONKEY_RESET=false/g" $CONFIG_FILE
cp ./resources/wpa_supplicant.empty.conf /boot/wpa_supplicant.conf
sudo raspi-config --expand-rootfs
logger "donkey-init rebooting"
reboot
fi
if [ "$DEV_MODE" = true ] ; then
cat resources/pub > /home/pi/.ssh/authorized_keys
cp ./resources/wpa_supplicant.test.conf /etc/wpa_supplicant/wpa_supplicant.conf
sed -i "s/DEV_MODE.*/DEV_MODE=false/g" $CONFIG_FILE
fi
logger "donkey-init completed"
exit 0