#!/bin/sh # _ _ ___ __ _ (R) # | | (_)_ _____ / __|___ _ _ / _(_)__ _ # | |__| \ V / -_) (__/ _ \ ' \| _| / _` | # |____|_|\_/\___|\___\___/_||_|_| |_\__, |___________________________________ # |___/ # LiveConfig automated install script # # Source: https://install.liveconfig.com # Documentation: https://www.liveconfig.com/install # ____________________________________________________________________________ INST_VERSION="1.8" TERM_RED=`tput setaf 1 2>/dev/null || echo ""` TERM_NORMAL=`tput sgr0 2>/dev/null || echo ""` TERM_CLEAR=`tput clear 2>/dev/null || echo ""` TERM_BOLD=`tput bold 2>/dev/null || echo ""` install_yum() { PACKAGE=$1 rpm -qa | grep $PACKAGE > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "Installing package '$PACKAGE'" yum install -y -q $PACKAGE if [ $? -ne 0 ]; then print_translated "Failed to install $PACKAGE" print_footer exit 2 fi fi } check_requirements() { if [ "$(whoami)" != "root" ]; then print_header print_bold "This script needs to be run as root." print_footer exit 1 fi wget=$(which wget 2> /dev/null) if [ $? -eq 0 ]; then dltool_file="${wget} -nv" dltool_stdout="${wget} -nv -O -" return fi curl=$(which curl 2> /dev/null) if [ $? -eq 0 ]; then dltool_file="${curl} -OsS" dltool_stdout="${curl} -sS" return fi print_header print_bold "Neither 'wget' nor 'curl' are installed on this system. Please install at least one of them." print_footer exit 1; } download() { ${dltool_file} "$@" } download_stdout() { ${dltool_stdout} "$@" } print_header() { echo "${TERM_CLEAR}${TERM_RED} _ _ ___ __ _ (R)" echo "| | (_)_ _____ / __|___ _ _ / _(_)__ _" echo "| |__| \\ V / -_) (__/ _ \\ ' \\| _| / _\` | ${TERM_NORMAL}LiveConfig Installer v${INST_VERSION}${TERM_RED}" echo "|____|_|\\_/\\___|\\___\\___/_||_|_| |_\\__, |_____________________________________" echo " |___/${TERM_NORMAL}\n" } print_footer() { echo "${TERM_RED}______________________________________________________________________________${TERM_NORMAL}\n" } print_bold() { echo ${TERM_BOLD}$( translate "$1" )${TERM_NORMAL} } print_translated() { echo $( translate "$1" ) } ask_yes_no() { echo -n ${TERM_BOLD}$( translate "$1" )${TERM_NORMAL} $( translate "([y]es or [N]o):" ) "" read INP /dev/null 2>&1 if [ $? -ne 0 ]; then print_bold "Failed to install required packages" print_footer exit 2 fi dpkg -s liveconfig-keyring > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "Adding LiveConfig repository..." cd /root download https://www.liveconfig.com/liveconfig-keyring.deb dpkg -i liveconfig-keyring.deb if [ $? -ne 0 ]; then print_bold "Installation of package 'liveconfig-keyring' failed!" print_footer exit 3 fi rm liveconfig-keyring.deb fi apt update if [ $? -ne 0 ]; then print_bold "apt update failed!" print_footer exit 5 fi dpkg -s liveconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then # Install LiveConfig print_bold "Installing LiveConfig..." apt-get install -qy liveconfig if [ $? -ne 0 ]; then print_bold "Installation of LiveConfig failed!" print_footer exit 6 fi else print_bold "LiveConfig already installed!" fi ask_yes_no "Do you want to install a basic hosting environment (install liveconfig-meta package)?" if [ $? -eq 1 ]; then # Install liveconfig-meta package echo print_translated "Installing LiveConfig Meta package for basic hosting environment" LANG=C DEBIAN_FRONTEND=noninteractive apt-get -qy -o APT::Install-Recommends=no install liveconfig-meta if [ $? -ne 0 ]; then print_bold "Installation of LiveConfig Meta package failed!" print_footer exit 7 fi service liveconfig restart else echo fi print_bold "LiveConfig successfully installed." } install_opensuse() { print_header print_bold "Installing on openSUSE system" rpm -qa | grep ca-certificates > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "ca-certificates not installed yet -> installing" zypper install ca-certificates if [ $? -ne 0 ]; then print_translated "Failed to install ca-certificates" print_footer exit 2 fi fi rpm -qi gpg-pubkey-65fe6664-* > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "RPM key not imported yet -> importing liveconfig.key" rpm --import https://www.liveconfig.com/liveconfig.key if [ $? -ne 0 ]; then print_translated "Import of RPM key failed!" print_footer exit 3 fi fi zypper --no-color repos | grep -i liveconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "Zypper repository not added yet" zypper -n addrepo -f http://repo.liveconfig.com/opensuse/liveconfig.repo if [ $? -ne 0 ]; then print_translated "Import of Zypper repository failed!" print_footer exit 4 fi fi zypper update if [ $? -ne 0 ]; then print_translated "Zypper update failed!" print_footer exit 5 fi rpm -qa | grep -i liveconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then # Install LiveConfig print_bold "Installing LiveConfig..." zypper install liveconfig if [ $? -ne 0 ]; then print_bold "Installation of LiveConfig failed!" print_footer exit 6 fi else print_bold "LiveConfig already installed." fi ask_yes_no "Do you want to install a basic hosting environment (install liveconfig-meta package)?" if [ $? -eq 1 ]; then # Install liveconfig-meta package echo print_translated "Installing LiveConfig Meta package for basic hosting environment" zypper install liveconfig-meta if [ $? -ne 0 ]; then print_translated "Installation of LiveConfig Meta package failed!" print_footer exit 7 fi service liveconfig restart else echo fi print_bold "LiveConfig successfully installed." } install_centos() { print_header print_bold "Installing on CentOS system" yum check 1>/dev/null 2>/dev/null if [ $? -ne 0 ]; then ask_yes_no "yum check failed - try to reinstall missing/broken packages?" if [ $? -eq 1 ]; then PKGLIST=`LANG=C yum check 2>/dev/null | grep 'has missing requires' | cut -d ' ' -f 1 | sort | uniq | tr '\n' ' '` if [ -n "$PKGLIST" ]; then print_translated "Reinstalling packages: " echo $PKGLIST yum -y reinstall $PKGLIST else print_translated "No missing packages found. Please run 'yum check'." exit 1 fi else print_translated "aborting." exit 1 fi fi print_translated "Checking/installing required packages..." install_yum ca-certificates # install_yum nss-pem rpm -qi gpg-pubkey-65fe6664-* > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "RPM key not imported yet -> importing liveconfig.key" rpm --import https://www.liveconfig.com/liveconfig.key if [ $? -ne 0 ]; then print_translated "Import of RPM key failed!" print_footer exit 2 fi fi ls /etc/yum.repos.d | grep -i liveconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then print_translated "Adding LiveConfig repository" cd /etc/yum.repos.d if [ $? -ne 0 ]; then print_translated "Failed to change directory to /etc/yum.repos.d!" print_footer exit 3 fi download http://repo.liveconfig.com/centos/liveconfig.repo if [ $? -ne 0 ]; then print_translated "Failed to download liveconfig yum-repository file!" print_footer exit 3 fi fi print_translated "Updating repository & packages" yum -y -q update if [ $? -ne 0 ]; then print_translated "Yum update failed!" print_footer exit 4 fi yum list installed liveconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then # Install LiveConfig print_bold "Installing LiveConfig..." yum -y -q install liveconfig if [ $? -ne 0 ]; then print_bold "Installation of LiveConfig failed!" print_footer exit 5 fi else print_bold "LiveConfig already installed." fi ask_yes_no "Do you want to install a basic hosting environment (install liveconfig-meta package)?" if [ $? -eq 1 ]; then # Install liveconfig-meta package echo print_translated "Installing LiveConfig Meta package for basic hosting environment!" yum -y -q install liveconfig-meta if [ $? -ne 0 ]; then print_translated "Installation of LiveConfig Meta package failed!" print_footer exit 6 fi service liveconfig restart else echo fi print_bold "LiveConfig successfully installed." } check_requirements detect_distro case ${distro} in deb) install_debian_ubuntu ;; opensuse) install_opensuse ;; centos) install_centos ;; *) distro_unknown ;; esac