Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Last active Jun 16, 2022
Embed
What would you like to do?
#!/bin/bash
echo ""
echo "==========================================================================="
echo "= Welcome to the Scailable Edge AI Manager installer ="
echo "==========================================================================="
echo ""
# run as:
#
# wget -q -O - https://get.sclbl.net | sudo bash
if ! type "killall" >/dev/null 2>&1; then
echo 'Error: The POSIX "killall" command cannot be found. Please install and try again.' >&2
exit 1
fi
if ! type "wget" >/dev/null 2>&1; then
echo 'Error: The POSIX "wget" command cannot be found. Please install and try again.' >&2
exit 1
fi
if ! type "tar" >/dev/null 2>&1; then
echo 'Error: The POSIX "tar" command cannot be found. Please install and try again.' >&2
exit 1
fi
if ! type "sed" >/dev/null 2>&1; then
echo 'Error: The POSIX "sed" command cannot be found. Please install and try again.' >&2
exit 1
fi
if [ "$(id -u)" -ne 0 ]; then echo 'Please run as root.' >&2; exit 1; fi
function get_architecture
{
if uname -m | grep -qx "alpha"; then
echo "alpha"
elif uname -m | grep -q "armv4"; then
echo "armv4"
elif uname -m | grep -q "armv5"; then
echo "armv5"
elif uname -m | grep -q "armv6"; then
if grep -q vfp /proc/cpuinfo; then
echo "armv6hf"
else
echo "armv6"
fi
elif uname -m | grep -q "armv7"; then
if grep -q vfp /proc/cpuinfo; then
echo "armv7hf"
else
echo "armv7"
fi
elif uname -m | grep -q "aarch64"; then
echo "aarch64"
elif uname -m | grep -qx "i386"; then
echo "i386"
elif uname -m | grep -qx "i686"; then
echo "i686"
elif uname -m | grep -qx "mips"; then
echo "mips"
elif uname -m | grep -qx "ppc"; then
echo "ppc"
elif uname -m | grep -qx "ppc64"; then
echo "ppc64"
elif uname -m | grep -qx "sparc64"; then
echo "sparc64"
elif uname -m | grep -qx "x86_64"; then
echo "x86_64"
elif uname -m | grep -qx "amd64"; then
echo "x86_64"
else
echo "unknown"
fi
}
archurl=$(get_architecture)
case ${archurl} in
aarch64) archurl="arm64" ;;
arm64) archurl="arm64" ;;
armv7hf) archurl="arm32" ;;
armv7) archurl="arm32" ;;
x86_64) archurl="x86_64" ;;
*) echo " * Unsupported architecture ${archurl}."; exit 1 ;;
esac
platform='unknown'
unamestr=$(uname)
if [ "$unamestr" = 'Linux' ]; then
platform='linux'
elif [ "$unamestr" = 'FreeBSD' ]; then
platform='freebsd'
fi
echo " * Your device's architecture is ${archurl}."
echo " * Your device's platform is ${platform}."
echo " * Downloading package."
# kill running processes if exist
killall uiprovider 2>/dev/null
killall sclblmod 2>/dev/null
killall sclbld 2>/dev/null
killall sclbl-output-distributor 2> /dev/null
# if /opt doesn't exist, create it
mkdir -p /opt
# get sclbl package
wget -q https://github.com/scailable/sclbl-tutorials/blob/master/downloads/files/lonelinux-sclbl-${archurl}.tgz?raw=true -O sclbl.tgz
echo " * Extracting package."
# extract the sclbl standalone package to /opt
tar xfz *sclbl*tgz -C /opt
# delete the tgz
rm *sclbl*tgz
echo " * Creating settings file if not exists."
cp -n /opt/sclbl/etc/defaults /opt/sclbl/etc/settings
echo " * Creating cache directory."
mkdir -p /var/cache/sclbl
echo " * Initializing settings file."
/opt/sclbl/bin/uiprovider serial >/dev/null 2>&1
echo " * Starting UI server."
echo ""
echo "==========================================================================="
echo "= The Scailable AI manager has been installed in /opt/sclbl ="
echo "==========================================================================="
echo ""
echo "==========================================================================="
echo "= The Scailable AI manager has been started ="
echo "==========================================================================="
echo ""
# start the ui server on http port 8081 https 8443
# and the outputdistributor on localhost port 8012
cd /opt/sclbl/etc
chmod 775 init
./init startui
echo "==========================================================================="
echo "= Go to http://localhost:8081 or ="
echo "= https://localhost:8443 to access the Scailable Edge AI Manager ="
echo "==========================================================================="
echo ""
if type "ip" >/dev/null 2>&1; then
echo "Autodetected alternative URLs:"
echo ""
arr=$(ip addr | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
for address in $arr ; do echo " * http://${address}:8081" ; done
for address in $arr ; do echo " * https://${address}:8443" ; done
echo ""
elif type "ifconfig" >/dev/null 2>&1; then
echo "Autodetected alternative URLs:"
echo ""
arr=$(ifconfig | grep -v inet6 | grep -v 127.0.0.1 | awk -v i=$i '/inet6?/{print i "" $2}')
for address in $arr ; do echo " * http://${address}:8081" ; done
for address in $arr ; do echo " * https://${address}:8443" ; done
echo ""
fi
echo "Start and stop the Scailable Edge AI Manager with respectively:"
echo ""
echo " $ sudo /opt/sclbl/etc/init startui"
echo " $ sudo /opt/sclbl/etc/init stopui"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment