#!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin export PATH LANG="en_US.UTF-8" export LANG MYPATH="/opt/bgpblist" export MYPATH if [ -s "/etc/os-release" ]; then . /etc/os-release if [ ${ID} != "debian" -a ${ID} != "ubuntu" ]; then echo "*** NOT DEBIAN OR UBUNTU ***" echo "*** WILL NOT INSTALL *******" exit 1 fi else echo "*** UNKNOWN DISTRIBUTION ***" echo "*** WILL NOT INSTALL *******" exit 1 fi MYUSER=$(whoami) if [ ${MYUSER} != "root" ]; then echo "*** USER IS NOT ROOT ***" echo "*** WILL NOT INSTALL ***" exit 1 fi echo "*** START ***" DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND trap "dpkg --configure -a" 1 2 3 9 11 15 echo "## installing tools" ls -al ${MYPATH} >/dev/null && exit 1 apt-get -q -y install git iproute2 php-cli wget curl | grep -v -e "is already the newest version" function sd_restart () { systemctl restart bgpblacklist.service } function sd_enable () { systemctl enable bgpblacklist.service } function sd_d_reload () { systemctl daemon-reload } function sd_copyunit () { cp ${MYPATH}/etc/systemd/bgpblacklist.service /etc/systemd/system/bgpblacklist.service } function bl_copy_conf () { if [ ! -s ${MYPATH}/etc/config.ini ]; then cp ${MYPATH}/etc/default/config.ini ${MYPATH}/etc/config.ini fi } function git_clone () { git clone https://git.funil.de/sinuspl/bgpblist ${MYPATH} if [ $? -gt 0 ]; then echo "ERROR: could not clone" exit 1 fi } echo "## installing service" mkdir -p ${MYPATH} bl_copy_conf sd_copyunit sd_d_reload sd_enable sd_restart echo "*** DONE ***"