Merge branch 'stretch' of https://github.com/bashrc/freedombone
This commit is contained in:
commit
fcff148f07
|
@ -373,19 +373,49 @@ function mesh_install_dat {
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
npm install --arch=$NPM_ARCH -g dat
|
npm install --arch=$NPM_ARCH -g dat
|
||||||
npm install --arch=$NPM_ARCH -g @garbados/dat-boi
|
npm install --arch=$NPM_ARCH -g @garbados/dat-boi
|
||||||
npm install --arch=$NPM_ARCH -g add-to-systemd
|
|
||||||
add-to-systemd dat-boi --user "$(whoami)" "$(which dat-boi)"
|
|
||||||
EOF
|
EOF
|
||||||
chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
|
chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
|
||||||
chroot "$rootdir" /usr/bin/install_dat
|
chroot "$rootdir" /usr/bin/install_dat
|
||||||
rm "$rootdir/usr/bin/install_dat"
|
rm "$rootdir/usr/bin/install_dat"
|
||||||
|
|
||||||
|
{ echo '[Unit]';
|
||||||
|
echo 'Description=DAT-boi';
|
||||||
|
echo 'After=syslog.target';
|
||||||
|
echo 'After=network.target';
|
||||||
|
echo '';
|
||||||
|
echo '[Service]';
|
||||||
|
echo 'Type=simple';
|
||||||
|
echo 'User=root';
|
||||||
|
echo 'Group=root';
|
||||||
|
echo 'ExecStart=/usr/local/bin/dat-boi';
|
||||||
|
echo 'Restart=always';
|
||||||
|
echo '';
|
||||||
|
echo '[Install]';
|
||||||
|
echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/dat-boi.service"
|
||||||
|
chmod +x "$rootdir/etc/systemd/system/dat-boi.service"
|
||||||
|
chroot "$rootdir" systemctl enable dat-boi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_dat {
|
function install_dat {
|
||||||
npm install -g dat
|
npm install -g dat
|
||||||
npm install -g @garbados/dat-boi
|
npm install -g @garbados/dat-boi
|
||||||
npm install -g add-to-systemd
|
|
||||||
add-to-systemd dat-boi --user "$(whoami)" "$(which dat-boi)"
|
{ echo '[Unit]';
|
||||||
|
echo 'Description=DAT-boi';
|
||||||
|
echo 'After=syslog.target';
|
||||||
|
echo 'After=network.target';
|
||||||
|
echo '';
|
||||||
|
echo '[Service]';
|
||||||
|
echo 'Type=simple';
|
||||||
|
echo 'User=root';
|
||||||
|
echo 'Group=root';
|
||||||
|
echo 'ExecStart=/usr/local/bin/dat-boi';
|
||||||
|
echo 'Restart=always';
|
||||||
|
echo '';
|
||||||
|
echo '[Install]';
|
||||||
|
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/dat-boi.service
|
||||||
|
chmod +x /etc/systemd/system/dat-boi.service
|
||||||
|
systemctl enable dat-boi
|
||||||
}
|
}
|
||||||
|
|
||||||
function mesh_install_scuttlebot {
|
function mesh_install_scuttlebot {
|
||||||
|
|
|
@ -143,11 +143,11 @@ BMX7_COMMIT='0a82c7c10fef44b259b35e77ab33632aa132d219'
|
||||||
|
|
||||||
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
|
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
|
|
||||||
function configure_backports {
|
configure_backports() {
|
||||||
echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main" >> "$rootdir/etc/apt/sources.list"
|
echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main" >> "$rootdir/etc/apt/sources.list"
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_contrib_repo {
|
configure_contrib_repo() {
|
||||||
if ! grep -q "contrib" "$rootdir/etc/apt/sources.list"; then
|
if ! grep -q "contrib" "$rootdir/etc/apt/sources.list"; then
|
||||||
chroot "$rootdir" /bin/sed -i "s| main| main contrib|g" /etc/apt/sources.list
|
chroot "$rootdir" /bin/sed -i "s| main| main contrib|g" /etc/apt/sources.list
|
||||||
fi
|
fi
|
||||||
|
@ -973,6 +973,18 @@ initialise_mesh() {
|
||||||
MESH_STARTUP_PARAMS="${MY_USERNAME} amnesic"
|
MESH_STARTUP_PARAMS="${MY_USERNAME} amnesic"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# command to switch to wired mesh
|
||||||
|
{ echo '#!/bin/bash';
|
||||||
|
echo 'echo -n "eth" > /root/.mesh_interface_type';
|
||||||
|
echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wired"
|
||||||
|
chmod +x "$rootdir/usr/bin/wired"
|
||||||
|
|
||||||
|
# command to switch to wireless mesh
|
||||||
|
{ echo '#!/bin/bash';
|
||||||
|
echo 'echo -n "wlan" > /root/.mesh_interface_type';
|
||||||
|
echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wireless"
|
||||||
|
chmod +x "$rootdir/usr/bin/wireless"
|
||||||
|
|
||||||
{ echo '[Unit]';
|
{ echo '[Unit]';
|
||||||
echo 'Description=Initial mesh router configuration';
|
echo 'Description=Initial mesh router configuration';
|
||||||
echo 'After=syslog.target';
|
echo 'After=syslog.target';
|
||||||
|
@ -995,7 +1007,7 @@ initialise_mesh() {
|
||||||
|
|
||||||
# User interface for USB drive installs ######################################
|
# User interface for USB drive installs ######################################
|
||||||
|
|
||||||
function mesh_client_startup_applications {
|
mesh_client_startup_applications() {
|
||||||
if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
|
if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
|
||||||
mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
|
mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
|
||||||
fi
|
fi
|
||||||
|
@ -1074,7 +1086,7 @@ function mesh_client_startup_applications {
|
||||||
chmod +x "$START_DESKTOP2"
|
chmod +x "$START_DESKTOP2"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mesh_desktop_icons {
|
mesh_desktop_icons() {
|
||||||
if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
|
if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
|
||||||
mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
|
mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
|
||||||
fi
|
fi
|
||||||
|
@ -1092,7 +1104,7 @@ function mesh_desktop_icons {
|
||||||
chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
|
chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_user_interface {
|
configure_user_interface() {
|
||||||
if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
|
if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -1630,7 +1642,7 @@ EOF
|
||||||
# setup_utils
|
# setup_utils
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
function image_install_inadyn {
|
image_install_inadyn() {
|
||||||
if [ "$INSTALLING_MESH" ]; then
|
if [ "$INSTALLING_MESH" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -1693,7 +1705,7 @@ function image_install_inadyn {
|
||||||
echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/freedombone-completed.txt"
|
echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/freedombone-completed.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
function image_setup_utils {
|
image_setup_utils() {
|
||||||
if [ "$INSTALLING_MESH" ]; then
|
if [ "$INSTALLING_MESH" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -1881,12 +1893,12 @@ function image_setup_utils {
|
||||||
#sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
|
#sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
|
||||||
}
|
}
|
||||||
|
|
||||||
function image_install_nodejs {
|
image_install_nodejs() {
|
||||||
mesh_install_nodejs
|
mesh_install_nodejs
|
||||||
#echo 'install_nodejs' >> ${rootdir}/root/${PROJECT_NAME}-completed.txt
|
#echo 'install_nodejs' >> ${rootdir}/root/${PROJECT_NAME}-completed.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
function image_preinstall_repos {
|
image_preinstall_repos() {
|
||||||
if [[ "$VARIANT" == "mesh"* ]]; then
|
if [[ "$VARIANT" == "mesh"* ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -193,7 +193,7 @@ fi
|
||||||
echo $'Changing values within customised customisation script'
|
echo $'Changing values within customised customisation script'
|
||||||
cp "$PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise" "$TEMP_CUSTOMISE3"
|
cp "$PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise" "$TEMP_CUSTOMISE3"
|
||||||
if [ "$MYUSERNAME" ]; then
|
if [ "$MYUSERNAME" ]; then
|
||||||
sed -i "s|MY_USERNAME=.*|MY_USERNAME=${MYUSERNAME}|g" "$TEMP_CUSTOMISE3"
|
sed -i "0,/MY_USERNAME=.*/s//MY_USERNAME=${MYUSERNAME}/" "$TEMP_CUSTOMISE3"
|
||||||
fi
|
fi
|
||||||
if [ "$MYPASSWORD" ]; then
|
if [ "$MYPASSWORD" ]; then
|
||||||
sed -i "s|MY_PASSWORD=.*|MY_PASSWORD=${MYPASSWORD}|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|MY_PASSWORD=.*|MY_PASSWORD=${MYPASSWORD}|g" "$TEMP_CUSTOMISE3"
|
||||||
|
@ -211,7 +211,7 @@ sed -i "s|CONFIG_FILENAME=.*|CONFIG_FILENAME=${CONFIG_FILENAME}|g" "$TEMP_CUSTOM
|
||||||
sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" "$TEMP_CUSTOMISE3"
|
||||||
sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" "$TEMP_CUSTOMISE3"
|
||||||
sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" "$TEMP_CUSTOMISE3"
|
||||||
sed -i "s|SSH_PORT=.*|SSH_PORT=\"${SSH_PORT}\"|g" "$TEMP_CUSTOMISE3"
|
sed -i "0,/SSH_PORT=.*/s//SSH_PORT=\"${SSH_PORT}\"/" "$TEMP_CUSTOMISE3"
|
||||||
sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" "$TEMP_CUSTOMISE3"
|
||||||
sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" "$TEMP_CUSTOMISE3"
|
||||||
sed -i "s|DEBIAN_INSTALL_ONLY=.*|DEBIAN_INSTALL_ONLY=\"${DEBIAN_INSTALL_ONLY}\"|g" "$TEMP_CUSTOMISE3"
|
sed -i "s|DEBIAN_INSTALL_ONLY=.*|DEBIAN_INSTALL_ONLY=\"${DEBIAN_INSTALL_ONLY}\"|g" "$TEMP_CUSTOMISE3"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
# Freedom in the Cloud
|
# Freedom in the Cloud
|
||||||
#
|
#
|
||||||
# Used to enable or disable batman mesh protocol on wlanX
|
# Used to enable or disable batman mesh protocol on a given interface
|
||||||
#
|
#
|
||||||
# License
|
# License
|
||||||
# =======
|
# =======
|
||||||
|
@ -34,22 +34,12 @@ COMPLETION_FILE="/root/${PROJECT_NAME}-completed.txt"
|
||||||
# hotspot passphrase must be 5 characters or longer
|
# hotspot passphrase must be 5 characters or longer
|
||||||
HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
|
HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
|
||||||
|
|
||||||
|
# The type of interface which the mesh will run on
|
||||||
|
MESH_INTERFACE_TYPE='wlan'
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
if [ ! "$IFACE" ]; then
|
|
||||||
echo $'No wlan adaptor'
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e /etc/default/batctl ]; then
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
. /etc/default/batctl
|
|
||||||
fi
|
|
||||||
|
|
||||||
function status {
|
function status {
|
||||||
batctl o
|
batctl o
|
||||||
|
|
||||||
|
@ -84,15 +74,17 @@ function stop {
|
||||||
|
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
if [ "$EIFACE" ]; then
|
if [ "$EIFACE" ]; then
|
||||||
brctl delif "$BRIDGE" bat0
|
if [[ "$EIFACE" != "$IFACE" ]] ; then
|
||||||
ifconfig "$BRIDGE" down || true
|
brctl delif "$BRIDGE" bat0
|
||||||
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
ifconfig "$BRIDGE" down || true
|
||||||
if [[ "$ethernet_connected" != "0" ]]; then
|
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
||||||
systemctl stop hostapd
|
if [[ "$ethernet_connected" != "0" ]]; then
|
||||||
brctl delif "$BRIDGE" "$EIFACE"
|
systemctl stop hostapd
|
||||||
ifconfig "$EIFACE" down -promisc
|
brctl delif "$BRIDGE" "$EIFACE"
|
||||||
|
ifconfig "$EIFACE" down -promisc
|
||||||
|
fi
|
||||||
|
brctl delbr "$BRIDGE"
|
||||||
fi
|
fi
|
||||||
brctl delbr "$BRIDGE"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ifconfig bat0 down -promisc
|
ifconfig bat0 down -promisc
|
||||||
|
@ -100,7 +92,9 @@ function stop {
|
||||||
batctl if del "$IFACE"
|
batctl if del "$IFACE"
|
||||||
ifconfig "$IFACE" mtu 1500
|
ifconfig "$IFACE" mtu 1500
|
||||||
ifconfig "$IFACE" down
|
ifconfig "$IFACE" down
|
||||||
iwconfig "$IFACE" mode managed
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
iwconfig "$IFACE" mode managed
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$IFACE_SECONDARY" ]; then
|
if [ "$IFACE_SECONDARY" ]; then
|
||||||
systemctl stop hostapd
|
systemctl stop hostapd
|
||||||
|
@ -108,7 +102,9 @@ function stop {
|
||||||
batctl if del "$IFACE_SECONDARY"
|
batctl if del "$IFACE_SECONDARY"
|
||||||
ifconfig "$IFACE_SECONDARY" mtu 1500
|
ifconfig "$IFACE_SECONDARY" mtu 1500
|
||||||
ifconfig "$IFACE_SECONDARY" down
|
ifconfig "$IFACE_SECONDARY" down
|
||||||
iwconfig "$IFACE_SECONDARY" mode managed
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
iwconfig "$IFACE_SECONDARY" mode managed
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rmmod batman-adv
|
rmmod batman-adv
|
||||||
|
@ -159,8 +155,10 @@ function add_wifi_interface {
|
||||||
fi
|
fi
|
||||||
ifconfig "$ifname" hw ether "$peermac"
|
ifconfig "$ifname" hw ether "$peermac"
|
||||||
echo $"$ifname assigned MAC address $peermac"
|
echo $"$ifname assigned MAC address $peermac"
|
||||||
iwconfig "$ifname" enc off
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
|
iwconfig "$ifname" enc off
|
||||||
|
iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
|
||||||
|
fi
|
||||||
|
|
||||||
batctl if add "$ifname"
|
batctl if add "$ifname"
|
||||||
ifconfig "$ifname" up
|
ifconfig "$ifname" up
|
||||||
|
@ -168,7 +166,7 @@ function add_wifi_interface {
|
||||||
|
|
||||||
# shellcheck disable=SC2120
|
# shellcheck disable=SC2120
|
||||||
function start {
|
function start {
|
||||||
update_wifi_adaptors
|
update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
|
||||||
|
|
||||||
if [ -z "$IFACE" ] ; then
|
if [ -z "$IFACE" ] ; then
|
||||||
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
|
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
|
||||||
|
@ -194,13 +192,15 @@ function start {
|
||||||
rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
|
rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
|
||||||
|
|
||||||
secondary_wifi_available=
|
secondary_wifi_available=
|
||||||
if [ "$IFACE_SECONDARY" ]; then
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
|
if [ "$IFACE_SECONDARY" ]; then
|
||||||
if [ -d /etc/hostapd ]; then
|
if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
|
||||||
if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
|
if [ -d /etc/hostapd ]; then
|
||||||
secondary_wifi_available=1
|
if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
|
||||||
else
|
secondary_wifi_available=1
|
||||||
echo $'Hotspot passphrase is too short'
|
else
|
||||||
|
echo $'Hotspot passphrase is too short'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -229,21 +229,23 @@ function start {
|
||||||
ifconfig bat0 0.0.0.0
|
ifconfig bat0 0.0.0.0
|
||||||
ethernet_connected='0'
|
ethernet_connected='0'
|
||||||
if [ "$EIFACE" ] ; then
|
if [ "$EIFACE" ] ; then
|
||||||
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
if [[ "$EIFACE" != "$IFACE" ]] ; then
|
||||||
if [[ "$ethernet_connected" != "0" ]]; then
|
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
||||||
echo $'Trying ethernet bridge to the internet'
|
if [[ "$ethernet_connected" != "0" ]]; then
|
||||||
brctl addif "$BRIDGE" "$EIFACE"
|
echo $'Trying ethernet bridge to the internet'
|
||||||
ifconfig "$EIFACE" 0.0.0.0
|
brctl addif "$BRIDGE" "$EIFACE"
|
||||||
ifconfig "$EIFACE" up promisc
|
ifconfig "$EIFACE" 0.0.0.0
|
||||||
echo $'End of ethernet bridge'
|
ifconfig "$EIFACE" up promisc
|
||||||
|
echo $'End of internet bridge'
|
||||||
|
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/babeld ${IFACE} ${EIFACE}|g" /etc/systemd/system/babel.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/babeld ${IFACE} ${EIFACE}|g" /etc/systemd/system/babel.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
else
|
else
|
||||||
echo $"$EIFACE is not connected"
|
echo $"$EIFACE is not connected"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
ifconfig "$BRIDGE" up
|
ifconfig "$BRIDGE" up
|
||||||
|
@ -302,6 +304,9 @@ function start {
|
||||||
}
|
}
|
||||||
|
|
||||||
function monitor {
|
function monitor {
|
||||||
|
if [[ "$MESH_INTERFACE_TYPE" != 'wlan'* ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
if [ -z "$IFACE" ] ; then
|
if [ -z "$IFACE" ] ; then
|
||||||
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
|
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
|
||||||
exit 723657
|
exit 723657
|
||||||
|
@ -357,6 +362,36 @@ function monitor {
|
||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# optionally a file can contain the mesh interface type
|
||||||
|
mesh_interface_type_file=/root/.mesh_interface_type
|
||||||
|
if [ -f "$mesh_interface_type_file" ]; then
|
||||||
|
MESH_INTERFACE_TYPE=$(head -n 1 < "$mesh_interface_type_file")
|
||||||
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
MESH_INTERFACE_TYPE='wlan'
|
||||||
|
fi
|
||||||
|
if [[ "$MESH_INTERFACE_TYPE" == 'eth'* ]]; then
|
||||||
|
MESH_INTERFACE_TYPE='eth'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
mesh_protocol_init
|
||||||
|
|
||||||
|
if [[ "$MESH_INTERFACE_TYPE" == 'eth'* ]]; then
|
||||||
|
MESH_INTERFACE_TYPE='eth'
|
||||||
|
fi
|
||||||
|
|
||||||
|
update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
|
||||||
|
|
||||||
|
if [ ! "$IFACE" ]; then
|
||||||
|
echo $'No wlan adaptor'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e /etc/default/batctl ]; then
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
. /etc/default/batctl
|
||||||
|
fi
|
||||||
|
|
||||||
if ! grep -q "$IFACE" /proc/net/dev; then
|
if ! grep -q "$IFACE" /proc/net/dev; then
|
||||||
echo "Interface \$IFACE was not found"
|
echo "Interface \$IFACE was not found"
|
||||||
stop
|
stop
|
||||||
|
|
|
@ -65,10 +65,10 @@ function mesh_avahi {
|
||||||
sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|use-ipv4=.*|use-ipv4=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
sed -i "s|use-ipv4=.*|use-ipv4=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|use-ipv6=.*|use-ipv6=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
sed -i "s|use-ipv6=.*|use-ipv6=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|#allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
#sed -i "s|#allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
#sed -i "s|allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|#deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
#sed -i "s|#deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
#sed -i "s|deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
sed -i "s|disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
sed -i "s|#publish_addresses=.*|publish_addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
sed -i "s|#publish_addresses=.*|publish_addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
|
||||||
|
|
|
@ -99,11 +99,13 @@ function mesh_protocol_init {
|
||||||
IFACE=
|
IFACE=
|
||||||
IFACE_SECONDARY=
|
IFACE_SECONDARY=
|
||||||
EIFACE=eth0
|
EIFACE=eth0
|
||||||
WLAN_ADAPTORS=$(count_wlan)
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
WLAN_ADAPTORS=$(count_wlan)
|
||||||
|
|
||||||
if [ "$WLAN_ADAPTORS" -eq 0 ]; then
|
if [ "$WLAN_ADAPTORS" -eq 0 ]; then
|
||||||
echo $'No wlan adaptors found'
|
echo $'No wlan adaptors found'
|
||||||
exit 0
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ function setup_wifi_atheros {
|
||||||
fi
|
fi
|
||||||
dpkg -i "$atheros_drivers_file"
|
dpkg -i "$atheros_drivers_file"
|
||||||
reset_usb_devices
|
reset_usb_devices
|
||||||
update_wifi_adaptors
|
update_wifi_adaptors 'wlan'
|
||||||
if [ "$IFACE" ]; then
|
if [ "$IFACE" ]; then
|
||||||
wpa_action "${IFACE}" stop
|
wpa_action "${IFACE}" stop
|
||||||
wpa_cli -i "${IFACE}" terminate
|
wpa_cli -i "${IFACE}" terminate
|
||||||
|
@ -198,19 +198,24 @@ function install_atheros_wifi {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_wifi_adaptors {
|
function update_wifi_adaptors {
|
||||||
|
interface_type="$1"
|
||||||
IFACE=
|
IFACE=
|
||||||
IFACE_SECONDARY=
|
IFACE_SECONDARY=
|
||||||
|
|
||||||
|
if [ ! "$interface_type" ]; then
|
||||||
|
interface_type='wlan'
|
||||||
|
fi
|
||||||
|
|
||||||
for i in $(seq 10 -1 0); do
|
for i in $(seq 10 -1 0); do
|
||||||
ifdown --force "wlan${i}" 2> /dev/null
|
ifdown --force "${interface_type}${i}" 2> /dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $(seq 10 -1 0); do
|
for i in $(seq 10 -1 0); do
|
||||||
if grep -q "wlan${i}" /proc/net/dev; then
|
if grep -q "${interface_type}${i}" /proc/net/dev; then
|
||||||
if [ ! $IFACE ]; then
|
if [ ! $IFACE ]; then
|
||||||
IFACE="wlan${i}"
|
IFACE="wlan${i}"
|
||||||
else
|
else
|
||||||
IFACE_SECONDARY="wlan${i}"
|
IFACE_SECONDARY="${interface_type}${i}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -479,7 +484,7 @@ function wifi_networks_file_header {
|
||||||
|
|
||||||
function create_networks_interactive {
|
function create_networks_interactive {
|
||||||
remove_config_param "WIFI_INTERFACE"
|
remove_config_param "WIFI_INTERFACE"
|
||||||
update_wifi_adaptors
|
update_wifi_adaptors 'wlan'
|
||||||
if [ ! "$IFACE" ]; then
|
if [ ! "$IFACE" ]; then
|
||||||
# Don't try to configure wifi if there are no adaptors
|
# Don't try to configure wifi if there are no adaptors
|
||||||
return
|
return
|
||||||
|
|
|
@ -150,7 +150,7 @@ if [ ! ${wifi_interface_specified} ]; then
|
||||||
else
|
else
|
||||||
sleep "${WAIT_SEC}"
|
sleep "${WAIT_SEC}"
|
||||||
fi
|
fi
|
||||||
update_wifi_adaptors
|
update_wifi_adaptors 'wlan'
|
||||||
if [ ! $IFACE ]; then
|
if [ ! $IFACE ]; then
|
||||||
echo $'No wifi adaptors were found'
|
echo $'No wifi adaptors were found'
|
||||||
exit 872356
|
exit 872356
|
||||||
|
|
Loading…
Reference in New Issue