utils should only contain functions
This commit is contained in:
parent
e3627b666f
commit
f7dca26bd3
|
@ -37,6 +37,7 @@ HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
|
||||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
|
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
|
||||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
|
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
|
||||||
|
|
||||||
|
mesh_protocol_init
|
||||||
update_wifi_adaptors
|
update_wifi_adaptors
|
||||||
|
|
||||||
if [ ! $IFACE ]; then
|
if [ ! $IFACE ]; then
|
||||||
|
|
|
@ -37,6 +37,7 @@ HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
|
||||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
|
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
|
||||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
|
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
|
||||||
|
|
||||||
|
mesh_protocol_init
|
||||||
update_wifi_adaptors
|
update_wifi_adaptors
|
||||||
|
|
||||||
if [ ! $IFACE ]; then
|
if [ ! $IFACE ]; then
|
||||||
|
|
|
@ -28,56 +28,58 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if [[ $1 == "start" ]]; then
|
function mesh_protocol_init {
|
||||||
# install avahi
|
if [[ $1 == "start" ]]; then
|
||||||
sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
|
# install avahi
|
||||||
sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
|
sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
|
||||||
sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf
|
sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
|
||||||
sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf
|
sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf
|
||||||
sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" /etc/avahi/avahi-daemon.conf
|
sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf
|
||||||
sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf
|
sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" /etc/avahi/avahi-daemon.conf
|
||||||
fi
|
sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf
|
||||||
|
|
||||||
# Mesh definition
|
|
||||||
WIFI_SSID='mesh'
|
|
||||||
if [ -f $COMPLETION_FILE ]; then
|
|
||||||
if grep -q "WIFI_SSID:" $COMPLETION_FILE; then
|
|
||||||
WIFI_SSID=$(cat $COMPLETION_FILE | grep "WIFI_SSID:" | awk -F ':' '{print $2}')
|
|
||||||
fi
|
fi
|
||||||
sed -i "s|WIFI_SSID:.*|WIFI_SSID:${WIFI_SSID}|g" $COMPLETION_FILE
|
|
||||||
fi
|
|
||||||
CELLID='any'
|
|
||||||
|
|
||||||
CHANNEL=2
|
# Mesh definition
|
||||||
HOTSPOT_CHANNEL=6
|
WIFI_SSID='mesh'
|
||||||
if [ -f $COMPLETION_FILE ]; then
|
if [ -f $COMPLETION_FILE ]; then
|
||||||
if grep -q "Wifi channel:" $COMPLETION_FILE; then
|
if grep -q "WIFI_SSID:" $COMPLETION_FILE; then
|
||||||
CHANNEL=$(cat $COMPLETION_FILE | grep "Wifi channel:" | awk -F ':' '{print $2}')
|
WIFI_SSID=$(cat $COMPLETION_FILE | grep "WIFI_SSID:" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
sed -i "s|WIFI_SSID:.*|WIFI_SSID:${WIFI_SSID}|g" $COMPLETION_FILE
|
||||||
fi
|
fi
|
||||||
sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE
|
CELLID='any'
|
||||||
fi
|
|
||||||
|
|
||||||
ZERONET_PORT=15441
|
CHANNEL=2
|
||||||
IPFS_PORT=4001
|
HOTSPOT_CHANNEL=6
|
||||||
TOX_PORT=33445
|
if [ -f $COMPLETION_FILE ]; then
|
||||||
TRACKER_PORT=6969
|
if grep -q "Wifi channel:" $COMPLETION_FILE; then
|
||||||
LIBREVAULT_PORT=42345
|
CHANNEL=$(cat $COMPLETION_FILE | grep "Wifi channel:" | awk -F ':' '{print $2}')
|
||||||
TAHOELAFS_PORT=50213
|
fi
|
||||||
GIT_SSB_PORT=7718
|
sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE
|
||||||
NGINX_GIT_SSB_PORT=7719
|
fi
|
||||||
|
|
||||||
# Ethernet bridge definition (bridged to bat0)
|
ZERONET_PORT=15441
|
||||||
BRIDGE=br-mesh
|
IPFS_PORT=4001
|
||||||
BRIDGE_HOTSPOT=br-hotspot
|
TOX_PORT=33445
|
||||||
IFACE=
|
TRACKER_PORT=6969
|
||||||
IFACE_SECONDARY=
|
LIBREVAULT_PORT=42345
|
||||||
EIFACE=eth0
|
TAHOELAFS_PORT=50213
|
||||||
WLAN_ADAPTORS=$(count_wlan)
|
GIT_SSB_PORT=7718
|
||||||
|
NGINX_GIT_SSB_PORT=7719
|
||||||
|
|
||||||
if [ $WLAN_ADAPTORS -eq 0 ]; then
|
# Ethernet bridge definition (bridged to bat0)
|
||||||
echo $'No wlan adaptors found'
|
BRIDGE=br-mesh
|
||||||
exit 0
|
BRIDGE_HOTSPOT=br-hotspot
|
||||||
fi
|
IFACE=
|
||||||
|
IFACE_SECONDARY=
|
||||||
|
EIFACE=eth0
|
||||||
|
WLAN_ADAPTORS=$(count_wlan)
|
||||||
|
|
||||||
|
if [ $WLAN_ADAPTORS -eq 0 ]; then
|
||||||
|
echo $'No wlan adaptors found'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function get_ipv4_wlan {
|
function get_ipv4_wlan {
|
||||||
echo $(ip -o -f inet addr show dev "$IFACE" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')
|
echo $(ip -o -f inet addr show dev "$IFACE" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')
|
||||||
|
|
Loading…
Reference in New Issue