-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworking-Wifi-install
More file actions
207 lines (164 loc) · 5.36 KB
/
Networking-Wifi-install
File metadata and controls
207 lines (164 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
# Debian 12 WiFi Setup Script
# Installs drivers, GUI tools, and configures WiFi management
set -e
echo "=== Debian 12 WiFi Setup Script ==="
echo "This script will install WiFi drivers and GUI configuration tools"
echo
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if running as root
if [[ $EUID -eq 0 ]]; then
print_error "This script should not be run as root. Please run as a regular user."
exit 1
fi
# Check if sudo is available
if ! command -v sudo &> /dev/null; then
print_error "sudo is required but not installed. Please install sudo first."
exit 1
fi
print_status "Starting WiFi setup for Debian 12..."
# Update package lists
print_status "Updating package lists..."
sudo apt update
# Check current WiFi hardware
print_status "Detecting WiFi hardware..."
echo "PCI WiFi devices:"
lspci | grep -i wireless || print_warning "No PCI WiFi devices found"
echo "USB WiFi devices:"
lsusb | grep -i wireless || print_warning "No USB WiFi devices found"
echo
# Install firmware packages
print_status "Installing WiFi firmware and drivers..."
sudo apt install -y \
firmware-linux \
firmware-linux-nonfree \
firmware-realtek \
firmware-atheros \
firmware-iwlwifi \
firmware-brcm80211 \
firmware-misc-nonfree
# Install wireless tools
print_status "Installing wireless utilities..."
sudo apt install -y \
wireless-tools \
wpasupplicant \
iw \
rfkill \
net-tools \
dnsutils
# Install NetworkManager and GUI
print_status "Installing NetworkManager and GUI components..."
sudo apt install -y \
network-manager \
network-manager-gnome
# Detect desktop environment and install appropriate GUI
if command -v gnome-shell &> /dev/null; then
print_status "GNOME detected - NetworkManager GNOME already installed"
elif command -v plasmashell &> /dev/null; then
print_status "KDE detected - Installing Plasma NetworkManager..."
sudo apt install -y plasma-nm
elif command -v xfce4-panel &> /dev/null; then
print_status "XFCE detected - Installing additional network manager..."
sudo apt install -y network-manager-gnome
else
print_status "Installing universal network manager GUI..."
sudo apt install -y wicd-gtk
fi
# Install additional useful tools
print_status "Installing additional networking tools..."
sudo apt install -y \
wavemon \
iperf3 \
traceroute \
nmap
# Configure NetworkManager
print_status "Configuring NetworkManager..."
# Stop and disable any conflicting network services
sudo systemctl stop networking 2>/dev/null || true
sudo systemctl disable networking 2>/dev/null || true
# Enable and start NetworkManager
sudo systemctl enable NetworkManager
sudo systemctl start NetworkManager
# Add user to netdev group if not already added
sudo usermod -a -G netdev $USER
# Check if WiFi is blocked by rfkill
print_status "Checking rfkill status..."
rfkill list
# Unblock WiFi if it's blocked
if rfkill list wifi | grep -q "Soft blocked: yes\|Hard blocked: yes"; then
print_warning "WiFi appears to be blocked. Attempting to unblock..."
sudo rfkill unblock wifi
fi
# Restart NetworkManager to ensure everything is working
print_status "Restarting NetworkManager..."
sudo systemctl restart NetworkManager
# Wait a moment for NetworkManager to start
sleep 3
# Check NetworkManager status
if systemctl is-active --quiet NetworkManager; then
print_status "NetworkManager is running successfully!"
else
print_error "NetworkManager failed to start properly"
fi
# Display available WiFi networks
print_status "Scanning for available WiFi networks..."
nmcli dev wifi list 2>/dev/null || print_warning "WiFi scanning failed - you may need to reboot"
# Final status check
print_status "Checking network interfaces..."
ip link show | grep -E "(wlan|wlp)"
echo
print_status "=== Setup Complete ==="
echo "To connect to WiFi networks, you can use:"
echo "1. GUI: Look for NetworkManager icon in your system tray"
echo "2. Command line: nmcli dev wifi connect 'SSID' password 'PASSWORD'"
echo "3. Alternative GUI: Run 'nm-connection-editor' for detailed network settings"
echo
print_warning "You may need to reboot for all changes to take effect."
echo "After reboot, run: nmcli dev wifi list"
echo
# Create a quick reference file
cat > ~/wifi-commands-reference.txt << 'EOF'
# WiFi Management Quick Reference for Debian 12
## NetworkManager CLI Commands:
# List available networks:
nmcli dev wifi list
# Connect to a network:
nmcli dev wifi connect "SSID" password "PASSWORD"
# Show connection status:
nmcli connection show
# Disconnect from current network:
nmcli dev disconnect wlan0
# Show device status:
nmcli dev status
## GUI Tools:
# NetworkManager GUI: nm-connection-editor
# System tray applet should appear automatically
# Alternative: wicd-gtk (if installed)
## Troubleshooting:
# Check if WiFi is blocked:
rfkill list
# Unblock WiFi:
sudo rfkill unblock wifi
# Restart NetworkManager:
sudo systemctl restart NetworkManager
# Check logs:
journalctl -u NetworkManager -f
# Manual WiFi scan:
sudo iw dev wlan0 scan | grep SSID
EOF
print_status "Created ~/wifi-commands-reference.txt for future reference"
echo "Setup completed successfully!"