nexusofdoom / lancache-installer

32 stars 20 forks source link

Distro watch #24

Open bntjah opened 5 years ago

bntjah commented 5 years ago

So will leave my findings here for making the installer compatible with the Ubuntu and Debian distro.

bntjah commented 5 years ago

Use the following code to achieve the differences for both distros. Now investigating what packages are required on Debian compared to Ubuntu

!/bin/bash

lc_distro=$( hostnamectl | grep "Operating System" | awk '{ print $3 }' )

Ubuntu

if [ "$lc_distro" = "Ubuntu" ]; then echo "Ubuntu"; fi

Debian

if [ "$lc_distro" = "Debian" ]; then echo "Debian"; fi

bntjah commented 5 years ago

So far: these changes are what I found: Comment line 30, 31, 35-43, change line 48 to only install nginx and unbound as debian repo doesnt have sniproxy and netdata

lc_distro=$( hostnamectl | grep "Operating System" | awk '{ print $3 }' )

Ubuntu

if [ "$lc_distro" = "Ubuntu" ]; then lc_gateway=$(route -n | grep 'UG[ \t]' | awk '{print $2}') if_name=$(ifconfig | grep flags | awk -F: '{print $1;}' | grep -Fvx -e lo)

Update packages

    echo "Installing package updates..."
    universeCheck=$(apt-cache policy |grep universe)
    if [[ -z $universeCheck ]]; then
        echo "Adding universe repository..."
        apt-add-repository universe
    else
        apt -y update
    fi
    apt -y upgrade        
    apt -y install sniproxy netdata

fi

Debian

if [ "$lc_distro" = "Debian" ]; then lc_gateway=$(/bin/ip route show | grep default | awk '{print $3}') if_name=$(ip a | grep LOWER_UP | awk -F: '{print $2;}' | grep -v -e lo)

Netdata

    # Pre Req for Netdata on Debian
    apt -y install zlib1g-dev uuid-dev libmnl-dev pkg-config curl gcc make autoconf autoconf-archive autogen automake python python-yaml python-mysqldb nodejs lm-sensors python-psycopg2 netcat git -y
    # Installation of Netdata on Debian
    git clone https://github.com/firehol/netdata.git --depth=1
    cd netdata
    ./netdata-installer.sh
    ## sniproxy
    # Pre Req for Sniproxy on Debian
    apt -y install autotools-dev cdbs debhelper dh-autoreconf gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts
    # Installation of Sniproxy on Debian
    git clone https://github.com/dlundquist/sniproxy
    cd sniproxy
    ./autogen.sh && ./configure && make check && make install

fi

image

bntjah commented 5 years ago

Still have to check the netplan part as debian isnt using netplan as the standard ip control yet compared to ubuntu...

bntjah commented 5 years ago

We might get away with commenting line 25 and adding it to the seperate distro sections like we did with lc_gateway and the code at 223/224 with a seperate if for distro and then move it to the correct location for either ubuntu / debian...

But like I said this is all just speculation and would need testing

bntjah commented 5 years ago

The only thing that would need doing next to this is actually making a config file for debian and put this in the etc aswell, perhaps something like /etc/debian/interfaces And then move this changed interfaces file to /etc/network/interfaces

bntjah commented 5 years ago

So the code for 223/224 would look something like this:

Ubuntu

if [ "$lc_distro" = "Ubuntu" ]; then mv /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.$TIMESTAMP.bak cp $lc_base_folder/etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml fi

Debian

if [ "$lc_distro" = "Debian" ]; then mv /etc/network/interfaces /etc/network/interfaces.$TIMESTAMP.bak cp $lc_base_folder/etc/debian/interfaces /etc/network/interfaces fi image

nexusofdoom commented 5 years ago

this would be nice to work on just need more free time :-)