summaryrefslogtreecommitdiff
path: root/unittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh
diff options
context:
space:
mode:
authorhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:20:53 +0900
committerhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:20:53 +0900
commit27763b024648b848430481a929d716038d887952 (patch)
treea5388eec33d3b55cbf75e2e1ea360c32de7de78f /unittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh
parent81dc7d90889e619942f34c4a584768b4b3179445 (diff)
downloaddocker-adaptor-master.tar.gz
docker-adaptor-master.tar.bz2
docker-adaptor-master.zip
Signed-off-by: hwajeong.son <hwajeong.son@samsung.com>
Diffstat (limited to 'unittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh')
-rwxr-xr-xunittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/unittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh b/unittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh
new file mode 100755
index 0000000..8e3aab6
--- /dev/null
+++ b/unittest/pre/beluga/setup-adaptor/config/set_wifi_config.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+file="/var/lib/connman/wifi.config"
+service_name="service_home_wifi"
+
+
+create_file()
+{
+ if [ -f "$file" ] ; then
+ echo "remove existing file"
+ rm "$file"
+ fi
+ touch "$file"
+}
+
+add_ssid_pw()
+{
+ echo "Name = ${SSID}" >> "$file"
+ echo "Passphrase = ${PASSWORD}" >> "$file"
+
+ echo -e "SET ==>> Name = ${SSID}"
+ echo -e "SET ==>> Passphrase = ${PASSWORD}"
+}
+
+add_ip_address()
+{
+ if [ -n "$IP" ] && [ -n "$NETMASK" ] && [ -n "$GATEWAY" ]; then
+ ipv4="$IP"/"$NETMASK"/"$GATEWAY"
+ elif [ -n "$DHCP" ]; then
+ ipv4="dhcp"
+ else
+ ipv4=""
+ fi
+
+ if [ -n "$ipv4" ]; then
+ echo "IPv4 = ${ipv4}" >> "$file"
+ echo -e "SET ==>> IPv4 = ${ipv4}"
+ fi
+}
+
+add_dns_server()
+{
+ if [ -n "$DNS1" ] && [ -n "$DNS2" ]; then
+ dns_server="$DNS1","$DNS2"
+ elif [ -n "$DNS1" ] && [ -z "$DNS2" ]; then
+ dns_server="$DNS1"
+ else
+ dns_server=""
+ fi
+
+ if [ -n "$dns_server" ]; then
+ echo "Nameservers = ${dns_server}" >> "$file"
+ echo "SET ==>> Nameservers = ${dns_server}"
+ fi
+}
+
+
+#start to write config file
+echo "create config file ${file}"
+create_file
+
+echo "[${service_name}]" >> "$file"
+echo "Type = wifi" >> "$file"
+
+add_ssid_pw
+add_ip_address
+add_dns_server
+
+#change file mode
+chmod +x "$file"
+echo -e "complete to write...\n"
+
+#disable wifi service
+connmanctl disable wifi
+
+#enable wifi service
+connmanctl enable wifi
+
+cat ${file}