Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Last active January 2, 2023 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinvanemden/1996a64ee33d20d6ebbbfc0e0b7162ca to your computer and use it in GitHub Desktop.
Save robinvanemden/1996a64ee33d20d6ebbbfc0e0b7162ca to your computer and use it in GitHub Desktop.
#!/bin/bash
# run as:
#
# sudo bash -c "$(wget -q -O - https://get.sclbl.net)"
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
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
echo ""
echo "==========================================================================="
echo "= Welcome to the Scailable Edge AI Manager installer ="
echo "==========================================================================="
echo ""
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 "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}."
special=""
if [ "$archurl" == "arm64" ]; then
if uname -a | grep -q "tegra" || grep -s -q "CUDA" /usr/local/cuda/version.txt; then
if grep -s -q "CUDA" /usr/local/cuda/version.txt; then
cat /usr/local/cuda/version.txt | sed 's/^/ \* NVIDIA acceleration found: /'
fi
echo -n " * Would you like to enable 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
special="-cuda"
fi
fi
if uname -a | grep -q "scailx"; then
echo -n " * Would you like to select the Videology distribution? (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
special="-videology"
fi
fi
fi
echo ""
echo " * Start downloading package."
echo ""
echo "----------------------------------------------------------------------------"
echo ""
# if /opt doesn't exist, create it
mkdir -p /opt
# get sclbl package
wget --help | grep -q '\--show-progress' >/dev/null 2>&1 &&
_PROGRESS_OPT="-q --show-progress --inet4-only --no-check-certificate " || _PROGRESS_OPT="-q"
wget --no-check-certificate $_PROGRESS_OPT https://u330311-sub1:wP5dyndg9cxqwQyO@u330311-sub1.your-storagebox.de/lonelinux-sclbl-${archurl}${special}.tgz -O sclbl.tgz | sed 's/^/ \* /'
echo ""
echo "----------------------------------------------------------------------------"
file=sclbl.tgz
minimumsize=1000000 # 1mb
actualsize=$(wc -c <"$file")
if [ $actualsize -ge $minimumsize ]; then
echo ""
echo " * Download of lonelinux-sclbl-${archurl}${special}.tgz succesfull."
else
echo ""
echo " * Download of lonelinux-sclbl-${archurl}${special}.tgz failed."
echo ""
exit 1
fi
# extract the sclbl standalone package to /opt
echo " * Extracting lonelinux-sclbl-${archurl}${special}.tgz to /opt/sclbl."
echo ""
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
if [[ "$0" -eq "args" ]]; then
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
KEY_LENGTH=${#KEY}
VALUE="${ARGUMENT:$KEY_LENGTH+1}"
# export "$KEY"="$VALUE"
sed -i "/^$KEY=/s/=.*/=$VALUE/" /opt/sclbl/etc/settings
done
fi
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 ""
if type "crontab" >/dev/null 2>&1; then
if grep "sclbl" /etc/crontab >/dev/null 2>&1; then
echo " * The Scailable Edge AI Manager has been set to autostart on boot.";
else
echo -n " * Would you like to enable autostart on boot through /etc/crontab? (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
echo '@reboot root /opt/sclbl/etc/init startui' >> /etc/crontab
echo " * The Scailable Edge AI Manager will now autostart on boot.";
fi
fi
fi
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