summaryrefslogtreecommitdiff
path: root/unittest/pre/beluga/setup-adaptor/config/set_eth_config.sh
diff options
context:
space:
mode:
Diffstat (limited to 'unittest/pre/beluga/setup-adaptor/config/set_eth_config.sh')
-rwxr-xr-xunittest/pre/beluga/setup-adaptor/config/set_eth_config.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/unittest/pre/beluga/setup-adaptor/config/set_eth_config.sh b/unittest/pre/beluga/setup-adaptor/config/set_eth_config.sh
new file mode 100755
index 0000000..c3f7778
--- /dev/null
+++ b/unittest/pre/beluga/setup-adaptor/config/set_eth_config.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+file="/var/lib/connman/ethernet.config"
+service_name="service_home_ethernet"
+
+
+create_file()
+{
+ if [ -f "$file" ] ; then
+ echo "remove existing file"
+ rm "$file"
+ fi
+ touch "$file"
+}
+
+add_ip_address()
+{
+ if [ -n "$IP" ] && [ -n "$NETMASK" ] && [ -n "$GATEWAY" ]; then
+ ipv4="$IP"/"$NETMASK"/"$GATEWAY"
+ else
+ echo -e "\nenter [ipAddress] [netmask] [gateway]"
+ ipv4=""
+ fi
+
+ if [ -n "$ipv4" ]; then
+ echo "IPv4 = ${ipv4}" >> "$file"
+ echo -e "SET ==>> IPv4 = ${ipv4}"
+ else
+ rm "$file"
+ echo -e "file write error"
+ exit 1
+ 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 = ethernet" >> "$file"
+
+add_ip_address
+add_dns_server
+
+#change file mode
+chmod +x "$file"
+echo -e "complete to write...\n"
+
+
+#disable ethernet service
+connmanctl disable ethernet
+
+#enable ethernet service
+connmanctl enable ethernet
+
+cat ${file}