expand installer: copy files, install ssh server, enable and start wlan2eth service, more checks
This commit is contained in:
parent
06e4269eaa
commit
217555e786
|
@ -29,17 +29,19 @@ if [ "$(id -u)" -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "# PREPARE ENVIRONMENT #"
|
||||||
|
|
||||||
# Reset interfaces
|
# Reset interfaces
|
||||||
iptables -X
|
iptables -X
|
||||||
iptables -F
|
iptables -F
|
||||||
iptables -t nat -X
|
iptables -t nat -X
|
||||||
iptables -t nat -F
|
iptables -t nat -F
|
||||||
echo "Cleared iptables"
|
echo "Erased all iptables rules."
|
||||||
|
|
||||||
ifconfig $WLAN_IFACE down
|
ifconfig $WLAN_IFACE down
|
||||||
ifconfig $WLAN_IFACE hw ether $(ethtool -P $WLAN_IFACE | awk '{print $3}')
|
ifconfig $WLAN_IFACE hw ether $(ethtool -P $WLAN_IFACE | awk '{print $3}')
|
||||||
ifconfig $WLAN_IFACE up
|
ifconfig $WLAN_IFACE up
|
||||||
echo "Reset $WLAN_IFACE"
|
echo "Reset the $WLAN_IFACE WiFi interface."
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
WLAN_IFACE_IP=$(ip -4 -br addr show $WLAN_IFACE | grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")
|
WLAN_IFACE_IP=$(ip -4 -br addr show $WLAN_IFACE | grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")
|
||||||
|
@ -51,6 +53,12 @@ while true; do
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Stop dnsmasq and restore systemd-resolved so we can avoid any DNS issues
|
||||||
|
systemctl stop dnsmasq
|
||||||
|
echo "Stopped dnsmasq."
|
||||||
|
systemctl start systemd-resolved
|
||||||
|
echo "Started systemd-resolved."
|
||||||
|
|
||||||
# We only need to get the $WLAN_IFACE IP address and will copy it over to $ETH_IFACE later
|
# We only need to get the $WLAN_IFACE IP address and will copy it over to $ETH_IFACE later
|
||||||
WLAN_NETMASK=$(ip addr show $WLAN_IFACE | grep -w inet | awk '{print $2}' | cut -d'/' -f2)
|
WLAN_NETMASK=$(ip addr show $WLAN_IFACE | grep -w inet | awk '{print $2}' | cut -d'/' -f2)
|
||||||
WLAN_NETMASK_CIDR=$(ip addr show $WLAN_IFACE | grep -w inet | awk '{print $2}' | cut -d'/' -f2)
|
WLAN_NETMASK_CIDR=$(ip addr show $WLAN_IFACE | grep -w inet | awk '{print $2}' | cut -d'/' -f2)
|
||||||
|
@ -66,16 +74,29 @@ fi
|
||||||
|
|
||||||
echo -e "\n# INSTALL THINGS #"
|
echo -e "\n# INSTALL THINGS #"
|
||||||
|
|
||||||
echo -e "Updating...\n\n"
|
|
||||||
|
|
||||||
service systemd-resolved start
|
INSTALL_DIR="/opt/wlan2eth"
|
||||||
sudo systemctl stop dnsmasq
|
echo "Installing to $INSTALL_DIR"
|
||||||
|
|
||||||
|
if [ "$DIR" != "$INSTALL_DIR" ]; then
|
||||||
|
if ! $NON_INTERACTIVE; then
|
||||||
|
echo -e "\nGoing to copy $DIR to $INSTALL_DIR"
|
||||||
|
read -p "Press ENTER to continue or CTRL+C to cancel..."
|
||||||
|
fi
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
cp -r "$DIR"/* "$INSTALL_DIR"
|
||||||
|
else
|
||||||
|
echo "We are already in $INSTALL_DIR, not copying files."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "Updating...\n"
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get upgrade $NON_INTERACTIVE_APT
|
apt-get upgrade $NON_INTERACTIVE_APT
|
||||||
|
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
|
|
||||||
THINGS_TO_INSTALL="parprouted dhcp-helper net-tools ethtool dnsmasq"
|
THINGS_TO_INSTALL="net-tools ethtool dnsmasq openssh-server"
|
||||||
|
|
||||||
if ! $NON_INTERACTIVE; then
|
if ! $NON_INTERACTIVE; then
|
||||||
echo "Going to install: $THINGS_TO_INSTALL"
|
echo "Going to install: $THINGS_TO_INSTALL"
|
||||||
|
@ -86,20 +107,16 @@ echo -e "\n"
|
||||||
|
|
||||||
apt-get install $NON_INTERACTIVE_APT $THINGS_TO_INSTALL
|
apt-get install $NON_INTERACTIVE_APT $THINGS_TO_INSTALL
|
||||||
|
|
||||||
echo -e "\n\nSetting up services...\n"
|
echo -e "\nStarting dnsmasq..."
|
||||||
|
|
||||||
systemctl stop dhcp-helper
|
|
||||||
systemctl disable dhcp-helper # remember to enable it later
|
|
||||||
sudo systemctl stop dnsmasq
|
sudo systemctl stop dnsmasq
|
||||||
sudo systemctl disable dnsmasq
|
sudo systemctl disable dnsmasq
|
||||||
|
|
||||||
if ! $NON_INTERACTIVE; then
|
if ! $NON_INTERACTIVE; then
|
||||||
echo -e "\n\nGoing to replace networking with systemd-networkd."
|
echo -e "\nGoing to replace networking with systemd-networkd."
|
||||||
read -p "Press ENTER to continue or CTRL+C to cancel..."
|
read -p "Press ENTER to continue or CTRL+C to cancel..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n"
|
apt-get autoremove --purge $NON_INTERACTIVE_APT ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common
|
||||||
apt-get --autoremove $NON_INTERACTIVE_APT purge ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common
|
|
||||||
|
|
||||||
echo -e "\n\nConnecting to WiFi..."
|
echo -e "\n\nConnecting to WiFi..."
|
||||||
|
|
||||||
|
@ -128,8 +145,7 @@ systemctl status --no-pager wpa_supplicant@$WLAN_IFACE.service
|
||||||
echo ""
|
echo ""
|
||||||
ifconfig $WLAN_IFACE
|
ifconfig $WLAN_IFACE
|
||||||
|
|
||||||
echo -e "\n\n"
|
echo -e "\n"
|
||||||
ifconfig $WLAN_IFACE
|
|
||||||
NET_CONF_FILE="/etc/systemd/network/08-$WLAN_IFACE.network"
|
NET_CONF_FILE="/etc/systemd/network/08-$WLAN_IFACE.network"
|
||||||
cat >"$NET_CONF_FILE" <<EOF
|
cat >"$NET_CONF_FILE" <<EOF
|
||||||
[Match]
|
[Match]
|
||||||
|
@ -137,24 +153,15 @@ Name=$WLAN_IFACE
|
||||||
[Network]
|
[Network]
|
||||||
IPForward=yes
|
IPForward=yes
|
||||||
DHCP=yes
|
DHCP=yes
|
||||||
# for a static ip address, remove DHCP=yes and modify the following lines:
|
|
||||||
#Address=192.168.50.2/24
|
|
||||||
#Gateway=192.168.50.1
|
|
||||||
#DNS=84.200.69.80 1.1.1.1
|
|
||||||
EOF
|
EOF
|
||||||
echo "Created network config: $WLAN_IFACE"
|
echo "Created network config: $WLAN_IFACE"
|
||||||
echo -e "Finishing systemd-networkd install...\n\n"
|
echo -e "Finishing systemd-networkd install...\n"
|
||||||
apt-get install $NON_INTERACTIVE_APT libnss-resolve
|
apt-get install $NON_INTERACTIVE_APT libnss-resolve
|
||||||
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
||||||
systemctl enable --now systemd-resolved.service
|
systemctl enable --now systemd-resolved.service
|
||||||
systemctl restart systemd-networkd.service
|
systemctl restart systemd-networkd.service
|
||||||
|
|
||||||
echo -e "\n\nInstall complete! Ignore any service errors for now..."
|
# echo -e "\n\nInstall complete! Ignore any service errors for now..."
|
||||||
|
|
||||||
# ==============================================================================
|
|
||||||
# Set up configs
|
|
||||||
|
|
||||||
echo -e "\n# SET UP CONFIG FILES #"
|
|
||||||
|
|
||||||
sed -i'' 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
|
sed -i'' 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
|
||||||
sysctl -p /etc/sysctl.conf
|
sysctl -p /etc/sysctl.conf
|
||||||
|
@ -168,6 +175,22 @@ echo "Created /var/lib/dnsmasq/"
|
||||||
sed -i '/^Port /d' /etc/ssh/sshd_config
|
sed -i '/^Port /d' /etc/ssh/sshd_config
|
||||||
echo "Port $ROUTER_SSH_PORT" >> /etc/ssh/sshd_config
|
echo "Port $ROUTER_SSH_PORT" >> /etc/ssh/sshd_config
|
||||||
systemctl restart ssh
|
systemctl restart ssh
|
||||||
|
systemctl enable --now ssh
|
||||||
echo "Set SSH server port to $ROUTER_SSH_PORT"
|
echo "Set SSH server port to $ROUTER_SSH_PORT"
|
||||||
|
|
||||||
echo -e "\n\n\n==============\nDone!\nNow reboot!"
|
echo ""
|
||||||
|
|
||||||
|
systemctl status --no-pager ssh
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo -e "Installing the wlan2eth systemd service..."
|
||||||
|
cp "$DIR/wlan2eth.service" /etc/systemd/system/
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now wlan2eth
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
systemctl status --no-pager wlan2eth
|
||||||
|
|
||||||
|
echo -e "\n==============\nDone!\nNow reboot!"
|
||||||
|
|
Loading…
Reference in New Issue