Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Last active Jan 29, 2022
Embed
What would you like to do?
Reset Scailable Edge AI Manager
#!/bin/bash
echo ""
echo "========================================================================"
echo "= Welcome to the Scailable Edge AI Manager Test Install ="
echo "========================================================================"
echo ""
# run as:
#
# wget -q -O - https://get.sclbl.net | sudo bash
if ! [ -x "$(command -v killall)" ]; then
echo 'Error: The POSIX "killall" command cannot be found. Please install and try again.' >&2
exit 1
fi
if ! [ -x "$(command -v wget)" ]; then
echo 'Error: The POSIX "wget" command cannot be found. Please install and try again.' >&2
exit 1
fi
if ! [ -x "$(command -v tar)" ]; then
echo 'Error: The POSIX "tar" command cannot be found. Please install and try again.' >&2
exit 1
fi
if ! [ -x "$(command -v sed)" ]; 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
case `dpkg --print-architecture` in
aarch64) archurl="arm64" ;;
arm64) archurl="arm64" ;;
arm32) archurl="arm32" ;;
arm) archurl="arm32" ;;
amd64) archurl="x86_64" ;;
x86_64) archurl="x86_64" ;;
i*86) archurl="i386" ;;
x86) archurl="i386" ;;
*) echo " * Unknown architecture ${archurl}."; exit 1 ;;
esac
echo " * Your device's architecture is ${archurl}."
echo " * Remove existing install. "
# kill running processes if exist
killall uiprovider 2>/dev/null
killall sclblmod 2>/dev/null
killall sclbld 2>/dev/null
rm -rf /opt/sclbl
echo " * Downloading package."
# 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 " * Copying ssl key and cert."
cp /etc/letsencrypt/live/run.sclbl.net/privkey.pem /opt/sclbl/bin/https-server.key 2> /dev/null
cp /etc/letsencrypt/live/run.sclbl.net/cert.pem /opt/sclbl/bin/https-server.crt 2> /dev/null
echo " * Creating cache directory."
mkdir -p /var/cache/sclbl
echo " * Creating settings file."
/opt/sclbl/bin/uiprovider serial >/dev/null 2>&1
echo " * Creating random uuid for device."
cd /opt/sclbl/etc && cp defaults settings
UUID=$(cat /proc/sys/kernel/random/uuid)&&sed -i "s/DeviceId=.*/DeviceId=${UUID}/" /opt/sclbl/etc/settings
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 ""
# run the server on port 8081
cd /opt/sclbl/bin
nohup ./uiprovider > log.txt 2>&1 &
echo "========================================================================"
echo "= Go to https://localhost:8081 to access the Scailable Edge AI Manager ="
echo "========================================================================"
echo ""
if [ -x "$(command -v ip)" ]; 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 " * https://${address}:8081" ; 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