/
change_settings.sh
100 lines (76 loc) · 2.86 KB
/
change_settings.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
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
#!/bin/bash
clear
echo ""
echo "****************************"
echo "*** CHANGE CONFIGURATION ***"
echo "****************************"
echo ""
echo "Change options or leave blank"
echo ""
echo ""
_homepath="/home/xilinx/azure-iot-hub-pynq/"
online_dashboard="azure-iot-dashboard"
offline_dashboard="azure-iot-dashboard-mini"
esp32="esp32-python-http-server"
flask="microserver-flask"
iotmessages="azureiot-messages"
tgbot="azure-iot-telegram-bot"
frontend_dashboard_environments_json="$_homepath/$online_dashboard/src/environments/environment.ts"
frontend_dashboard_azure_json="$_homepath/$online_dashboard/config.json"
azure_messages_json="$_homepath/$iotmessages/azure_config.json"
IFS=', ' read -r -a ips_array <<< "$(hostname -I)"
read -p "Choose actual IP [ ${ips_array[0]} / ${ips_array[1]} / ${ips_array[2]}]: " chosen_ip
echo "You set $chosen_ip"
read -p "Write board name: " chosen_board_name
echo "You set $chosen_board_name"
read -p "Write event connection string: " chosen_event_connection_string
echo "You set $chosen_event_connection_string"
read -p "Write cloud to device connection string: " chosen_cloud_to_device_connection_string
echo "You set $chosen_cloud_to_device_connection_string"
read -p "Write device to cloud connection string: " chosen_device_to_cloud_connection_string
echo "You set $chosen_device_to_cloud_connection_string"
read -p "Write device id: " chosen_device_id
echo "You set $chosen_device_id"
JSON_STRING="
export const environment = {
production: false,
local: false,
server: 'http://$chosen_ip:3000',
deviceName: '$chosen_board_name'
};
"
#echo $JSON_STRING
echo $JSON_STRING > $frontend_dashboard_environments_json
echo "changed in $frontend_dashboard_environments_json"
#Endpoint=sb://ihsuprodamres019dednamespace.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=aMAtWHIITXjgS0DGIOeFG38wFOMshbLUprSKzaqgBEQ=;EntityPath=iothub-ehub-z7010-3876357-5826ddaa93
#HostName=Z7010.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=fTw2DV4CniY+M+d0iuSmn3OkXZfZDKAH77CyQic2j68=
#Z7010-board1
JSON_STRING="
{
\"eventConnectionString\": \"$chosen_event_connection_string\",
\"eventEndpoint\": \"\$Default\",
\"cloudToDeviceConnectionString\": \"$chosen_cloud_to_device_connection_string\",
\"deviceId\": \"$chosen_device_id\"
}"
#echo $JSON_STRING
echo $JSON_STRING > $frontend_dashboard_azure_json
echo "changed in $frontend_dashboard_azure_json"
#HostName=Z7010.azure-devices.net;DeviceId=Z7010-board1;SharedAccessKey=tSZ5eYqdBjSGMnhcPQsJqJaPxyuQ1TCJYvAPveN3iVg=
JSON_STRING="
{
\"connection_string\": \"$chosen_device_to_cloud_connection_string\"
}
"
#echo $JSON_STRING
echo $JSON_STRING > $frontend_dashboard_azure_json
echo "changed in $azure_messages_json"
echo "Regenerate sources..."
cd $online_dashboard
npm run build
cd $_homepath
sudo pm2 restart all
sudo pm2 reset all
echo "Done!"
echo ""
echo ""
echo ""