107 lines
2.9 KiB
Bash
Executable File
107 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
HostName="https://remotely.akanealw.com"
|
|
Organization="7fbfb541-0720-42cf-b363-ddf13a19fd16"
|
|
GUID=$(cat /proc/sys/kernel/random/uuid)
|
|
UpdatePackagePath=""
|
|
InstallDir="/usr/local/bin/Remotely"
|
|
|
|
apt-get update
|
|
apt-get -y install curl lsb-release apt-transport-https libx11-dev libxrandr-dev unzip libc6-dev libxtst-dev xclip jq
|
|
|
|
ETag=$(curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2)
|
|
LogPath="/var/log/remotely/Agent_Install.log"
|
|
|
|
mkdir -p /var/log/remotely
|
|
Args=( "$@" )
|
|
ArgLength=${#Args[@]}
|
|
|
|
for (( i=0; i<${ArgLength}; i+=2 ));
|
|
do
|
|
if [ "${Args[$i]}" = "--uninstall" ]; then
|
|
systemctl stop remotely-agent
|
|
rm -r -f $InstallDir
|
|
rm -f /etc/systemd/system/remotely-agent.service
|
|
systemctl daemon-reload
|
|
exit
|
|
elif [ "${Args[$i]}" = "--path" ]; then
|
|
UpdatePackagePath="${Args[$i+1]}"
|
|
fi
|
|
done
|
|
|
|
if [ -z "$ETag" ]; then
|
|
echo "ETag is empty. Aborting install." | tee -a $LogPath
|
|
exit 1
|
|
fi
|
|
|
|
debianVersion=$(lsb_release -r -s)
|
|
|
|
wget -q https://packages.microsoft.com/config/debian/$debianVersion/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
|
dpkg -i packages-microsoft-prod.deb
|
|
apt-get update
|
|
#apt-get -y install apt-transport-https
|
|
apt-get -y install dotnet-runtime-7.0
|
|
rm packages-microsoft-prod.deb
|
|
|
|
#apt-get -y install libx11-dev libxrandr-dev unzip libc6-dev libxtst-dev xclip jq
|
|
|
|
|
|
if [ -f "$InstallDir/ConnectionInfo.json" ]; then
|
|
SavedGUID=`cat "$InstallDir/ConnectionInfo.json" | jq -r '.DeviceID'`
|
|
if [[ "$SavedGUID" != "null" && -n "$SavedGUID" ]]; then
|
|
GUID="$SavedGUID"
|
|
fi
|
|
fi
|
|
|
|
rm -r -f $InstallDir
|
|
rm -f /etc/systemd/system/remotely-agent.service
|
|
|
|
mkdir -p $InstallDir
|
|
|
|
if [ -z "$UpdatePackagePath" ]; then
|
|
echo "Downloading client." | tee -a $LogPath
|
|
wget -q -O /tmp/Remotely-Linux.zip $HostName/Content/Remotely-Linux.zip
|
|
else
|
|
echo "Copying install files." | tee -a $LogPath
|
|
cp "$UpdatePackagePath" /tmp/Remotely-Linux.zip
|
|
rm -f "$UpdatePackagePath"
|
|
fi
|
|
|
|
unzip -o /tmp/Remotely-Linux.zip -d $InstallDir
|
|
rm -f /tmp/Remotely-Linux.zip
|
|
chmod +x $InstallDir/Remotely_Agent
|
|
chmod +x $InstallDir/Desktop/Remotely_Desktop
|
|
|
|
|
|
connectionInfo="{
|
|
\"DeviceID\":\"$GUID\",
|
|
\"Host\":\"$HostName\",
|
|
\"OrganizationID\": \"$Organization\",
|
|
\"ServerVerificationToken\":\"\"
|
|
}"
|
|
|
|
echo "$connectionInfo" > $InstallDir/ConnectionInfo.json
|
|
|
|
curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2 > $InstallDir/etag.txt
|
|
|
|
echo Creating service. | tee -a $LogPath
|
|
|
|
serviceConfig="[Unit]
|
|
Description=The Remotely agent used for remote access.
|
|
|
|
[Service]
|
|
WorkingDirectory=$InstallDir
|
|
ExecStart=$InstallDir/Remotely_Agent
|
|
Restart=always
|
|
StartLimitIntervalSec=0
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=graphical.target"
|
|
|
|
echo "$serviceConfig" > /etc/systemd/system/remotely-agent.service
|
|
|
|
systemctl enable remotely-agent
|
|
systemctl restart remotely-agent
|
|
|
|
echo Install complete. | tee -a $LogPath
|