Skip to content
ispc3-ai.sh 1.53 KiB
Newer Older
Marius Burkard's avatar
Marius Burkard committed
#!/bin/bash

Marius Burkard's avatar
Marius Burkard committed
CURDIR=$(pwd) ;

Marius Burkard's avatar
Marius Burkard committed
BASEDIR=$(dirname $0) ;
BASEDIR=$(realpath ${BASEDIR}) ;

CURL=$(which curl) ;
WGET=$(which wget) ;
PHP=$(which php) ;

if [ "$CURL" = "" ] ; then
	if [ "$WGET" = "" ] ; then
		echo "Curl and Wget missing, trying to install." ;
		apt-get update -qq && apt-get -y -qq install wget ;
		WGET=$(which wget) ;
	fi
	if [ "$WGET" = "" ] ; then
		echo "Wget and curl are missing. Please install either wget or curl package." ;
		exit 1 ;
	fi
fi

if [ "$PHP" = "" ] ; then
	echo "PHP cli missing, trying to install." ;
	apt-get update -qq && apt-get -y -qq install php-cli ;
	PHP=$(which php) ;
fi
if [ "$PHP" = "" ] ; then
	echo "PHP cli is missing. Please install package php-cli." ;
	exit 1;
fi

Marius Burkard's avatar
Marius Burkard committed
if [ "$CURL" != "" ] ; then
	$CURL -s -o /tmp/ispconfig-ai.tar.gz "https://www.ispconfig.org/downloads/ispconfig-ai.tar.gz" >/dev/null 2>&1
else
	$WGET -q -O /tmp/ispconfig-ai.tar.gz "https://www.ispconfig.org/downloads/ispconfig-ai.tar.gz" >/dev/null 2>&1
fi

if [ ! -f "/tmp/ispconfig-ai.tar.gz" ] ; then
	echo "Failed downloading Autoinstaller" ;
	exit 1;
fi

rm -rf /tmp/ispconfig-ai ;
mkdir /tmp/ispconfig-ai ;
tar -C /tmp/ispconfig-ai/ -xzf /tmp/ispconfig-ai.tar.gz || (echo "Failed extracting Autoinstaller" ; exit 1)
rm -f /tmp/ispconfig-ai.tar.gz ;
cd /tmp/ispconfig-ai ;

TTY=$(ps ax | grep ^$$ | head -n 1 | awk '{ print $2 }' 2>/dev/null);
if [ "$TTY" != "" ] ; then
	${PHP} -q /tmp/ispconfig-ai/ispconfig.ai.php $@ < /dev/${TTY} ;
else 
	${PHP} -q /tmp/ispconfig-ai/ispconfig.ai.php $@ ;
fi
Marius Burkard's avatar
Marius Burkard committed

Marius Burkard's avatar
Marius Burkard committed
cd ${CURDIR} ;
rm -rf /tmp/ispconfig-ai ;