Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 137 lines (123 sloc) 3.56 KB
#! /bin/bash
#
# This script will download, build and install the
# macchina.io Remote Manager SDK executables from
# <https://github.com/my-devices/sdk>.
#
function unsupportedPlatform {
echo "Sorry, your platform is not supported by this script."
echo "Please install manually by following the instructions"
echo "at <https://github.com/my-devices/sdk>."
exit 1
}
echo ""
echo "##"
echo "##"
echo "## Welcome to the macchina.io Remote Manager Device Agent and Utilities Installer."
echo "##"
echo "##"
echo ""
echo "This script will download, build and install the"
echo "macchina.io Remote Manager device agent (WebTunnelAgent) and utility"
echo "(WebTunnelClient, WebTunnelSSH, WebTunnelRDP, WebTunnelVNC) executables from"
echo "<https://github.com/my-devices/sdk>."
echo ""
os=`uname`
repo="https://github.com/my-devices/sdk.git"
builddir=/tmp/my-devices-sdk-build.$$
installdir=/usr/local/bin
CMAKE=cmake
if [ "$os" = "Darwin" ] ; then
cmakeOptions="-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_USE_STATIC_LIBS=TRUE"
fi
curlpath=`which curl`
if [ "$curlpath" = "" ] ; then
echo "curl is required to run this script."
exit 2
fi
if [ "$os" = "Linux" ] ; then
if [ -x /usr/bin/apt-get ] ; then
cmd="sudo apt-get -y update && sudo apt-get -y install git g++ make cmake libssl-dev"
elif [ -x /bin/yum ] ; then
cmd="sudo yum install -y git gcc-c++ make cmake3 openssl-devel"
CMAKE=cmake3
fi
if [ "$cmd" != "" ] ; then
echo "Installing dependencies (git, g++, make, cmake, openssl)."
echo "About to run $cmd"
echo "Please provide your sudo password when prompted."
sh -c "$cmd"
else
unsupportedPlatform
fi
elif [ "$os" = Darwin ] ; then
if [ -x /usr/local/bin/brew ] ; then
if [ -x /usr/bin/clang ] ; then
echo "Installing dependencies (cmake, openssl) using Homebrew."
brew install cmake openssl
else
echo "Please install the Xcode command-line tools before"
echo "running this script."
exit 1
fi
else
echo "Please install Homebrew before running this script."
echo "See <https://brew.sh> for more information."
exit 1
fi
else
unsupportedPlatform
fi
echo "Done installing dependencies."
echo ""
echo "Downloading sources from GitHub to $builddir..."
if [ -d $builddir ] ; then
echo "Directory $builddir already exists."
echo "Please manually remove the directory and try again."
exit 2
fi
mkdir -p $builddir
if [ $? -ne 0 ] ; then
echo "Failed to create directory $builddir. Exiting."
exit 3
fi
basedir=`pwd`
cd $builddir
git clone https://github.com/my-devices/sdk.git
if [ $? -ne 0 ] ; then
echo "Failed to clone GitHub repository. Exiting."
exit 4
fi
echo "Configuring and building SDK..."
cd sdk
mkdir cmake-build
if [ $? -ne 0 ] ; then
echo "Failed to create cmake-build directory. Exiting."
exit 4
fi
cd cmake-build
$CMAKE .. $cmakeOptions
if [ $? -ne 0 ] ; then
echo "Failed to configure CMake build. Exiting."
exit 5
fi
$CMAKE --build . --config Release -- -j2
if [ $? -ne 0 ] ; then
echo "Failed to build project. Exiting."
exit 5
fi
echo "Build completed."
echo ""
echo "Copying executables to $installdir..."
echo "Please provide your sudo password when prompted."
find ./bin -name 'WebTunnel*' -type f -perm -755 -exec strip {} \; -exec sudo cp {} $installdir \;
if [ $? -ne 0 ] ; then
echo "Failed to install agent executable. Exiting."
exit 6
fi
cd $basedir
echo "Executables successfully installed. Removing build directory $builddir..."
rm -rf $builddir
echo ""
echo "Completed."
echo "Thank you for installing the macchina.io Remote Manager Device Agent and Utilities."
You can’t perform that action at this time.