-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollection
46 lines (33 loc) · 1.54 KB
/
collection
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
#!/bin/bash
output_file="$HOME/.chrome/device_info.txt"
> $output_file
echo "Collecting macOS device information..." | tee -a $output_file
hostname=$(hostname)
echo "Hostname: $hostname" | tee -a $output_file
os_version=$(sw_vers -productVersion)
echo "Operating System Version: $os_version" | tee -a $output_file
hardware_info=$(system_profiler SPHardwareDataType | grep "Model Name\|Model Identifier\|Processor Name\|Processor Speed\|Number of Processors\|Total Number of Cores\|Memory:")
echo "Hardware Information:" | tee -a $output_file
echo "$hardware_info" | tee -a $output_file
echo "Collecting network information..." | tee -a $output_file
network_interfaces=$(networksetup -listallhardwareports)
echo "Network Interfaces:" | tee -a $output_file
echo "$network_interfaces" | tee -a $output_file
ip_address=$(ipconfig getifaddr en0)
if [ -z "$ip_address" ]; then
ip_address=$(ipconfig getifaddr en1)
fi
echo "IP Address: $ip_address" | tee -a $output_file
subnet_mask=$(ipconfig getoption en0 subnet_mask)
if [ -z "$subnet_mask" ]; then
subnet_mask=$(ipconfig getoption en1 subnet_mask)
fi
echo "Subnet Mask: $subnet_mask" | tee -a $output_file
router=$(netstat -nr | grep default | awk '{print $2}')
echo "Router: $router" | tee -a $output_file
dns_servers=$(networksetup -getdnsservers Wi-Fi)
if [ "$dns_servers" = "There aren't any DNS Servers set on Wi-Fi." ]; then
dns_servers=$(networksetup -getdnsservers Ethernet)
fi
echo "DNS Servers: $dns_servers" | tee -a $output_file
echo "Information collection complete." | tee -a $output_file