Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to version 3.1.0 #25

Merged
merged 51 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3cf338a
Bugfix on OVPN + add lite version
spmzt Mar 10, 2024
bf90226
change configuration format from URI to DOMAIN
spmzt Mar 10, 2024
1c653f1
lite cleaning
spmzt Mar 10, 2024
a270fba
Add adm utilities, not tested
spmzt Mar 10, 2024
ddf0330
add other utilities to wanpad adm (not tested)
spmzt Mar 10, 2024
9973a6d
update api
spmzt Mar 11, 2024
8f5536d
update api
spmzt Mar 11, 2024
3ecbea4
Merge branch 'develop' of github.com:hoopadcorp/wanpad-edge into develop
spmzt Mar 11, 2024
0e8e40a
md enhancement
spmzt Mar 11, 2024
ebd0596
Add set_token
spmzt Mar 11, 2024
2b62e60
bugfix init
spmzt Mar 11, 2024
1fcabd1
bugfix on token validation
spmzt Mar 11, 2024
dda9611
install: bugfix on ssh configuration
mrAlirj Mar 11, 2024
aa72a5a
install: bugfix on snmpd
mrAlirj Mar 11, 2024
d58f80a
install: enhancement on nameserver
mrAlirj Mar 11, 2024
98c80ab
install: replace tee with redirect
mrAlirj Mar 11, 2024
27f0579
install: bugfix on nameserver
mrAlirj Mar 11, 2024
8c15282
install: add installonly make and ssh bugfix
spmzt Mar 11, 2024
ce010c2
install: ssh bugfix for linux
spmzt Mar 11, 2024
8b555b5
install: snmpd bugfix
spmzt Mar 11, 2024
f5011b2
Add swanctl and ocserv
spmzt Apr 19, 2024
c1cc0b9
Add UDPSpeeder + replace git with git-lite on freebsd
spmzt Apr 21, 2024
55d79e7
add g++ symlink to FreeBSD Version
spmzt Apr 21, 2024
cb37e01
Add to startup files
spmzt Apr 21, 2024
df9c429
UDPspeeder cleaning
spmzt Apr 21, 2024
b031719
add smoeping-prober
spmzt Apr 21, 2024
8a1285a
configure smokeping-exporter
spmzt Apr 21, 2024
f9222bb
Check if speederv2 is installed or not
spmzt Apr 21, 2024
eafe7da
Bugfix last commit
spmzt Apr 21, 2024
e20bb2e
add sot command
spmzt Apr 21, 2024
89f32bc
add sot command
spmzt Apr 21, 2024
4e91f3f
add sot command
spmzt Apr 21, 2024
4fe187a
Update README.md
spmzt Apr 26, 2024
c49ef76
LITE_VERSION bugfix
spmzt Apr 26, 2024
723cf18
DOMAIN variable bugfix
spmzt Apr 26, 2024
fd108b9
Update wanpad.conf.sample
spmzt Apr 26, 2024
2a8804a
ztp bugfix
spmzt Apr 26, 2024
9879d86
Update pnp-client.py
spmzt Apr 26, 2024
d3533b9
change script for starting wanpad services
mostafawkhd Jul 7, 2024
7ea0414
fix a typo
mostafawkhd Jul 7, 2024
3f1e8a1
Merge pull request #24 from mostafawkhd/patch-2
spmzt Jul 7, 2024
321bc99
Remove lite version (adm should be a separate package)
spmzt Jul 8, 2024
27aa5c6
Remove lite and merge current
spmzt Jul 8, 2024
321a349
add swanctl support to wanpad-edge client
spmzt Jul 8, 2024
4da1c3e
swanctl: always include wanpad configuration
spmzt Jul 8, 2024
245263e
ZTP: Bugfix on wanpad-ztp service
spmzt Jul 8, 2024
8f21117
Build: set ownership of etc directory
spmzt Jul 8, 2024
7ad44ca
Build: set ownership of etc directory
spmzt Jul 8, 2024
3b0db51
Build: set ownership of etc directory
spmzt Jul 8, 2024
b878a99
swanctl: add apparmor profile to include wanpad directory
spmzt Jul 8, 2024
505161d
swanctl: add apparmor profile to include wanpad directory (bugfix)
spmzt Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DEBUG= $$(if [ "${OS}" = "FreeBSD" ]; then echo set -xeouv pipefail; else ech
WANPAD_VERSION= $$(git rev-parse HEAD)
WANPAD_CMD= /usr/local/bin/wanpadctl
WANPAD_USERNAME= hoopad
WANPAD_GROUP= hoopad

.PHONY: all
all:
Expand All @@ -15,9 +16,9 @@ deps:
@echo "Install applications"
@if [ -e /etc/debian_version ]; then\
DEBIAN_FRONTEND=noninteractive apt install -y net-tools git openvpn python3-pip wireguard snmpd libqmi-utils udhcpc build-essential\
python3-dev strongswan strongswan-starter frr bird2 keepalived fprobe sudo golang-1.20-go git-lfs;\
python3-dev strongswan strongswan-starter strongswan-swanctl ocserv frr bird2 keepalived fprobe sudo golang-1.20-go git-lfs jq prometheus-smokeping-prober;\
elif [ "${OS}" = "FreeBSD" ]; then\
pkg install -y git openvpn python3 py39-pip strongswan frr9 frr9-pythontools bird2 fprobe sudo node_exporter go;\
pkg install -y git-lite openvpn python3 py39-pip strongswan frr9 frr9-pythontools bird2 fprobe sudo node_exporter go jq gcc49;\
fi
@echo
@echo "Install python applications"
Expand All @@ -32,6 +33,20 @@ deps:
rm -rf /tmp/node_exporter*;\
fi
@echo
@echo "Install UDPSpeeder (FEC)"
@echo
@if [ ! -s /usr/local/bin/speederv2 ]; then\
git clone https://github.com/wangyu-/UDPspeeder.git /tmp/UDPspeeder;\
if [ -e /etc/debian_version ]; then\
make -C /tmp/UDPspeeder;\
elif [ "${OS}" = "FreeBSD" ]; then\
ln -s /usr/local/bin/g++49 /usr/local/bin/g++;\
make -C /tmp/UDPspeeder freebsd;\
fi;\
cp /tmp/UDPspeeder/speederv2 /usr/local/bin/;\
rm -rf /tmp/UDPspeeder;\
fi
@echo
@echo "Install birdwatcher"
@echo
@if [ ! -s /usr/local/bin/birdwatcher ]; then\
Expand Down Expand Up @@ -85,13 +100,38 @@ install: ca deps generate
@echo "Installing wanpad"
@echo
@cp -Rv usr /
@echo
@echo "Set ownership of wanpad configuration directory to ${WANPAD_USERNAME} and ${WANPAD_GROUP}"
@echo
@chown ${WANPAD_USERNAME}:${WANPAD_GROUP} -R /usr/local/etc/wanpad
@chmod +x ${WANPAD_CMD}
@echo
@echo "Install filebeat"
@echo
@tar xzvf usr/local/share/wanpad/tar-files/filebeat.tar.gz -C /usr/local/share/wanpad/client-services/
@ln -sf /usr/local/share/wanpad/client-services/filebeat/filebeat /usr/local/bin/
@echo
@if [ "${OS}" = "GNU/Linux" ]; then\
echo "Configure apparmor (Linux)";\
cp /usr/local/share/wanpad/apparmor.d/usr.sbin.swanctl /etc/apparmor.d/local/usr.sbin.swanctl;\
aa-status --enabled && apparmor_parser -r /etc/apparmor.d/usr.sbin.swanctl;\
fi
@echo "Installing wanpad configuration"
@if [ ! -s /usr/local/etc/wanpad/wanpad.conf ]; then\
cp /usr/local/etc/wanpad/wanpad.conf.sample /usr/local/etc/wanpad/wanpad.conf;\
else\
echo "wanpad configuration file is already exists at /usr/local/etc/wanpad/wanpad.conf.";\
echo "If you want the new configuration use the following command below:";\
echo "\tcp /usr/local/etc/wanpad/wanpad.conf.sample /usr/local/etc/wanpad/wanpad.conf";\
fi

.PHONY: installonly
installonly:
@echo "Installing wanpad version"
@echo
@cp -Rv usr /
@chmod +x ${WANPAD_CMD}
@echo
@echo "Installing wanpad configuration"
@if [ ! -s /usr/local/etc/wanpad/wanpad.conf ]; then\
cp /usr/local/etc/wanpad/wanpad.conf.sample /usr/local/etc/wanpad/wanpad.conf;\
Expand Down Expand Up @@ -197,4 +237,4 @@ purge: uninstall
python3-dev strongswan strongswan-starter frr bird2 keepalived fprobe golang-1.20-go;\
elif [ "${OS}" = "FreeBSD"]; then\
pkg delete -y git openvpn python3 py39-pip strongswan frr9 frr9-pythontools bird2 fprobe sudo node_exporter go;\
fi
fi
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ Login as `root`.

> NOTE: Please just hit `Enter` when you are prompted for a configuration in a pink screen! (linux only)

> NOTE 2: The SSH service will be running on port 24489 after running this script!

```sh
git clone https://github.com/HoopadCorp/wanpad-edge.git
git lfs pull
make install
wanpadctl install
```

> NOTE 2: The SSH service will be running on port 24489 after installation

Wait for the installation to be completed. If there are any errors, feel free to reach out to _issues_ and inform us or call the tech assistans!

### Uninstall
Expand All @@ -76,25 +76,23 @@ wanpadctl init

You'll be prompted to enter your controller URL and access token:

```
```txt
Please Provide the following information:
WANPAD controller URI: <URI HERE>
WANPAD controller address: <DOMAIN HERE>
Your access token: <TOKEN HERE>
```

- **URI format**: `controller.wanpad.ir`
- **DOMAIN format**: `controller.wanpad.ir`

After the prompt return, you should be able to access your device through the controller panel.

- **NOTE:** You can also run the script in **non-interactive** mode, doing:

```sh
wanpadctl <URL HERE> <TOKEN HERE>
wanpadctl init <DOMAIN HERE> <TOKEN HERE>
```

##

# Contributions
## Contributions

Any PR(s) are welcomed.
Check the wiki section of Github for more information.
32 changes: 4 additions & 28 deletions usr/local/bin/wanpadctl
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

PATH=${PATH}:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

. /usr/local/share/wanpad/common.sh
. /usr/local/etc/wanpad/wanpad.conf

## version
WANPAD_VERSION="3.0.0"

usage()
{
cat << EOF
wanpadctl(8) is an open-source utility for automating deployment and management of
WANPAD edges for SD-WAN controller.

Usage:
wanpadctl command [args]

Available Commands:
install prepare and set up operating system to function as edge device.
init join to WANPAD controller.
oob connect to WANPAD controller using oob network.
lte configure lte module. (if any exists.)

Use "wanpad -v|--version" for version information.
Use "wanpad command -h|--help" for more information about a command.

EOF
exit 1
}
. /usr/local/share/wanpad/common.sh
. /usr/local/etc/wanpad/wanpad.conf

[ $# -lt 1 ] && usage

CMD=$1
export CMD=$1
shift

# Handle special-case commands first.
Expand All @@ -69,5 +45,5 @@ if [ -f "${SCRIPTPATH}" ]; then
: "${SH:=sh}"
exec "${SH}" "${SCRIPTPATH}" "$@"
else
error_exit "${SCRIPTPATH} not found."
print_error "${SCRIPTPATH} not found."
fi
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions usr/local/etc/wanpad/startup/startup-9.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
9 changes: 9 additions & 0 deletions usr/local/etc/wanpad/startup/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@

DIR="/usr/local/etc/wanpad/startup"

. ${DIR}/startup-0.sh
. ${DIR}/startup-1.sh
. ${DIR}/startup-2.sh
. ${DIR}/startup-3.sh
. ${DIR}/startup-4.sh
. ${DIR}/startup-5.sh
. ${DIR}/startup-6.sh
. ${DIR}/startup-7.sh
. ${DIR}/startup-8.sh
. ${DIR}/startup-9.sh

. ${DIR}/swanctl.sh
10 changes: 10 additions & 0 deletions usr/local/etc/wanpad/startup/swanctl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# This shell script ensures that strongswan has the exact configuration we want at any time.

SWANCTL_DIR="/usr/local/etc/wanpad/swanctl/conf.d"

if ! $(grep -q "include ${SWANCTL_DIR}/\*.conf" /etc/swanctl/swanctl.conf)
then
echo "include ${SWANCTL_DIR}/*.conf" >> /etc/swanctl/swanctl.conf
fi
Empty file.
13 changes: 11 additions & 2 deletions usr/local/etc/wanpad/wanpad.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ DEFAULT_SSH_PORT=24489
CLIENT_SERVICES_DIR="/usr/local/share/wanpad/client-services"

# ZTP
URI=https://deploy.wanpad.ir:8001/wanpad/api/v1/devices/plug_play/
CONTROLLER_DOMAIN=deploy.wanpad.ir
CONTROLLER_API_PORT=8001

# Controller Token
TOKEN=

# SSL for controller connectivity
SSL=true

# OpenVPN Client
OOB_CONFIG_FILE=/usr/local/etc/wanpad/client.ovpn
# The ".ovpn" file must be located under /usr/local/etc/wanpad/ directory.
OOB_CONFIG_FILE=client.ovpn

# Advanced
CONTROLLER_API_PATH=/wanpad/api/v1/devices/plug_play/
Binary file modified usr/local/share/man/man8/wanpadctl.8.gz
Binary file not shown.
1 change: 1 addition & 0 deletions usr/local/share/wanpad/apparmor.d/usr.sbin.swanctl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/local/etc/wanpad/swanctl/** r,
7 changes: 6 additions & 1 deletion usr/local/share/wanpad/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

set -a
. /usr/local/etc/wanpad/wanpad.conf
set +a

# Base library should be first to call
. /usr/local/share/wanpad/lib/base-lib.sh

. /usr/local/share/wanpad/lib/install-lib.sh
. /usr/local/share/wanpad/lib/ztp-lib.sh
. /usr/local/share/wanpad/lib/adm-lib.sh
. /usr/local/share/wanpad/lib/sot-lib.sh
4 changes: 2 additions & 2 deletions usr/local/share/wanpad/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ case "$NA" in
ztp_dialogue
;;
2)
URI=$1
CONTROLLER_DOMAIN=$1
TOKEN=$2
;;
*)
Expand All @@ -37,6 +37,6 @@ case "$NA" in
;;
esac

validate_token
save_ztp_config
validate_token $2
run_ztp_py
11 changes: 4 additions & 7 deletions usr/local/share/wanpad/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@
. /usr/local/etc/wanpad/wanpad.conf
. /usr/local/share/wanpad/common.sh

set +x
force_run_as_root
set -x

configure_birdwatcher
if [ "$OSKERNEL" = "Linux" ]; then
enable_wanpad_systemd_services
fi
[ "$OSKERNEL" = "Linux" ] && enable_wanpad_systemd_services
start_wanpad_services
enable_ipv4_forward
set_fib_multipath_hash_policy_1
set_fib_multipath_hash_policy
set_fib_ip_no_pmtu_disc_1
configure_fprobe
set_ssh_default_port
configure_prometheus_smokeping_prober
configure_ssh
configure_snmpd
save_current_nameserver_conf_and_disable_resolved
18 changes: 0 additions & 18 deletions usr/local/share/wanpad/lib/adm-lib.sh

This file was deleted.

Loading