Created
April 11, 2025 04:28
-
-
Save elico/fb162e4b392859a4ab34183f64a23800 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Author: remontti.com.br | |
# Define color codes with standard ANSI escape sequences | |
GREEN='\033[1;32m' | |
BLUE='\033[1;36m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' | |
# Check if terminal supports colors | |
if [ -t 1 ]; then | |
USE_COLORS=1 | |
else | |
USE_COLORS=0 | |
GREEN="" | |
BLUE="" | |
YELLOW="" | |
NC="" | |
fi | |
# Check if running as root | |
if [ "$EUID" -ne 0 ]; then | |
echo -e " ${YELLOW}This script must be run as root (use sudo).${NC}\n" | |
exit 1 | |
fi | |
# Display header | |
echo -e " ${BLUE} _ ___ ___ ___ _ ___ ___ ___ ${NC}" | |
echo -e " ${BLUE} /_\ / __/ __| __| | ___| _ \\ _ \\ _ \\ ${NC}" | |
echo -e " ${BLUE} / _ \\ (_| (__| _|| |_|___| _/ _/ _/ ${NC}" | |
echo -e " ${BLUE} /_/ \\_\\___\\___|___|____| |_| |_| |_| ${NC}" | |
echo -e " ${YELLOW} Installation ON Debian 12${NC}\n" | |
# Check the distribution and version | |
DISTRO=$(cat /etc/os-release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $1}') | |
VERSION=$(cat /etc/os-release | grep "VERSION_ID" | sed 's/VERSION_ID=//g' | sed 's/["]//g' | awk '{print $1}') | |
# Log file for errors | |
LOGFILE="/tmp/accel-ppp-install.log" | |
if [ "$DISTRO" != "Debian" ]; then | |
echo -e " ${YELLOW}Your Linux distribution ($DISTRO) is not Debian!!!${NC}\n" | |
exit 1 | |
elif [ "$VERSION" != "12" ]; then | |
echo -e " ${YELLOW}Your Debian version ($VERSION) is not 12. This script is optimized for Debian 12.${NC}" | |
echo -n " Continue anyway? (Y)Yes/(N)No [N] " | |
read continue_response | |
if [[ "$continue_response" != "y" && "$continue_response" != "Y" ]]; then | |
echo -e "\n Installation canceled.\n" | |
exit 1 | |
fi | |
fi | |
# Help option | |
if [[ "$1" == "-h" || "$1" == "--help" ]]; then | |
echo -e " ${BLUE}Usage:${NC}" | |
echo -e " ./$(basename "$0") [-h|--help]" | |
echo -e " Installs Accel-PPP on Debian 12 with optional IPoE and VLAN support." | |
echo -e " Run as root or with sudo.\n" | |
exit 0 | |
fi | |
echo -n " Do you want to install ACCEL-PPP? (Y)Yes/(N)No [N] " | |
read response | |
case "$response" in | |
y|Y) | |
echo -e " ${BLUE}Updating package lists...${NC}" | |
apt update > "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to update package lists. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
echo -e " ${BLUE}Installing dependencies...${NC}" | |
apt install -y git build-essential cmake libsnmp-dev linux-headers-$(uname -r) libpcre3-dev libssl-dev liblua5.4-dev libpcre2-dev >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to install dependencies. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
echo -e " ${BLUE}Cloning Accel-PPP repository...${NC}" | |
mkdir -p /usr/local/src/accel/build | |
cd /usr/local/src/accel | |
if [ -d "accel-ppp" ]; then | |
echo -e " ${YELLOW}Directory accel-ppp already exists.${NC}" | |
echo -n " Overwrite? (Y)Yes/(n)No [n] " | |
read overwrite_response | |
if [[ "$overwrite_response" == "y" || "$overwrite_response" == "Y" ]]; then | |
rm -rf accel-ppp | |
git clone https://github.com/accel-ppp/accel-ppp.git >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to clone accel-ppp repository after overwrite. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
else | |
echo -e " ${BLUE}Using existing accel-ppp directory.${NC}\n" | |
fi | |
else | |
git clone https://github.com/accel-ppp/accel-ppp.git >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to clone accel-ppp repository. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
fi | |
cd /usr/local/src/accel/build | |
echo -e " ${BLUE}Configuring with CMake...${NC}" | |
cmake \ | |
-DCPACK_TYPE=Debian12 \ | |
-DBUILD_IPOE_DRIVER=TRUE \ | |
-DBUILD_VLAN_MON_DRIVER=TRUE \ | |
-DRADIUS=TRUE \ | |
-DNETSNMP=TRUE \ | |
-DLUA=TRUE \ | |
-DLUA=5.4 \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX=/usr \ | |
-DKDIR=/usr/src/linux-headers-$(uname -r) \ | |
../accel-ppp >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}CMake configuration failed. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
echo -e " ${BLUE}Compiling source...${NC}" | |
make >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Compilation failed. Possible OpenSSL 3.0 issues or kernel module errors. Try -DBUILD_IPOE_DRIVER=FALSE -DBUILD_VLAN_MON_DRIVER=FALSE. See $LOGFILE.${NC}\n" | |
exit 1 | |
fi | |
echo -e " ${BLUE}Installing kernel modules...${NC}" | |
if [ -f drivers/ipoe/driver/ipoe.ko ]; then | |
cp drivers/ipoe/driver/ipoe.ko /lib/modules/$(uname -r) | |
else | |
echo -e " ${YELLOW}Warning: ipoe.ko not found. IPoE module not compiled.${NC}\n" | |
fi | |
if [ -f drivers/vlan_mon/driver/vlan_mon.ko ]; then | |
cp drivers/vlan_mon/driver/vlan_mon.ko /lib/modules/$(uname -r) | |
else | |
echo -e " ${YELLOW}Warning: vlan_mon.ko not found. VLAN module not compiled.${NC}\n" | |
fi | |
depmod -a | |
modprobe vlan_mon 2>/dev/null || echo -e " ${YELLOW}Warning: Failed to load vlan_mon module.${NC}\n" | |
modprobe ipoe 2>/dev/null || echo -e " ${YELLOW}Warning: Failed to load ipoe module.${NC}\n" | |
echo "vlan_mon" >> /etc/modules | |
echo "ipoe" >> /etc/modules | |
echo -e " ${BLUE}Creating and installing DEB package...${NC}" | |
cpack -G DEB >> "$LOGFILE" 2>&1 | |
if [ -f accel-ppp.deb ]; then | |
apt install ./accel-ppp.deb >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to install accel-ppp.deb. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
else | |
echo -e " ${YELLOW}Failed to create accel-ppp.deb. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
echo -e " ${BLUE}Enabling accel-ppp service...${NC}" | |
systemctl enable accel-ppp >> "$LOGFILE" 2>&1 | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to enable accel-ppp service. Check $LOGFILE for details.${NC}\n" | |
exit 1 | |
fi | |
echo -e " ${BLUE}Copying configuration file...${NC}" | |
cp /etc/accel-ppp.conf.dist /etc/accel-ppp.conf | |
if [ $? -ne 0 ]; then | |
echo -e " ${YELLOW}Failed to copy accel-ppp.conf.dist. Ensure it exists in /etc/.${NC}\n" | |
exit 1 | |
fi | |
# Verify installation | |
if command -v accel-pppd >/dev/null 2>&1; then | |
VERSION=$(accel-pppd -V 2>&1) | |
echo -e " ${GREEN}Accel-PPP installed successfully! Version: $VERSION${NC}\n" | |
else | |
echo -e " ${YELLOW}Warning: accel-pppd not found in PATH. Installation may have issues.${NC}\n" | |
fi | |
echo -e " ${BLUE}Edit the file ${YELLOW}/etc/accel-ppp.conf${NC} ${BLUE}to configure according to your needs.${NC}" | |
echo -e " ${BLUE}Restart the service after changes:${NC}" | |
echo -e " ${BLUE} systemctl restart accel-ppp${NC}\n" | |
echo -e " ${BLUE}Detailed logs are available in $LOGFILE${NC}\n" | |
;; | |
n|N|"") | |
echo -e "\n Installation canceled.\n" | |
;; | |
*) | |
echo -e "\n Invalid option\n" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment