#!/bin/ash
#
# Obelisco BALConfig
#
# /usr/sbin/balconfig
# 20070411 - HernanRossetto@buenosaireslibre.org
#
# Configuration wizard for BuenosAiresLibre devices
#
# http://wiki.buenosaireslibre.org/Obelisco
#
# -----------------------------------------
CFG_BALCFG_LIB=/usr/lib/balcfg.sh
if [ -x ${CFG_BALCFG_LIB} ]
then
. ${CFG_BALCFG_LIB}
else
echo "Error, no se puede encontrar ${CFG_BALCFG_LIB}"
exit 1
fi
# -----------------------------------------
#
# -----------------------------------------
check_arguments $*
balconfig_title
set_nvram_bin
if [ "${CFG_TYPE}" != "defaults" ]
then
check_boot_wait
check_root_passwd
fi
hw_detection
set_hw_default_features
set_hw_features
clear_nvram
read_project_cfgfile
set_project_defaults
case "${CFG_TYPE}" in
("defaults")
display_msg "Configuración por defecto."
set_cfg_defaults
create_tmp_cfgfile
set_cfg_with_defaults
;;
("auto")
display_msg "Configuración automática."
;;
("normal"|"test"|"kamikaze"|"extra")
read_cfg_from_nvram
read_cfgfile
set_cfg_defaults
create_tmp_cfgfile
# Configuration Wizard
# -----------------------------------------
display_msg "Por favor, responder cuidadosamente:"
# General configuration
#save_setting BALCFG_boot_wait ${BALCFG_boot_wait}
save_setting BALCFG_obelisco_defaults false
save_setting BALCFG_obelisco_nvram_defaults blank
# Info
save_setting BALCFG_obelisco_hw_detected ${BALCFG_obelisco_hw_detected}
save_setting BALCFG_obelisco_project_name ${BALCFG_obelisco_project_name}
save_setting BALCFG_obelisco_project_url ${BALCFG_obelisco_project_url}
save_setting BALCFG_obelisco_project_rss ${BALCFG_obelisco_project_rss}
save_setting BALCFG_obelisco_project_cgiirc ${BALCFG_obelisco_project_cgiirc}
save_setting BALCFG_obelisco_project_irc_channel ${BALCFG_obelisco_project_irc_channel}
save_setting BALCFG_obelisco_project_dns_tld ${BALCFG_obelisco_project_dns_tld}
ask_user "Nombre Wiki del Nodo" BALCFG_obelisco_node_name ${BALCFG_obelisco_node_name}
if [ "${BALCFG_obelisco_node_name}" != "${CFG_RETURN}" ]
then
BALCFG_obelisco_node_name=${CFG_RETURN}
BALCFG_obelisco_node_url=${CFG_obelisco_node_url_PREFIX}${BALCFG_obelisco_node_name}
BALCFG_wl0_ssid=""
if [ -n $( echo ${BALCFG_obelisco_node_name} | grep "^[Nn]odo") ]
then
BALCFG_wan_hostname=$(echo ${CFG_RETURN} | sed 's/^[Nn]odo//' | tr [A-Z] [a-z])
fi
fi
ask_user "URL del Wiki del Nodo" BALCFG_obelisco_node_url ${BALCFG_obelisco_node_url}
ask_user "Nombre Wiki del responsable del Nodo" BALCFG_obelisco_admin_name ${BALCFG_obelisco_admin_name}
ask_user "e-mail para contacto del responsable" BALCFG_obelisco_admin_email ${BALCFG_obelisco_admin_email}
# Node type selection
CFG_obelisco_node_type_prev=${BALCFG_obelisco_node_type}
case "${CFG_HW_DETECTED}" in
("ProAP"*)
if [ "${CFG_HW_PORT2}" != "none" -a "${CFG_HW_PORT3}" != "none" ]
then
ask_user "Tipo de Nodo [${CFG_NODE_TYPE1}|${CFG_NODE_TYPE2}|${CFG_NODE_TYPE3}|${CFG_NODE_TYPE4}]" BALCFG_obelisco_node_type ${BALCFG_obelisco_node_type}
case "${CFG_RETURN}" in
("${CFG_NODE_TYPE1}"|"${CFG_NODE_TYPE2}"|"${CFG_NODE_TYPE3}"|"${CFG_NODE_TYPE4}")
BALCFG_obelisco_node_type=${CFG_RETURN}
;;
(*)
# Error
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, Tipo de Nodo incorrecto, debe ser ${CFG_NODE_TYPE1} o ${CFG_NODE_TYPE2} o ${CFG_NODE_TYPE3} o ${CFG_NODE_TYPE4}"
;;
esac
elif [ "${CFG_HW_PORT2}" != "none" ]
then
ask_user "Tipo de Nodo [${CFG_NODE_TYPE1}|${CFG_NODE_TYPE2}|${CFG_NODE_TYPE3}]" BALCFG_obelisco_node_type ${BALCFG_obelisco_node_type}
case "${CFG_RETURN}" in
("${CFG_NODE_TYPE1}"|"${CFG_NODE_TYPE2}"|"${CFG_NODE_TYPE3}")
BALCFG_obelisco_node_type=${CFG_RETURN}
;;
("${CFG_NODE_TYPE4}")
# Error, type not supported
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, su hardware no soporta este tipo de configuración"
;;
(*)
# Error
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, Tipo de Nodo incorrecto, debe ser ${CFG_NODE_TYPE1} o ${CFG_NODE_TYPE2} o ${CFG_NODE_TYPE3}"
;;
esac
else
ask_user "Tipo de Nodo [${CFG_NODE_TYPE1}|${CFG_NODE_TYPE2}]" BALCFG_obelisco_node_type ${BALCFG_obelisco_node_type}
case "${CFG_RETURN}" in
("${CFG_NODE_TYPE1}"|"${CFG_NODE_TYPE2}")
BALCFG_obelisco_node_type=${CFG_RETURN}
;;
("${CFG_NODE_TYPE3}"|"${CFG_NODE_TYPE4}")
# Error, type not supported
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, su hardware no soporta este tipo de configuración"
;;
(*)
# Error
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, Tipo de Nodo incorrecto, debe ser ${CFG_NODE_TYPE1} o ${CFG_NODE_TYPE2}"
;;
esac
fi
;;
(*)
if [ ${CFG_HW_VLAN_SUPPORT} -eq 1 ]
then
ask_user "Tipo de Nodo [${CFG_NODE_TYPE1}|${CFG_NODE_TYPE2}|${CFG_NODE_TYPE3}|${CFG_NODE_TYPE4}]" BALCFG_obelisco_node_type ${BALCFG_obelisco_node_type}
case "${CFG_RETURN}" in
("${CFG_NODE_TYPE1}"|"${CFG_NODE_TYPE2}"|"${CFG_NODE_TYPE3}"|"${CFG_NODE_TYPE4}")
BALCFG_obelisco_node_type=${CFG_RETURN}
;;
(*)
# Error
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, Tipo de Nodo incorrecto, debe ser ${CFG_NODE_TYPE1} o ${CFG_NODE_TYPE2} o ${CFG_NODE_TYPE3} o ${CFG_NODE_TYPE4}"
;;
esac
else
ask_user "Tipo de Nodo [${CFG_NODE_TYPE1}|${CFG_NODE_TYPE2}]" BALCFG_obelisco_node_type ${BALCFG_obelisco_node_type}
case "${CFG_RETURN}" in
("${CFG_NODE_TYPE1}"|"${CFG_NODE_TYPE2}")
BALCFG_obelisco_node_type=${CFG_RETURN}
;;
("${CFG_NODE_TYPE3}"|"${CFG_NODE_TYPE4}")
# Error, type not supported
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, su hardware no soporta este tipo de configuración"
;;
(*)
# Error
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, Tipo de Nodo incorrecto, debe ser ${CFG_NODE_TYPE1} o ${CFG_NODE_TYPE2}"
;;
esac
fi
;;
esac
display_msg "Tipo de Nodo: ${BALCFG_obelisco_node_type}"
# Configuration based on Node type
# Interfaces
#save_setting BALCFG_ifup_interfaces ${BALCFG_ifup_interfaces}
save_setting BALCFG_static_route ${BALCFG_static_route}
ask_user "Nombre de red, hostname, del ${BALCFG_obelisco_node_type:=Nodo}" BALCFG_wan_hostname ${BALCFG_wan_hostname}
[ ${BALCFG_wan_hostname} != ${CFG_RETURN} ] && BALCFG_wl0_ssid=""
BALCFG_wan_hostname=${CFG_RETURN}
# LAN
save_setting BALCFG_lan_ifname ${BALCFG_lan_ifname}
#save_setting BALCFG_lan_ifnames ${BALCFG_lan_ifnames}
save_setting BALCFG_lan_proto ${BALCFG_lan_proto}
ask_user "IP Address" BALCFG_lan_ipaddr ${BALCFG_lan_ipaddr}
[ ${CFG_RETURN} != ${BALCFG_lan_ipaddr} ] && BALCFG_lan_netmask=$(set_netmask ${CFG_RETURN})
BALCFG_lan_ipaddr=${CFG_RETURN}
ask_user "Netmask" BALCFG_lan_netmask ${BALCFG_lan_netmask}
BALCFG_lan_netmask=${CFG_RETURN}
BALCFG_First_IP=$(int2ip $(($(($(ip2int ${BALCFG_lan_ipaddr})&$(ip2int ${BALCFG_lan_netmask})))+1)))
[ $? -ne 0 ] && display_msg_error "Error: Dirección IP incorrecta"
if [ "${BALCFG_First_IP}" != "${BALCFG_lan_ipaddr}" ]
then
if [ "${BALCFG_obelisco_node_type}" = "${CFG_NODE_TYPE1}" ]
then
BALCFG_lan_gateway=$(int2ip $(($(ip2int ${BALCFG_lan_ipaddr})-1)))
BALCFG_lan_dns=${BALCFG_lan_gateway}
else
BALCFG_lan_gateway=${BALCFG_First_IP}
BALCFG_lan_dns=${BALCFG_lan_gateway}
fi
fi
ask_user "Default Gateway" BALCFG_lan_gateway ${BALCFG_lan_gateway}
[ "${BALCFG_lan_gateway}" != "${CFG_RETURN}" ] && BALCFG_lan_dns=${CFG_RETURN}
ask_user "DNS Server" BALCFG_lan_dns ${BALCFG_lan_dns}
save_setting BALCFG_lan_hostname ${BALCFG_lan_hostname}
save_setting BALCFG_lan_stp ${BALCFG_lan_stp}
save_setting BALCFG_lan_static_route ${BALCFG_lan_static_route}
# WIFI
save_setting BALCFG_wl0_ifname ${BALCFG_wl0_ifname}
save_setting BALCFG_wl0_ap_isolate ${BALCFG_wl0_ap_isolate}
if [ "${BALCFG_obelisco_node_type}" != "${CFG_NODE_TYPE1}" ]
then
BALCFG_wl0_ssid=${BALCFG_wl0_ssid:=${BALCFG_wan_hostname}${CFG_SSID_SUFFIX}}
else
BALCFG_wl0_ssid=${BALCFG_wl0_ssid:=$CFG_wl0_ssid}
fi
ask_user "Wireless SSID" BALCFG_wl0_ssid ${BALCFG_wl0_ssid}
save_setting BALCFG_wl0_infra ${BALCFG_wl0_infra}
save_setting BALCFG_wl0_closed ${BALCFG_wl0_closed}
save_setting BALCFG_wl0_country_code ${BALCFG_wl0_country_code}
save_setting BALCFG_wl0_macmode ${BALCFG_wl0_macmode}
save_setting BALCFG_wl0_radio ${BALCFG_wl0_radio}
ask_user "Wireless Channel" BALCFG_wl0_channel ${BALCFG_wl0_channel}
save_setting BALCFG_wl0_gmode ${BALCFG_wl0_gmode}
save_setting BALCFG_wl0_gmode_protection ${BALCFG_wl0_gmode_protection}
save_setting BALCFG_wl0_rateset ${BALCFG_wl0_rateset}
save_setting BALCFG_wl0_plcphdr ${BALCFG_wl0_plcphdr}
save_setting BALCFG_wl0_rate ${BALCFG_wl0_rate}
if [ "${CFG_TYPE}" = "extra" ]
then
ask_user "Extra: Wireless TX Power en miliwatts" BALCFG_wl0_txpwr ${BALCFG_wl0_txpwr}
case "${BALCFG_wl0_antdiv}" in
("-1")
CFG_wl0_antdiv="auto"
;;
("0")
if [ "${CFG_HW_ANTENNA_ORDER}" = "reverse" ]
then
CFG_wl0_antdiv="aux"
else
CFG_wl0_antdiv="main"
fi
;;
("1")
if [ "${CFG_HW_ANTENNA_ORDER}" = "reverse" ]
then
CFG_wl0_antdiv="main"
else
CFG_wl0_antdiv="aux"
fi
;;
("3")
CFG_wl0_antdiv="diversity"
;;
(*)
CFG_wl0_antdiv="auto"
;;
esac
ask_user "Extra: Seleccionar antena [auto|main|aux|diversity]" CFG_wl0_antdiv ${CFG_wl0_antdiv}
CFG_wl0_antdiv=${CFG_RETURN}
case "${CFG_wl0_antdiv}" in
("auto")
save_setting BALCFG_wl0_antdiv -1
save_setting BALCFG_wl0_txant -1
;;
("main")
if [ "${CFG_HW_ANTENNA_ORDER}" = "reverse" ]
then
save_setting BALCFG_wl0_antdiv 1
save_setting BALCFG_wl0_txant 1
else
save_setting BALCFG_wl0_antdiv 0
save_setting BALCFG_wl0_txant 0
fi
;;
("aux")
if [ "${CFG_HW_ANTENNA_ORDER}" = "reverse" ]
then
save_setting BALCFG_wl0_antdiv 0
save_setting BALCFG_wl0_txant 0
else
save_setting BALCFG_wl0_antdiv 1
save_setting BALCFG_wl0_txant 1
fi
;;
("diversity")
save_setting BALCFG_wl0_antdiv 3
save_setting BALCFG_wl0_txant 3
;;
(*)
save_setting BALCFG_wl0_antdiv -1
save_setting BALCFG_wl0_txant -1
funError "Error, opción inválida"
;;
esac
ask_user "Extra: Distancia en metros del enlace (mayor a 1500)" BALCFG_wl0_distance ${BALCFG_wl0_distance}
else
save_setting BALCFG_wl0_txpwr blank
save_setting BALCFG_wl0_antdiv -1
save_setting BALCFG_wl0_txant -1
save_setting BALCFG_wl0_distance blank
fi
save_setting BALCFG_wl0_rts ${BALCFG_wl0_rts}
save_setting BALCFG_wl0_frag ${BALCFG_wl0_frag}
save_setting BALCFG_wl0_dtim ${BALCFG_wl0_dtim}
save_setting BALCFG_wl0_bcn ${BALCFG_wl0_bcn}
save_setting BALCFG_wl0_frameburst ${BALCFG_wl0_frameburst}
save_setting BALCFG_wl0_wdstimeout ${BALCFG_wl0_wdstimeout}
save_setting BALCFG_wl0_auth_mode ${BALCFG_wl0_auth_mode}
save_setting BALCFG_wl0_akm ${BALCFG_wl0_akm}
save_setting BALCFG_wl0_wpa_psk ${BALCFG_wl0_wpa_psk}
save_setting BALCFG_wl0_wpa_gtk_rekey ${BALCFG_wl0_wpa_gtk_rekey}
save_setting BALCFG_wl0_radius_ipaddr ${BALCFG_wl0_radius_ipaddr}
save_setting BALCFG_wl0_radius_key ${BALCFG_wl0_radius_key}
save_setting BALCFG_wl0_radius_port ${BALCFG_wl0_radius_port}
save_setting BALCFG_wl0_wep ${BALCFG_wl0_wep}
save_setting BALCFG_wl0_key1 ${BALCFG_wl0_key1}
save_setting BALCFG_wl0_key2 ${BALCFG_wl0_key2}
save_setting BALCFG_wl0_key3 ${BALCFG_wl0_key3}
save_setting BALCFG_wl0_key4 ${BALCFG_wl0_key4}
save_setting BALCFG_wl0_key ${BALCFG_wl0_key}
save_setting BALCFG_wl0_auth ${BALCFG_wl0_auth}
# WDS
#
# WAN
save_setting BALCFG_wan_stp ${BALCFG_wan_stp}
save_setting BALCFG_wan_static_route ${BALCFG_wan_static_route}
# PORT 1
#
# PORT 2
save_setting BALCFG_port2_ifnames ${BALCFG_port2_ifnames}
save_setting BALCFG_port2_gateway ${BALCFG_port2_gateway}
save_setting BALCFG_port2_dns ${BALCFG_port2_dns}
save_setting BALCFG_port2_hostname ${BALCFG_port2_hostname}
save_setting BALCFG_port2_stp ${BALCFG_port2_stp}
save_setting BALCFG_port2_static_route ${BALCFG_port2_static_route}
# PORT 3
save_setting BALCFG_port3_ifnames ${BALCFG_port3_ifnames}
save_setting BALCFG_port3_gateway ${BALCFG_port3_gateway}
save_setting BALCFG_port3_dns ${BALCFG_port3_dns}
save_setting BALCFG_port3_hostname ${BALCFG_port3_hostname}
save_setting BALCFG_port3_stp ${BALCFG_port3_stp}
save_setting BALCFG_port3_static_route ${BALCFG_port3_static_route}
# PORT 4
save_setting BALCFG_port4_ifnames ${BALCFG_port4_ifnames}
save_setting BALCFG_port4_gateway ${BALCFG_port4_gateway}
save_setting BALCFG_port4_dns ${BALCFG_port4_dns}
save_setting BALCFG_port4_hostname ${BALCFG_port4_hostname}
save_setting BALCFG_port4_stp ${BALCFG_port4_stp}
save_setting BALCFG_port4_static_route ${BALCFG_port4_static_route}
# Internet - PPPOE
#
# OpenVPN
#
# Services
save_setting BALCFG_obelisco_button_enable ${BALCFG_obelisco_button_enable}
save_setting BALCFG_dhcp_start ${BALCFG_dhcp_start}
save_setting BALCFG_dhcp_num ${BALCFG_dhcp_num}
save_setting BALCFG_dhcp_lease ${BALCFG_dhcp_lease}
save_setting BALCFG_ntp_server ${BALCFG_ntp_server}
if [ "${CFG_TYPE}" = "extra" ]
then
ask_user "Extra: Syslog Server" BALCFG_log_ipaddr ${BALCFG_log_ipaddr}
else
save_setting BALCFG_log_ipaddr ${BALCFG_log_ipaddr}
fi
# MMC
#
case "${BALCFG_obelisco_node_type}" in
("${CFG_NODE_TYPE1}")
# Bridged client
# DHCP Server disabled, HTTPD Server disabled, OLSR disabled
#
save_setting BALCFG_ifup_interfaces lan#wifi
# LAN
save_setting BALCFG_vlan0hwname et0
save_setting BALCFG_vlan0ports 0#1#2#3#4#5#
save_setting BALCFG_lan_ifnames ${CFG_HW_LAN}#${CFG_HW_WIFI}
# WIFI
if [ "${CFG_TYPE}" = "extra" ]
then
case "${BALCFG_wl0_mode}" in
("ap")
if [ "${CFG_obelisco_node_type_prev}" = "${CFG_NODE_TYPE1}" ]
then
CFG_wl0_master="si"
else
CFG_wl0_master="no"
fi
;;
("wet")
CFG_wl0_master="no"
;;
(*)
CFG_wl0_master="no"
;;
esac
ask_user "Extra: ${CFG_NODE_TYPE1} en Modo Master [si|no]" CFG_wl0_master ${CFG_wl0_master}
CFG_wl0_master=${CFG_RETURN}
case "${CFG_wl0_master}" in
("si")
save_setting BALCFG_wl0_mode ap
;;
("no")
save_setting BALCFG_wl0_mode wet
;;
(*)
save_setting BALCFG_wl0_mode ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
else
save_setting BALCFG_wl0_mode wet
fi
# WDS
save_setting BALCFG_obelisco_wds_enable false
save_setting BALCFG_wl0_lazywds blank
save_setting BALCFG_wl0_wds blank
save_setting BALCFG_wds_ifname blank
save_setting BALCFG_wds_ifnames blank
save_setting BALCFG_wds_proto blank
save_setting BALCFG_wds_ipaddr blank
save_setting BALCFG_wds_netmask blank
save_setting BALCFG_wds_gateway blank
save_setting BALCFG_wds_dns blank
save_setting BALCFG_wds_hostname blank
save_setting BALCFG_wds_stp blank
save_setting BALCFG_wds_static_route blank
# WAN
save_setting BALCFG_vlan1hwname blank
save_setting BALCFG_vlan1ports blank
save_setting BALCFG_wan_ifname ${BALCFG_wan_ifname}
save_setting BALCFG_wan_proto none
save_setting BALCFG_wan_ipaddr blank
save_setting BALCFG_wan_netmask blank
save_setting BALCFG_wan_gateway blank
save_setting BALCFG_wan_dns blank
# PORT 1
#
# PORT 2
save_setting BALCFG_vlan4hwname blank
save_setting BALCFG_vlan4ports blank
save_setting BALCFG_port2_ifname blank
save_setting BALCFG_port2_proto blank
save_setting BALCFG_port2_ipaddr blank
save_setting BALCFG_port2_netmask blank
# PORT 2 - WIFI
save_setting BALCFG_wl1_ifname blank
save_setting BALCFG_wl1_mode blank
save_setting BALCFG_wl1_ssid blank
save_setting BALCFG_wl1_channel blank
save_setting BALCFG_wl1_txpwr blank
# PORT 3
save_setting BALCFG_vlan6hwname blank
save_setting BALCFG_vlan6ports blank
save_setting BALCFG_port3_ifname blank
save_setting BALCFG_port3_proto blank
save_setting BALCFG_port3_ipaddr blank
save_setting BALCFG_port3_netmask blank
# PORT 3 - WIFI
save_setting BALCFG_wl2_ifname blank
save_setting BALCFG_wl2_mode blank
save_setting BALCFG_wl2_ssid blank
save_setting BALCFG_wl2_channel blank
save_setting BALCFG_wl2_txpwr blank
# PORT 4
save_setting BALCFG_vlan8hwname blank
save_setting BALCFG_vlan8ports blank
save_setting BALCFG_port4_ifname blank
save_setting BALCFG_port4_proto blank
save_setting BALCFG_port4_ipaddr blank
save_setting BALCFG_port4_netmask blank
# Internet - PPPOE
save_setting BALCFG_ppp_idletime blank
save_setting BALCFG_ppp_mtu blank
save_setting BALCFG_ppp_redialperiod blank
save_setting BALCFG_ppp_username blank
save_setting BALCFG_ppp_passwd blank
save_setting BALCFG_pppoe_ifname blank
save_setting BALCFG_pppoe_idletime blank
save_setting BALCFG_pppoe_username blank
save_setting BALCFG_pppoe_passwd blank
# OpenVPN
save_setting BALCFG_obelisco_vpn0_enable false
save_setting BALCFG_vpn0_ifname blank
save_setting BALCFG_vpn0_port blank
save_setting BALCFG_vpn0_ipaddr blank
save_setting BALCFG_vpn0_netmask blank
save_setting BALCFG_vpn0_peer_ipaddr blank
save_setting BALCFG_obelisco_vpn1_enable false
save_setting BALCFG_vpn1_ifname blank
save_setting BALCFG_vpn1_port blank
save_setting BALCFG_vpn1_remote blank
save_setting BALCFG_vpn1_ipaddr blank
save_setting BALCFG_vpn1_netmask blank
save_setting BALCFG_vpn1_peer_ipaddr blank
# Services
save_setting BALCFG_obelisco_internet false
save_setting BALCFG_obelisco_dhcpd_enable false
save_setting BALCFG_obelisco_httpd_enable false
save_setting BALCFG_obelisco_olsrd_enable false
save_setting BALCFG_obelisco_olsrd_hna4 blank
save_setting BALCFG_obelisco_portal_enable false
save_setting BALCFG_obelisco_portal_log file
save_setting BALCFG_obelisco_portal_accept ${BALCFG_obelisco_portal_accept}
save_setting BALCFG_obelisco_portal_irc_enable false
save_setting BALCFG_obelisco_balls_update_enable true
# MMC
save_setting BALCFG_obelisco_mmc_enable false
save_setting BALCFG_obelisco_mmc_driver ${BALCFG_obelisco_mmc_driver}
;;
("${CFG_NODE_TYPE2}")
# DHCP Server enabled, HTTPD Server enabled, OLSR enabled
#
#save_setting BALCFG_ifup_interfaces lan#wan#wifi
BALCFG_ifup_interfaces="lan#wan#wifi"
# LAN
save_setting BALCFG_vlan0hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan0ports 0#1#2#3#5#
else
save_setting BALCFG_vlan0ports 1#2#3#4#5#
fi
save_setting BALCFG_lan_ifnames ${CFG_HW_LAN}#${CFG_HW_WIFI}
# WIFI
save_setting BALCFG_wl0_mode ap
# WDS
#
# WAN
save_setting BALCFG_vlan1hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan1ports 4#5
else
save_setting BALCFG_vlan1ports 0#5
fi
# PORT 1
#
# PORT 2
save_setting BALCFG_vlan4hwname blank
save_setting BALCFG_vlan4ports blank
save_setting BALCFG_port2_ifname blank
save_setting BALCFG_port2_proto blank
save_setting BALCFG_port2_ipaddr blank
save_setting BALCFG_port2_netmask blank
# PORT 2 - WIFI
save_setting BALCFG_wl1_ifname blank
save_setting BALCFG_wl1_mode blank
save_setting BALCFG_wl1_ssid blank
save_setting BALCFG_wl1_channel blank
save_setting BALCFG_wl1_txpwr blank
# PORT 3
save_setting BALCFG_vlan6hwname blank
save_setting BALCFG_vlan6ports blank
save_setting BALCFG_port3_ifname blank
save_setting BALCFG_port3_proto blank
save_setting BALCFG_port3_ipaddr blank
save_setting BALCFG_port3_netmask blank
# PORT 3 - WIFI
save_setting BALCFG_wl2_ifname blank
save_setting BALCFG_wl2_mode blank
save_setting BALCFG_wl2_ssid blank
save_setting BALCFG_wl2_channel blank
save_setting BALCFG_wl2_txpwr blank
# PORT 4
save_setting BALCFG_vlan8hwname blank
save_setting BALCFG_vlan8ports blank
save_setting BALCFG_port4_ifname blank
save_setting BALCFG_port4_proto blank
save_setting BALCFG_port4_ipaddr blank
save_setting BALCFG_port4_netmask blank
# Internet - PPPOE
#
# OpenVPN
#
# Services
save_setting BALCFG_obelisco_dhcpd_enable true
save_setting BALCFG_obelisco_httpd_enable true
save_setting BALCFG_obelisco_olsrd_enable true
save_setting BALCFG_obelisco_balls_update_enable true
# MMC
#
;;
("${CFG_NODE_TYPE3}")
# DHCP Server enabled, HTTPD Server enabled, OLSR enabled
# Switch PORT2 on VLAN4
#
if [ ${CFG_HW_VLAN_SUPPORT} -eq 0 ]
then
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, su hardware no soporta este tipo de configuración"
fi
#
#save_setting BALCFG_ifup_interfaces lan#wan#wifi#port2
BALCFG_ifup_interfaces="lan#wan#wifi#port2"
# LAN
save_setting BALCFG_vlan0hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan0ports 0#1#3#5#
else
save_setting BALCFG_vlan0ports 1#3#4#5#
fi
save_setting BALCFG_lan_ifnames ${CFG_HW_LAN}#${CFG_HW_WIFI}
# WIFI
save_setting BALCFG_wl0_mode ap
# WDS
#
# WAN
save_setting BALCFG_vlan1hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan1ports 4#5
else
save_setting BALCFG_vlan1ports 0#5
fi
# PORT 1
#
# PORT 2
save_setting BALCFG_vlan4hwname et0
save_setting BALCFG_vlan4ports 2#5
save_setting BALCFG_port2_ifname ${CFG_HW_PORT2}
save_setting BALCFG_port2_proto static
ask_user "PORT2 IP Address" BALCFG_port2_ipaddr ${BALCFG_port2_ipaddr}
[ ${CFG_RETURN} != ${BALCFG_port2_ipaddr} ] && BALCFG_port2_netmask=$(set_netmask ${CFG_RETURN})
ask_user "PORT2 Netmask" BALCFG_port2_netmask ${BALCFG_port2_netmask}
# PORT 2 - WIFI
if [ "${CFG_HW_PORT2_ISWIFI}" = "true" ]
then
save_setting BALCFG_wl1_ifname ${CFG_HW_PORT2}
ask_user "PORT2 Wireless Mode [ap|sta]" CFG_wl1_mode ${BALCFG_wl1_mode}
case "${CFG_RETURN}" in
("ap"|"sta")
save_setting BALCFG_wl1_mode ${CFG_RETURN}
;;
(*)
save_setting BALCFG_wl1_mode ""
display_msg_error "Error, la respuesta debe ser ap o sta"
;;
esac
ask_user "PORT2 Wireless SSID" BALCFG_wl1_ssid ${BALCFG_wl1_ssid}
ask_user "PORT2 Wireless Channel" BALCFG_wl1_channel ${BALCFG_wl1_channel}
if [ "${CFG_TYPE}" = "extra" ]
then
ask_user "Extra: PORT2 Wireless TX Power en miliwatts" BALCFG_wl1_txpwr ${BALCFG_wl1_txpwr}
else
save_setting BALCFG_wl1_txpwr blank
fi
else
save_setting BALCFG_wl1_ifname blank
save_setting BALCFG_wl1_mode blank
save_setting BALCFG_wl1_ssid blank
save_setting BALCFG_wl1_channel blank
save_setting BALCFG_wl1_txpwr blank
fi
# PORT 3
save_setting BALCFG_vlan6hwname blank
save_setting BALCFG_vlan6ports blank
save_setting BALCFG_port3_ifname blank
save_setting BALCFG_port3_proto blank
save_setting BALCFG_port3_ipaddr blank
save_setting BALCFG_port3_netmask blank
# PORT 3 - WIFI
save_setting BALCFG_wl2_ifname blank
save_setting BALCFG_wl2_mode blank
save_setting BALCFG_wl2_ssid blank
save_setting BALCFG_wl2_channel blank
save_setting BALCFG_wl2_txpwr blank
# PORT 4
save_setting BALCFG_vlan8hwname blank
save_setting BALCFG_vlan8ports blank
save_setting BALCFG_port4_ifname blank
save_setting BALCFG_port4_proto blank
save_setting BALCFG_port4_ipaddr blank
save_setting BALCFG_port4_netmask blank
# Internet - PPPOE
#
# OpeVPN
#
# Services
save_setting BALCFG_obelisco_dhcpd_enable true
save_setting BALCFG_obelisco_httpd_enable true
save_setting BALCFG_obelisco_olsrd_enable true
save_setting BALCFG_obelisco_balls_update_enable true
# MMC
#
;;
("${CFG_NODE_TYPE4}")
# DHCP Server enabled, HTTPD Server enabled, OLSR enabled
# Switch PORT2 on VLAN4, Switch PORT3 on VLAN6
#
if [ ${CFG_HW_VLAN_SUPPORT} -eq 0 ]
then
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, su hardware no soporta este tipo de configuración"
fi
#
#save_setting BALCFG_ifup_interfaces lan#wan#wifi#port2#port3
BALCFG_ifup_interfaces="lan#wan#wifi#port2#port3"
# LAN
save_setting BALCFG_vlan0hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan0ports 0#3#5#
else
save_setting BALCFG_vlan0ports 1#4#5#
fi
save_setting BALCFG_lan_ifnames ${CFG_HW_LAN}#${CFG_HW_WIFI}
# WIFI
save_setting BALCFG_wl0_mode ap
# WDS
#
# WAN
save_setting BALCFG_vlan1hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan1ports 4#5
else
save_setting BALCFG_vlan1ports 0#5
fi
# PORT 1
#
# PORT 2
save_setting BALCFG_vlan4hwname et0
save_setting BALCFG_vlan4ports 2#5
save_setting BALCFG_port2_ifname ${CFG_HW_PORT2}
save_setting BALCFG_port2_proto static
ask_user "PORT2 IP Address" BALCFG_port2_ipaddr ${BALCFG_port2_ipaddr}
[ ${CFG_RETURN} != ${BALCFG_port2_ipaddr} ] && BALCFG_port2_netmask=$(set_netmask ${CFG_RETURN})
ask_user "PORT2 Netmask" BALCFG_port2_netmask ${BALCFG_port2_netmask}
# PORT 2 - WIFI
if [ "${CFG_HW_PORT2_ISWIFI}" = "true" ]
then
save_setting BALCFG_wl1_ifname ${CFG_HW_PORT2}
ask_user "PORT2 Wireless Mode [ap|sta]" CFG_wl1_mode ${BALCFG_wl1_mode}
case "${CFG_RETURN}" in
("ap"|"sta")
save_setting BALCFG_wl1_mode ${CFG_RETURN}
;;
(*)
save_setting BALCFG_wl1_mode ""
display_msg_error "Error, la respuesta debe ser ap o sta"
;;
esac
ask_user "PORT2 Wireless SSID" BALCFG_wl1_ssid ${BALCFG_wl1_ssid}
ask_user "PORT2 Wireless Channel" BALCFG_wl1_channel ${BALCFG_wl1_channel}
if [ "${CFG_TYPE}" = "extra" ]
then
ask_user "Extra: PORT2 Wireless TX Power en miliwatts" BALCFG_wl1_txpwr ${BALCFG_wl1_txpwr}
else
save_setting BALCFG_wl1_txpwr blank
fi
else
save_setting BALCFG_wl1_ifname blank
save_setting BALCFG_wl1_mode blank
save_setting BALCFG_wl1_ssid blank
save_setting BALCFG_wl1_channel blank
save_setting BALCFG_wl1_txpwr blank
fi
# PORT 3
save_setting BALCFG_vlan6hwname et0
if [ ${CFG_HW_SWITCH_ORDER} = "reverse" ]
then
save_setting BALCFG_vlan6ports 1#5
else
save_setting BALCFG_vlan6ports 3#5
fi
save_setting BALCFG_port3_ifname ${CFG_HW_PORT3}
save_setting BALCFG_port3_proto static
ask_user "PORT3 IP Address" BALCFG_port3_ipaddr ${BALCFG_port3_ipaddr}
[ ${CFG_RETURN} != ${BALCFG_port3_ipaddr} ] && BALCFG_port3_netmask=$(set_netmask ${CFG_RETURN})
ask_user "PORT3 Netmask" BALCFG_port3_netmask ${BALCFG_port3_netmask}
# PORT 3 - WIFI
if [ "${CFG_HW_PORT3_ISWIFI}" = "true" ]
then
save_setting BALCFG_wl2_ifname ${CFG_HW_PORT3}
ask_user "PORT3 Wireless Mode [ap|sta]" CFG_wl2_mode ${BALCFG_wl2_mode}
case "${CFG_RETURN}" in
("ap"|"sta")
save_setting BALCFG_wl2_mode ${CFG_RETURN}
;;
(*)
save_setting BALCFG_wl2_mode ""
display_msg_error "Error, la respuesta debe ser ap o sta"
;;
esac
ask_user "PORT3 Wireless SSID" BALCFG_wl2_ssid ${BALCFG_wl2_ssid}
ask_user "PORT3 Wireless Channel" BALCFG_wl2_channel ${BALCFG_wl2_channel}
if [ "${CFG_TYPE}" = "extra" ]
then
ask_user "Extra: PORT3 Wireless TX Power en miliwatts" BALCFG_wl2_txpwr ${BALCFG_wl2_txpwr}
else
save_setting BALCFG_wl2_txpwr blank
fi
else
save_setting BALCFG_wl2_ifname blank
save_setting BALCFG_wl2_mode blank
save_setting BALCFG_wl2_ssid blank
save_setting BALCFG_wl2_channel blank
save_setting BALCFG_wl2_txpwr blank
fi
# PORT 4
save_setting BALCFG_vlan8hwname blank
save_setting BALCFG_vlan8ports blank
save_setting BALCFG_port4_ifname blank
save_setting BALCFG_port4_proto blank
save_setting BALCFG_port4_ipaddr blank
save_setting BALCFG_port4_netmask blank
# Internet - PPPOE
#
# OpenVPN
#
# Services
save_setting BALCFG_obelisco_dhcpd_enable true
save_setting BALCFG_obelisco_httpd_enable true
save_setting BALCFG_obelisco_olsrd_enable true
save_setting BALCFG_obelisco_balls_update_enable true
# MMC
#
;;
(*)
# Error
save_setting BALCFG_obelisco_node_type ""
display_msg_error "Error, Tipo de Nodo incorrecto, debe ser ${CFG_NODE_TYPE1} o ${CFG_NODE_TYPE2} o ${CFG_NODE_TYPE3} o ${CFG_NODE_TYPE4}"
;;
esac
# OLSR, WDS, Internet, PortalCautivo, OpenVPN and MMC
if [ ${BALCFG_obelisco_node_type} != "${CFG_NODE_TYPE1}" ]
then
# OLSR
CFG_obelisco_olsrd_hna4="$(int2ip $(($(ip2int ${BALCFG_lan_ipaddr})&$(ip2int ${BALCFG_lan_netmask}))))"
CFG_obelisco_olsrd_hna4="${CFG_obelisco_olsrd_hna4}#${BALCFG_lan_netmask}"
# WDS
case "${BALCFG_obelisco_wds_enable}" in
("true")
CFG_obelisco_wds_enable="si"
;;
("false")
CFG_obelisco_wds_enable="no"
;;
(*)
CFG_obelisco_wds_enable="no"
;;
esac
if [ "${CFG_TYPE}" = "extra" ]
then
display_msg "Extra: WDS (Wireless Distribution System)"
ask_user "Configurar WDS [si|no]?" CFG_obelisco_wds_enable ${CFG_obelisco_wds_enable}
CFG_obelisco_wds_enable=${CFG_RETURN}
case "${CFG_obelisco_wds_enable}" in
("si")
BALCFG_ifup_interfaces="wds#${BALCFG_ifup_interfaces}"
save_setting BALCFG_obelisco_wds_enable true
save_setting BALCFG_wl0_lazywds 0
ask_user "Listado de direcciones MAC habilitadas, separadas por #" BALCFG_wl0_wds ${BALCFG_wl0_wds}
save_setting BALCFG_wds_ifname br1
save_setting BALCFG_wds_ifnames wds0.49153
save_setting BALCFG_wds_proto static
ask_user "WDS IP Address" BALCFG_wds_ipaddr ${BALCFG_wds_ipaddr}
[ ${CFG_RETURN} != ${BALCFG_wds_ipaddr} ] && BALCFG_wds_netmask=$(set_netmask ${CFG_RETURN})
ask_user "WDS Netmask" BALCFG_wds_netmask ${BALCFG_wds_netmask}
save_setting BALCFG_wds_gateway ${BALCFG_wds_gateway}
save_setting BALCFG_wds_dns ${BALCFG_wds_dns}
save_setting BALCFG_wds_hostname ${BALCFG_wds_hostname}
save_setting BALCFG_wds_stp 1
save_setting BALCFG_wds_static_route ${BALCFG_wds_static_route}
;;
("no")
save_setting BALCFG_obelisco_wds_enable false
save_setting BALCFG_wl0_lazywds blank
save_setting BALCFG_wl0_wds blank
save_setting BALCFG_wds_ifname blank
save_setting BALCFG_wds_ifnames blank
save_setting BALCFG_wds_proto blank
save_setting BALCFG_wds_ipaddr blank
save_setting BALCFG_wds_netmask blank
save_setting BALCFG_wds_gateway blank
save_setting BALCFG_wds_dns blank
save_setting BALCFG_wds_hostname blank
save_setting BALCFG_wds_stp blank
save_setting BALCFG_wds_static_route blank
;;
(*)
save_setting BALCFG_obelisco_wds_enable ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
else
save_setting BALCFG_obelisco_wds_enable ${BALCFG_obelisco_wds_enable}
save_setting BALCFG_wl0_lazywds ${BALCFG_wl0_lazywds}
save_setting BALCFG_wl0_wds ${BALCFG_wl0_wds}
save_setting BALCFG_wds_ifname ${BALCFG_wds_ifname}
save_setting BALCFG_wds_ifnames ${BALCFG_wds_ifnames}
save_setting BALCFG_wds_proto ${BALCFG_wds_proto}
save_setting BALCFG_wds_ipaddr ${BALCFG_wds_ipaddr}
save_setting BALCFG_wds_netmask ${BALCFG_wds_netmask}
save_setting BALCFG_wds_gateway ${BALCFG_wds_gateway}
save_setting BALCFG_wds_dns ${BALCFG_wds_dns}
save_setting BALCFG_wds_hostname ${BALCFG_wds_hostname}
save_setting BALCFG_wds_stp ${BALCFG_wds_stp}
save_setting BALCFG_wds_static_route ${BALCFG_wds_static_route}
fi
save_setting BALCFG_ifup_interfaces ${BALCFG_ifup_interfaces}
# Internet
case "${BALCFG_wan_ifname}" in
("none")
CFG_obelisco_internet="no"
save_setting BALCFG_obelisco_internet false
save_setting BALCFG_obelisco_internet_type none
save_setting BALCFG_wan_ifname none
save_setting BALCFG_wan_proto none
save_setting BALCFG_wan_ipaddr blank
save_setting BALCFG_wan_netmask blank
save_setting BALCFG_wan_gateway blank
save_setting BALCFG_wan_dns blank
save_setting BALCFG_ppp_idletime blank
save_setting BALCFG_ppp_mtu blank
save_setting BALCFG_ppp_redialperiod blank
save_setting BALCFG_ppp_username blank
save_setting BALCFG_ppp_passwd blank
save_setting BALCFG_pppoe_ifname blank
save_setting BALCFG_pppoe_idletime blank
save_setting BALCFG_pppoe_username blank
save_setting BALCFG_pppoe_passwd blank
;;
(*)
case "${BALCFG_obelisco_internet}" in
("true")
CFG_obelisco_internet="si"
;;
("false")
CFG_obelisco_internet="no"
;;
(*)
CFG_obelisco_internet="no"
;;
esac
display_msg "Acceso a Internet"
ask_user "Configurar Internet [si|no]" CFG_obelisco_internet ${CFG_obelisco_internet}
CFG_obelisco_internet=${CFG_RETURN}
case "${CFG_obelisco_internet}" in
("si")
save_setting BALCFG_obelisco_internet true
case "${BALCFG_obelisco_internet_type}" in
("static"|"dhcp"|"pppoe")
# nothing
;;
(*)
BALCFG_obelisco_internet_type=dhcp
;;
esac
ask_user "Tipo de acceso [static|dhcp|pppoe]" BALCFG_obelisco_internet_type ${BALCFG_obelisco_internet_type}
BALCFG_obelisco_internet_type=${CFG_RETURN}
case "${BALCFG_obelisco_internet_type}" in
("static")
save_setting BALCFG_wan_ifname ${CFG_HW_WAN}
save_setting BALCFG_wan_proto static
ask_user "WAN IP Address" BALCFG_wan_ipaddr ${BALCFG_wan_ipaddr}
[ ${CFG_RETURN} != ${BALCFG_wan_ipaddr} ] && BALCFG_wan_netmask=$(set_netmask ${CFG_RETURN})
BALCFG_wan_ipaddr=${CFG_RETURN}
ask_user "WAN Netmask" BALCFG_wan_netmask ${BALCFG_wan_netmask}
BALCFG_wan_netmask=${CFG_RETURN}
BALCFG_First_IP=$(int2ip $(($(($(ip2int ${BALCFG_wan_ipaddr})&$(ip2int ${BALCFG_wan_netmask})))+1)))
[ $? -ne 0 ] && display_msg_error "Error: Dirección IP incorrecta"
if [ "${BALCFG_First_IP}" != "${BALCFG_wan_ipaddr}" ]
then
BALCFG_wan_gateway=${BALCFG_First_IP}
BALCFG_wan_dns=${BALCFG_First_IP}
fi
ask_user "WAN Default Gateway" BALCFG_wan_gateway ${BALCFG_wan_gateway}
[ "${BALCFG_wan_gateway}" != "${CFG_RETURN}" ] && BALCFG_wan_dns=${CFG_RETURN}
ask_user "WAN DNS Server" BALCFG_wan_dns ${BALCFG_wan_dns}
save_setting BALCFG_ppp_idletime blank
save_setting BALCFG_ppp_mtu blank
save_setting BALCFG_ppp_redialperiod blank
save_setting BALCFG_ppp_username blank
save_setting BALCFG_ppp_passwd blank
save_setting BALCFG_pppoe_ifname blank
save_setting BALCFG_pppoe_idletime blank
save_setting BALCFG_pppoe_username blank
save_setting BALCFG_pppoe_passwd blank
;;
("dhcp")
save_setting BALCFG_wan_ifname ${CFG_HW_WAN}
save_setting BALCFG_wan_proto dhcp
save_setting BALCFG_wan_ipaddr blank
save_setting BALCFG_wan_netmask blank
save_setting BALCFG_wan_gateway blank
save_setting BALCFG_wan_dns blank
save_setting BALCFG_ppp_idletime blank
save_setting BALCFG_ppp_mtu blank
save_setting BALCFG_ppp_redialperiod blank
save_setting BALCFG_ppp_username blank
save_setting BALCFG_ppp_passwd blank
save_setting BALCFG_pppoe_ifname blank
save_setting BALCFG_pppoe_idletime blank
save_setting BALCFG_pppoe_username blank
save_setting BALCFG_pppoe_passwd blank
;;
("pppoe")
save_setting BALCFG_wan_ifname ppp0
save_setting BALCFG_wan_proto pppoe
save_setting BALCFG_wan_ipaddr blank
save_setting BALCFG_wan_netmask blank
save_setting BALCFG_wan_gateway blank
save_setting BALCFG_wan_dns blank
save_setting BALCFG_ppp_idletime 10
save_setting BALCFG_ppp_mtu 1492
save_setting BALCFG_ppp_redialperiod 15
save_setting BALCFG_pppoe_ifname ${CFG_HW_WAN}
ask_user "Usuario ISP" BALCFG_ppp_username ${BALCFG_ppp_username}
ask_user "Contraseña ISP" BALCFG_ppp_passwd ${BALCFG_ppp_passwd}
;;
(*)
# Error
save_setting BALCFG_obelisco_internet_type ""
display_msg_error "Error, Tipo de acceso a Internet incorrecto, debe ser dhcp o pppoe"
;;
esac
case "${BALCFG_obelisco_internet_type}" in
("static"|"dhcp")
if [ "${CFG_TYPE}" = "extra" ]
then
case "${BALCFG_obelisco_wan_nat_enable}" in
("true")
CFG_obelisco_wan_nat_enable="si"
;;
("false")
CFG_obelisco_wan_nat_enable="no"
;;
(*)
CFG_obelisco_wan_nat_enable="no"
;;
esac
ask_user "Extra: Habilitar NAT en puerto WAN [si|no]" CFG_obelisco_wan_nat_enable ${CFG_obelisco_wan_nat_enable}
CFG_obelisco_wan_nat_enable=${CFG_RETURN}
case "${CFG_obelisco_wan_nat_enable}" in
("si")
save_setting BALCFG_obelisco_wan_nat_enable true
;;
("no")
save_setting BALCFG_obelisco_wan_nat_enable false
;;
(*)
save_setting BALCFG_obelisco_wan_nat_enable ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
else
save_setting BALCFG_obelisco_wan_nat_enable ${BALCFG_obelisco_wan_nat_enable}
fi
;;
(*)
save_setting BALCFG_obelisco_wan_nat_enable true
;;
esac
# OLSR
CFG_obelisco_olsrd_hna4="0.0.0.0#0.0.0.0#$CFG_obelisco_olsrd_hna4"
;;
("no")
save_setting BALCFG_obelisco_internet false
save_setting BALCFG_obelisco_internet_type none
save_setting BALCFG_wan_ifname ${CFG_HW_WAN}
save_setting BALCFG_wan_proto none
save_setting BALCFG_wan_ipaddr blank
save_setting BALCFG_wan_netmask blank
save_setting BALCFG_wan_gateway blank
save_setting BALCFG_wan_dns blank
save_setting BALCFG_ppp_idletime blank
save_setting BALCFG_ppp_mtu blank
save_setting BALCFG_ppp_redialperiod blank
save_setting BALCFG_ppp_username blank
save_setting BALCFG_ppp_passwd blank
save_setting BALCFG_pppoe_ifname blank
save_setting BALCFG_pppoe_idletime blank
save_setting BALCFG_pppoe_username blank
save_setting BALCFG_pppoe_passwd blank
;;
(*)
# Error
save_setting BALCFG_obelisco_internet ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
;;
esac
# OLSR
save_setting BALCFG_obelisco_olsrd_hna4 ${CFG_obelisco_olsrd_hna4}
# PortalCautivo
case "${BALCFG_obelisco_portal_enable}" in
("true")
CFG_obelisco_portal_enable="si"
;;
("false")
CFG_obelisco_portal_enable="no"
;;
(*)
CFG_obelisco_portal_enable="si"
;;
esac
display_msg "Funcionalidad Portal Cautivo"
ask_user "Habilitar funcionalidad de Portal Cautivo [si|no]" CFG_obelisco_portal_enable ${CFG_obelisco_portal_enable}
CFG_obelisco_portal_enable=${CFG_RETURN}
case "${CFG_obelisco_portal_enable}" in
("si")
save_setting BALCFG_obelisco_portal_enable true
ask_user "Listado de direcciones IP excluídas, separadas por #" BALCFG_obelisco_portal_hosts ${BALCFG_obelisco_portal_hosts}
if [ "${CFG_TYPE}" = "extra" ]
then
ask_user "Extra: Portal Cautivo, tipo de log [file|syslog]" BALCFG_obelisco_portal_log ${BALCFG_obelisco_portal_log}
case "${CFG_RETURN}" in
(!"file"|!"syslog")
save_setting BALCFG_obelisco_portal_log file
funError "Error, opción inválida"
;;
esac
else
save_setting BALCFG_obelisco_portal_log file
fi
save_setting BALCFG_obelisco_portal_accept ${BALCFG_obelisco_portal_accept}
save_setting BALCFG_obelisco_portal_irc_enable true
;;
("no")
save_setting BALCFG_obelisco_portal_enable false
save_setting BALCFG_obelisco_portal_log file
save_setting BALCFG_obelisco_portal_accept ${BALCFG_obelisco_portal_accept}
save_setting BALCFG_obelisco_portal_irc_enable false
;;
(*)
# Error
save_setting BALCFG_obelisco_portal_enable ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
# OpenVPN
if [ "${CFG_obelisco_internet}" = "si" -a "${CFG_SW_VPN}" = "true" ]
then
if [ "${CFG_TYPE}" = "extra" ]
then
display_msg "Extra: Túneles por Internet con OpenVPN"
display_msg2 "Por favor, leer bien la documentación de Obelisco para entender que implica activarlo"
# OpenVPN Server
case "${BALCFG_obelisco_vpn0_enable}" in
("true")
CFG_obelisco_vpn0_enable="si"
;;
("false")
CFG_obelisco_vpn0_enable="no"
;;
(*)
CFG_obelisco_vpn0_enable="si"
;;
esac
ask_user "Habilitar servidor OpenVPN [si|no]" CFG_obelisco_vpn0_enable ${CFG_obelisco_vpn0_enable}
CFG_obelisco_vpn0_enable="${CFG_RETURN}"
case "${CFG_obelisco_vpn0_enable}" in
("si")
save_setting BALCFG_obelisco_vpn0_enable true
save_setting BALCFG_vpn0_ifname tap0
save_setting BALCFG_vpn0_port 1195
ask_user "Dirección IP a utilizar en este extremo del túnel" BALCFG_vpn0_ipaddr ${BALCFG_vpn0_ipaddr}
if [ "${CFG_RETURN}" != "blank" ]
then
BALCFG_vpn0_netmask=$(set_netmask ${CFG_RETURN})
BALCFG_vpn0_peer_ipaddr=$(int2ip $(($(ip2int ${CFG_RETURN})+1)))
[ $? -ne 0 ] && display_msg_error "Error: Dirección IP incorrecta"
display_msg "Máscara de red a utilizar en ambos extremos: ${BALCFG_vpn0_netmask}"
save_setting BALCFG_vpn0_netmask ${BALCFG_vpn0_netmask}
display_msg2 "Dirección IP a utilizar en el extremo cliente: ${BALCFG_vpn0_peer_ipaddr}"
save_setting BALCFG_vpn0_peer_ipaddr ${BALCFG_vpn0_peer_ipaddr}
else
save_setting BALCFG_obelisco_vpn0_enable false
display_msg_error "Error, debe especificar una dirección IP"
fi
;;
("no")
save_setting BALCFG_obelisco_vpn0_enable false
save_setting BALCFG_vpn0_ifname blank
save_setting BALCFG_vpn0_port blank
save_setting BALCFG_vpn0_ipaddr blank
save_setting BALCFG_vpn0_netmask blank
save_setting BALCFG_vpn0_peer_ipaddr blank
;;
(*)
# Error
save_setting BALCFG_obelisco_vpn0_enable ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
# OpenVPN Client
case "${BALCFG_obelisco_vpn1_enable}" in
("true")
CFG_obelisco_vpn1_enable="si"
;;
("false")
CFG_obelisco_vpn1_enable="no"
;;
(*)
CFG_obelisco_vpn1_enable="si"
;;
esac
ask_user "Habilitar cliente OpenVPN [si|no]" CFG_obelisco_vpn1_enable ${CFG_obelisco_vpn1_enable}
CFG_obelisco_vpn1_enable="${CFG_RETURN}"
case "${CFG_obelisco_vpn1_enable}" in
("si")
save_setting BALCFG_obelisco_vpn1_enable true
save_setting BALCFG_vpn1_ifname tap1
save_setting BALCFG_vpn1_port 1195
ask_user "Dirección IP en Internet del Servidor" BALCFG_vpn1_remote ${BALCFG_vpn1_remote}
[ "${BALCFG_vpn1_remote}" != "${CFG_RETURN}" ] && BALCFG_vpn1_remote="${CFG_RETURN}"
if [ "${BALCFG_vpn1_remote}" != "auto" ]
then
ask_user "Dirección IP a utilizar en este extremo del túnel" BALCFG_vpn1_ipaddr ${BALCFG_vpn1_ipaddr}
if [ "${CFG_RETURN}" != "blank" ]
then
BALCFG_vpn1_peer_ipaddr=$(int2ip $(($(ip2int ${CFG_RETURN})-1)))
[ $? -ne 0 ] && display_msg_error "Error: Dirección IP incorrecta"
BALCFG_vpn1_netmask=$(set_netmask ${CFG_RETURN})
display_msg "Máscara de red a utilizar en ambos extremos: ${BALCFG_vpn1_netmask}"
save_setting BALCFG_vpn1_netmask ${BALCFG_vpn1_netmask}
display_msg2 "Dirección IP a utilizar en el extremo server: ${BALCFG_vpn1_peer_ipaddr}"
save_setting BALCFG_vpn1_peer_ipaddr ${BALCFG_vpn1_peer_ipaddr}
else
save_setting BALCFG_obelisco_vpn1_enable false
display_msg_error "Error, debe especificar una dirección IP"
fi
else
save_setting BALCFG_vpn1_ipaddr blank
save_setting BALCFG_vpn1_netmask blank
save_setting BALCFG_vpn1_peer_ipaddr blank
fi
;;
("no")
save_setting BALCFG_obelisco_vpn1_enable false
save_setting BALCFG_vpn1_ifname blank
save_setting BALCFG_vpn1_port blank
save_setting BALCFG_vpn1_remote blank
save_setting BALCFG_vpn1_ipaddr blank
save_setting BALCFG_vpn1_netmask blank
save_setting BALCFG_vpn1_peer_ipaddr blank
;;
(*)
# Error
save_setting BALCFG_obelisco_vpn1_enable ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
else
save_setting BALCFG_obelisco_vpn0_enable ${BALCFG_obelisco_vpn0_enable}
save_setting BALCFG_vpn0_ifname ${BALCFG_vpn0_ifname}
save_setting BALCFG_vpn0_port ${BALCFG_vpn0_port}
save_setting BALCFG_vpn0_ipaddr ${BALCFG_vpn0_ipaddr}
save_setting BALCFG_vpn0_netmask ${BALCFG_vpn0_netmask}
save_setting BALCFG_vpn0_peer_ipaddr ${BALCFG_vpn0_peer_ipaddr}
save_setting BALCFG_obelisco_vpn1_enable ${BALCFG_obelisco_vpn1_enable}
save_setting BALCFG_vpn1_ifname ${BALCFG_vpn1_ifname}
save_setting BALCFG_vpn1_port ${BALCFG_vpn1_port}
save_setting BALCFG_vpn1_remote ${BALCFG_vpn1_remote}
save_setting BALCFG_vpn1_ipaddr ${BALCFG_vpn1_ipaddr}
save_setting BALCFG_vpn1_netmask ${BALCFG_vpn1_netmask}
save_setting BALCFG_vpn1_peer_ipaddr ${BALCFG_vpn1_peer_ipaddr}
fi
else
# OpenVPN is not enabled when Internet is not available
save_setting BALCFG_obelisco_vpn0_enable false
save_setting BALCFG_vpn0_ifname blank
save_setting BALCFG_vpn0_port blank
save_setting BALCFG_vpn0_ipaddr blank
save_setting BALCFG_vpn0_netmask blank
save_setting BALCFG_vpn0_peer_ipaddr blank
save_setting BALCFG_obelisco_vpn1_enable false
save_setting BALCFG_vpn1_ifname blank
save_setting BALCFG_vpn1_port blank
save_setting BALCFG_vpn1_remote blank
save_setting BALCFG_vpn1_ipaddr blank
save_setting BALCFG_vpn1_netmask blank
save_setting BALCFG_vpn1_peer_ipaddr blank
fi
# MMC
if [ "${CFG_TYPE}" = "extra" ]
then
if [ -n "${BALCFG_obelisco_mmc_driver}" -a "${BALCFG_obelisco_mmc_driver}" != "na" ]
then
display_msg "Extra: MMC/SD Mod"
case "${BALCFG_obelisco_mmc_enable}" in
("true")
CFG_obelisco_mmc_enable="si"
;;
("false")
CFG_obelisco_mmc_enable="no"
;;
(*)
CFG_obelisco_mmc_enable="si"
;;
esac
ask_user "Habilitar soporte MMC/SD [si|no]" CFG_obelisco_mmc_enable ${CFG_obelisco_mmc_enable}
CFG_obelisco_mmc_enable="${CFG_RETURN}"
case "${CFG_obelisco_mmc_enable}" in
("si")
save_setting BALCFG_obelisco_mmc_enable true
save_setting BALCFG_obelisco_mmc_driver ${BALCFG_obelisco_mmc_driver}
;;
("no")
save_setting BALCFG_obelisco_mmc_enable false
save_setting BALCFG_obelisco_mmc_driver ${BALCFG_obelisco_mmc_driver}
;;
(*)
# Error
save_setting BALCFG_obelisco_mmc_enable ""
display_msg_error "Error, respuesta incorrecta, debe ser si o no"
;;
esac
fi
fi
fi
;;
esac
#
#
# Configuration file processing
# -----------------------------------------
echo
[ "${CFG_TYPE}" != "test" ] && display_msg "No detener la ejecución !!!, aplicando en memoria la configuración..."
clear_variables
get_cfg_from_file
# Configuration file MUST be ok starting from here
backup_cfgfile
set_cfg_nvram
set_cfg_hosts_file
set_cfg_portal
case "${CFG_TYPE}" in
("kamikaze"|"auto"|"defaults")
display_msg "GUARDANDO CAMBIOS EN NVRAM !!!"
$nvram commit && display_msg "REBOOT !!!" && reboot
;;
("normal"|"extra")
display_msg "Configuración aplicada en memoria !!"
ask_user "Guardar definitivamente los cambios de configuración ? [si|no]" CFG_COMMIT ${CFG_COMMIT}
if [ "${CFG_RETURN}" = "si" ]
then
display_msg "Guardando cambios... se reiniciará el equipo..."
$nvram commit && display_msg "REBOOT !!!" && reboot
else
display_msg_error "Advertencia: No se guardaron los cambios"
fi
;;
esac
echo
#