-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add installation and uninstallation scripts
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
# Check if we are root | ||
if [ $(id -u) -ne 0 ]; then | ||
echo "Please run as root" | ||
exit 1 | ||
fi | ||
|
||
# Check installation by checking .orig files | ||
if [ -f /etc/dhcpcd.conf.orig ]; then | ||
echo "Already installed. Please uninstall first." | ||
exit 1 | ||
fi | ||
|
||
# if ./ap_config_files or ./client_config_files exists, then exit with error | ||
if [ -d ./ap_config_files ] || [ -d ./client_config_files ]; then | ||
echo "Already installed. Please uninstall first." | ||
exit 1 | ||
fi | ||
|
||
|
||
# Give execution permissions to scripts | ||
chmod +x ./switch_client_mode.sh | ||
chmod +x ./switch_ap_mode.sh | ||
|
||
# Install dependencies | ||
apt-get update | ||
apt-get install -y hostapd dnsmasq | ||
|
||
# Disable services as default | ||
systemctl unmask hostapd | ||
systemctl disable hostapd dnsmasq | ||
systemctl stop hostapd dnsmasq | ||
|
||
# Get the current configs from the system | ||
cp /etc/dhcpcd.conf /etc/dhcpcd.conf.orig | ||
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig | ||
cp /etc/hosts /etc/hosts.orig | ||
|
||
mkdir client_config_files | ||
cp /etc/dhcpcd.conf.orig ./client_config_files/dhcpcd.conf | ||
cp /etc/dnsmasq.conf.orig ./client_config_files/dnsmasq.conf | ||
cp /etc/hosts.orig ./client_config_files/hosts | ||
touch ./client_config_files/wpa_supplicant-wlan0.conf | ||
|
||
mkdir ap_config_files | ||
cp /etc/dhcpcd.conf.orig ./ap_config_files/dhcpcd.conf | ||
cp /etc/dnsmasq.conf.orig ./ap_config_files/dnsmasq.conf | ||
touch ./ap_config_files/hostapd.conf | ||
cp /etc/hosts.orig ./ap_config_files/hosts | ||
|
||
# Add confgurations for AP mode to the files | ||
cat ./source_configs/dhcpcd.conf >> ./ap_config_files/dhcpcd.conf | ||
cat ./source_configs/dnsmasq.conf >> ./ap_config_files/dnsmasq.conf | ||
cat ./source_configs/hostapd.conf >> ./ap_config_files/hostapd.conf | ||
cat ./source_configs/hosts >> ./ap_config_files/hosts | ||
cat ./source_configs/wpa_supplicant-wlan0.conf >> ./client_config_files/wpa_supplicant-wlan0.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Check if we are root | ||
if [ $(id -u) -ne 0 ]; then | ||
echo "Please run as root" | ||
exit 1 | ||
fi | ||
|
||
# Return original configs | ||
mv /etc/dhcpcd.conf.orig /etc/dhcpcd.conf | ||
mv /etc/hosts.orig /etc/hosts | ||
mv /etc/dnsmasq.conf.orig /etc/dnsmasq.conf | ||
|
||
# Remove services | ||
systemctl stop hostapd dnsmasq | ||
systemctl disable hostapd dnsmasq | ||
apt purge hostapd dnsmasq -y | ||
|
||
# Remove config files | ||
rm -rf /etc/hostapd/hostapd.conf | ||
rm -rf /etc/dnsmasq.conf | ||
rm -rf ./ap_config_files | ||
rm -rf ./client_config_files |