Repository navigation
Expand file tree
/
Copy pathstart-server.sh
More file actions
78 lines (61 loc) · 1.81 KB
/
Copy pathstart-server.sh
File metadata and controls
78 lines (61 loc) · 1.81 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
#!/bin/bash
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
function echo-info {
echo -e "\e[34;1m[+]\e[0m \e[34mInfo: $1\e[0m" >&2
}
function echo-warning {
echo -e "\e[31;1m[!] Warning: $1\e[0m" >&2
}
function printInfo {
echo -e "\e[34;1mUsage:\e[0m"
echo -e "\e[34;1m- Start PXE server: \e[0m \e[34m$0 pxe <interface>\e[0m"
echo -e "\e[34;1m- Start SMB server: \e[0m \e[34m$0 smb <interface>\e[0m"
}
# Function to start the PXE and DHCP server
function start-pxe-server {
interface=$1
if [[ "$interface" = "" ]]; then
echo-warning "No interface specified!"
printInfo
exit
fi
# Add IP address to interface
sudo ip a add 10.13.37.100/24 dev $interface
echo-info "Interface $interface has IP address 10.13.37.100/24"
stop-servers
# Start dnsmasq
echo-info "Starting dnsmasq..."
sudo dnsmasq --no-daemon --interface=$interface --dhcp-range=10.13.37.100,10.13.37.101,255.255.255.0,1h --dhcp-boot=bootmgfw.efi --enable-tftp --tftp-root=$SCRIPTPATH/pxe-server
echo-info "Stopping dnsmasq..."
}
# Function to start the SMBserver
function start-pxe-server {
interface=$1
if [[ "$interface" = "" ]]; then
echo-warning "No interface specified!"
printInfo
exit
fi
# Add IP address to interface
sudo ip a add 10.13.37.100/24 dev $interface
echo-info "Interface $interface has IP address 10.13.37.100/24"
# Start dnsmasq
echo-info "Starting smbserver.py..."
sudo $(which smbserver.py) -smb2support smb "$scriptpath/pxe-server/Boot"
echo-info "Stopping smbserver.py..."
}
# Function to stop the servers
function stop-servers {
echo-info "Killing all dnsmasq processes..."
sudo killall dnsmasq
}
if [[ "$1" = "smb" ]]; then
start-servers shimx64.efi $2
exit
elif [[ "$1" = "pxe" ]]; then
start-servers $2
exit
else
printInfo
exit
fi