nano /root/setopenwifi.sh
#!/bin/sh
/sbin/uci delete network.lan.ipaddr
/sbin/uci delete network.lan.netmask
/sbin/uci set network.lan.proto=dhcp
/sbin/uci set wireless.@wifi-iface[0].mode=sta
/sbin/uci set wireless.@wifi-iface[0].ssid="$1"
/sbin/uci set wireless.@wifi-iface[0].encryption=none
/sbin/uci commit wireless
wifi down; wifi up
/etc/init.d/network  restart
chmod 755 /root/setopenwifi.sh

Testing:

/root/setopenwifi.sh "my wifi ssid"