Skip to content

Commit

Permalink
feat: Add mode switching scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
selengalp committed Feb 6, 2023
1 parent 6e7741a commit b74608b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
41 changes: 41 additions & 0 deletions switch_ap_mode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Switch to wifi AP mode

# Check if we are root
if [ $(id -u) -ne 0 ]; then
echo "Please run as root"
exit 1
fi


# Configure the dhcpcd to use the static IP address
cp ./ap_config_files/dhcpcd.conf /etc/dhcpcd.conf

# Configure the dnsmaq
cp ./ap_config_files/dnsmasq.conf /etc/dnsmasq.conf

# Configure the hostapd
cp ./ap_config_files/hostapd.conf /etc/hostapd/hostapd.conf

# Add new local host name to /etc/hosts
cp ./ap_config_files/hosts /etc/hosts

# Stop services
systemctl stop hostapd
systemctl stop dnsmasq

# Stop services conflicting with hostapd
systemctl stop systemd-resolved
systemctl stop wpa_supplicant

# Stop active wpa supplicant processes
pkill wpa_supplicant

# Restart dhcpcd, dnsmasq and hostapd
systemctl daemon-reload
systemctl restart dhcpcd dnsmasq hostapd




28 changes: 28 additions & 0 deletions switch_client_mode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Switch WIFI client mode

# Check if we are root
if [ $(id -u) -ne 0 ]; then
echo "Please run as root"
exit 1
fi


# Delete AP Configs
cp ./client_config_files/dhcpcd.conf /etc/dhcpcd.conf

# Add wifi credentials to wpa_supplicant config
cp ./client_config_files/wpa_supplicant-wlan0.conf /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

# Stop AP mode services
systemctl stop hostapd dnsmasq

# Restart services
systemctl daemon-reload
systemctl restart systemd-resolved dhcpcd
systemctl enable [email protected]
systemctl start [email protected]



0 comments on commit b74608b

Please sign in to comment.