Created
August 23, 2022 08:39
-
-
Save robinvanemden/5e4707253cbd48115f2d8e7bc7b4561d to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -e | |
#trap 'echo " * Script failed with exit code $?"' EXIT | |
echo "" | |
echo "===========================================================================" | |
echo "= Welcome to the Scailable Edge AI Manager installer =" | |
echo "===========================================================================" | |
echo "" | |
# run as: | |
# | |
# sudo bash -c "$(wget -q -O - https://get.sclbl.net)" | |
# | |
# or, if you prefer curl: | |
# | |
# sudo bash -c "$(curl -s -L https://get.sclbl.net)" | |
if ! type "uname" >/dev/null 2>&1; then | |
echo 'Error: The POSIX "uname" command cannot be found. Please install and try again.' >&2 | |
exit 1 | |
fi | |
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 ! type "grep" >/dev/null 2>&1; then | |
echo 'Error: The POSIX "grep" 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}." | |
cuda="" | |
#if grep -s -q "CUDA" /usr/local/cuda/version.txt && [ "$archurl" == "arm64" ]; then | |
cat /usr/local/cuda/version.txt | sed 's/^/ \* NVIDIA acceleration found: /' | |
echo -n " * Would you like to enable experimental CUDA support? (y/n)? " | |
read answer | |
finish="-1" | |
while [ "$finish" = '-1' ]; do | |
finish="1" | |
if [ "$answer" = '' ]; then | |
answer="" | |
else | |
case $answer in | |
y | Y | yes | YES) answer="y" ;; | |
n | N | no | NO) answer="n" ;; | |
*) | |
finish="-1" | |
echo -n ' * Invalid response -- please reenter:' | |
read answer | |
;; | |
esac | |
fi | |
done | |
if [ "$answer" = 'y' ]; then | |
cuda="-cuda" | |
fi | |
#fi | |
echo "" | |
echo " * Start downloading package." | |
echo "" | |
# 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 --help | grep -q '\--show-progress' && | |
_PROGRESS_OPT="-q --show-progress --progress=dot --inet4-only --no-check-certificate " || _PROGRESS_OPT="-q" | |
wget $_PROGRESS_OPT https://github.com/scailable/sclbl-tutorials/blob/master/downloads/files/lonelinux-sclbl-${archurl}${cuda}.tgz?raw=true -O sclbl.tgz | sed 's/^/ \* /' | |
file=sclbl.tgz | |
minimumsize=1000000 # 1mb | |
actualsize=$(wc -c <"$file") | |
if [ $actualsize -ge $minimumsize ]; then | |
echo "" | |
echo "" | |
echo " * Download of lonelinux-sclbl-${archurl}${cuda}.tgz succesfull." | |
else | |
echo " * Download of lonelinux-sclbl-${archurl}${cuda}.tgz failed." | |
echo "" | |
exit 1 | |
fi | |
# extract the sclbl standalone package to /opt | |
echo " * Extracting lonelinux-sclbl-${archurl}${cuda}.tgz to /opt/sclbl." | |
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 "" | |
# 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 "===========================================================================" | |
echo "= The Scailable AI manager has been started =" | |
echo "===========================================================================" | |
echo "" | |
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