-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinit
More file actions
executable file
·134 lines (116 loc) · 3.59 KB
/
init
File metadata and controls
executable file
·134 lines (116 loc) · 3.59 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
#!/bin/bash
echo '
__ ___ _ _ _ ___ ___ ___ ___ ___ ___
\ \ / / | /_\ | \| | _ \_ _|__ / __/ _ \| _ \ __|
\ \/\/ /| |__ / _ \| . | _/| |___| (_| (_) | / _|
\_/\_/ |____/_/ \_\_|\_|_| |___| \___\___/|_|_\___|
'
echo '
.___ .__ .__ __
__| _/_______ __ |__| ____ |__|/ |_
/ __ |/ __ \ \/ / | |/ \| \ __\
/ /_/ \ ___/\ / | | | \ || |
\____ |\___ >\_/ |__|___| /__||__|
\/ \/ \/
'
echo '
wlanpi-core development environment setup & initial launcher
This script automates the setup process for developing with wlanpi_core:
- Installs system dependencies (build tools, Python, networking utilities)
- Creates a Python virtual environment in the current folder
- Installs Python dependencies from requirements.txt and testing.txt
- Configures firewall to allow development port 8000
- Launches wlanpi_core in debug mode with auto-reload
Requires: Ubuntu/Debian system with sudo access
Usage: Intended for first run from the wlanpi-core root directory
'
if ! command -v sudo &> /dev/null; then
echo "Error: sudo is not installed ... Please run as root or install sudo and try again ..."
exit 1
fi
install_dependencies() {
echo "Installing required depends ..."
sudo apt-get update
if ! sudo apt-get install -y -q \
build-essential \
git \
unzip \
zip \
nload \
tree \
ufw \
nftables \
vlan \
sqlite3 \
lldpd \
xxd; then
echo "Error: Failed to install build essentials and tools ..."
exit 1
fi
if ! sudo apt-get install -y -q \
dbus \
pkg-config \
gcc \
libpq-dev \
libdbus-glib-1-dev \
libglib2.0-dev \
cmake \
libdbus-1-dev; then
echo "Error: Failed to install development libraries ..."
exit 1
fi
if ! sudo apt-get install -y -q \
python3-pip \
python3-dev \
python3-venv \
python3-wheel \
python3-setuptools \
dh-python; then
echo "Error: Failed to install Python packages ..."
exit 1
fi
}
if [ -d "venv" ]; then
echo "Virtual environment 'venv' already exists ... Skipping creation ..."
else
echo "Creating new virtual environment ..."
if ! python3 -m venv venv; then
echo "Error: Failed to create virtual environment ..."
exit 1
fi
fi
install_dependencies
# shellcheck disable=SC1091
source venv/bin/activate
if [ -f "requirements.txt" ]; then
echo "Installing dependencies from requirements.txt ..."
if ! pip install -r requirements.txt; then
echo "Error: Failed to install Python requirements ..."
exit 1
fi
else
echo "Warning: requirements.txt not found in current directory ..."
fi
if [ -f "testing.txt" ]; then
echo "Installing dependencies from testing.txt ..."
if ! pip install -r testing.txt; then
echo "Error: Failed to install testing Python requirements ..."
exit 1
fi
else
echo "Warning: testing.txt not found in current directory ..."
fi
echo "Configuring firewall to allow port 8000 ..."
if ! sudo ufw allow 8000; then
echo "Error: Failed to configure firewall rule for port 8000 ..."
exit 1
fi
echo
echo "Starting wlanpi_core in debug mode ..."
echo "Protip: next time use ./run to skip the setup ..."
echo "Executing: sudo venv/bin/python -m wlanpi_core --reload --debug"
echo
if ! sudo venv/bin/python -m wlanpi_core --reload --debug; then
echo "Error: Failed to start wlanpi_core ..."
exit 1
fi