-
Notifications
You must be signed in to change notification settings - Fork 2
/
example-user-data.yml
116 lines (108 loc) · 3.39 KB
/
example-user-data.yml
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#cloud-config
# vim: syntax=yaml
#
# Set your hostname here, the manage_etc_hosts will update the hosts file entries as well
hostname: twccontroller
manage_etc_hosts: true
# You could modify this for your own user information
users:
- name: tesla
gecos: "Tesla Wall Connector Controller"
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
groups: users,docker,video,input
plain_text_passwd: tesla
lock_passwd: false
ssh_pwauth: true
chpasswd: { expire: false }
# # Set the locale of the system
# locale: "en_US.UTF-8"
# # Set the timezone
# # Value of 'timezone' must exist in /usr/share/zoneinfo
timezone: "Australia/Sydney"
# # Update apt packages on first boot
# package_update: true
# package_upgrade: true
# package_reboot_if_required: true
package_upgrade: false
# # Install any additional apt packages you need here
# packages:
# - ntp
# # WiFi connect to HotSpot
# # - use `wpa_passphrase SSID PASSWORD` to encrypt the psk
write_files:
- content: |
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
path: /etc/network/interfaces.d/wlan0
- content: |
country=au
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR_WIFI_SSID"
psk="YOUR_WIFI_PSK_PASSWORD"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
path: /etc/wpa_supplicant/wpa_supplicant.conf
- content: |
#!/bin/bash
sudo -i -u tesla bash << "EOF"
function twcstartup {
if [ ! -d /home/tesla/twc-controller ]
then
DOCKER_RUN=false
until "$DOCKER_RUN" == "true"
do
if [ "$(systemctl is-active docker)" = "active" ]; then
DOCKER_RUN=true
echo "Docker is running, continuing..."
GIT_SSL_NO_VERIFY=true git clone https://github.com/shreddedbacon/twc-controller.git /home/tesla/twc-controller
fi
done
fi
DOCKER_RUN=false
until "$DOCKER_RUN" == "true"
do
if [ "$(systemctl is-active docker)" = "active" ]; then
DOCKER_RUN=true
echo "Docker is running, continuing..."
cd /home/tesla/twc-controller
# if using fakepowerwall, edit the 'bash startup.sh ...' script with the following
# change 'nofakepowerwall' to 'fakepowerwall'
# change '-i INVERTER_HOST' value to the address for your inverter (see fake-powerwall for information)
# change '-t INVERTER_TYPE' value to the address for your inverter (see fake-powerwall for information)
bash startup.sh -p nofakepowerwall -i http://192.168.1.50 -t fronius
fi
done
}
exitcount=0
while true
do
if [ $exitcount -eq 30 ]; then
echo "Failed to start up the TWC controllers after 30 attempts"
break
fi
twcstartup
if [ $? -eq 0 ]; then
break
fi
((exitcount=exitcount+1))
sleep 5
done
EOF
path: /twccontroller
permissions: "0755"
# These commands will be ran once on first boot only
runcmd:
# Pickup the hostname changes
- "systemctl restart avahi-daemon"
# Activate WiFi interface
- "ifup wlan0"
# setup the startup/install scripts
- "/twccontroller"