Skip to content

Instantly share code, notes, and snippets.

@sholwe
Last active January 26, 2019 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sholwe/b065db843024457c5be6be5df66b0168 to your computer and use it in GitHub Desktop.
Save sholwe/b065db843024457c5be6be5df66b0168 to your computer and use it in GitHub Desktop.
Devuan-kindof kernelcare installer script
#!/bin/bash
#
# KernelCare (https://kernelcare.com/) installation script
# Copyright (c) 2017 CloudLinux Inc. All Rights Reserved
# Unofficial edits by Shawn Holwegner
set -e -o pipefail
repo="https://repo.cloudlinux.com/kernelcare"
name="kernelcare-latest"
distr="debian"
rel="9.0"
if [ -e /etc/os-release ]; then
distr=$(grep -w 'ID' /etc/os-release | cut -d'=' -f2|tr -d '"')
if [ "$distr" == "debian" ] || [ "$distr" == "devuan" ] || [ "$distr" == "ubuntu" ]; then
repo=${repo}-debian
apt-get -y -q install curl
else
yum -y -q install curl
fi
#I really don't like their script design, but whatever.
if [ "$distr" == "devuan" ]; then
ver=$(grep -w 'PRETTY_NAME' /etc/os-release | cut -d' ' -f3 | grep -oE "[a-z]*")
if [ "$ver" == "ascii" ]; then rel="9" pkg=${name}-9.deb
else rel="8" pkg=${name}-8.deb
fi
else
rel=$(grep -w 'VERSION_ID' /etc/os-release | cut -d'.' -f1 | grep -oE "[0-9]*")
fi
case $distr in
"devuan")
if [ "$rel" -ge "9" ]; then pkg=${name}-9.deb
elif [ "$rel" -eq "8" ]; then pkg=${name}-8.deb
else pkg=${name}-6.deb
fi
;;
"debian")
if [ "$rel" -ge "9" ]; then pkg=${name}-9.deb
elif [ "$rel" -eq "8" ]; then pkg=${name}-8.deb
else pkg=${name}-6.deb
fi
;;
"ubuntu")
if [ "$rel" -ge "14" ]; then pkg=${name}-8.deb
else pkg=${name}-6.deb
fi
;;
"amzn")
rel='7'
pkg=${name}-${rel}.rpm
;;
* )
pkg=${name}-${rel}.rpm
;;
esac
elif [ -e /etc/system-release ]; then
rel=$(cut -d'.' -f1 /etc/system-release | grep -oE "[0-9]")
pkg=${name}-${rel}.rpm
else
rel=$(cut -d'.' -f1 /etc/redhat-release | grep -oE "[0-9]")
pkg=${name}-${rel}.rpm
fi
cd /root/
curl -O ${repo}/${pkg}
if [ "$distr" == "debian" ] || [ "$distr" == "devuan" ] || [ "$distr" == "ubuntu" ]; then
dpkg -i $pkg
else
if [ "$rel" == "5" ]; then
yum -y localinstall $pkg --nogpgcheck
else
yum -y localinstall $pkg
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment