7 Periodic update

This commit is contained in:
Eliezer Croitoru 2024-08-16 14:16:53 +03:00
parent 81c30d15d4
commit 3f654ef5d1
3 changed files with 134 additions and 169 deletions

View File

@ -3,7 +3,7 @@ FROM alpine:latest
ARG TARGETOS
ARG TARGETARCH
ENV ENCRYPTED_ONLY 0
ENV ENCRYPTED_ONLY=0
RUN apk update && apk add --no-cache supervisor && mkdir -p /opt/rustdesk && mkdir /public && mkdir /data

View File

@ -1,4 +1,13 @@
$ErrorActionPreference= 'silentlycontinue'
# Assign the value random password to the password variable
$rustdesk_pw=(-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_}))
# Get your config string from your Web portal and Fill Below
$rustdesk_cfg="secure-string"
################################### Please Do Not Edit Below This Line #########################################
# Run as administrator and stays in the current directory
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
@ -6,125 +15,90 @@ if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
Exit;
}
}
# Replace wanipreg and keyreg with the relevant info for your install. IE wanipreg becomes your rustdesk server IP or DNS and keyreg becomes your public key.
$rustdesk_url = 'https://github.com/rustdesk/rustdesk/releases/latest'
$request = [System.Net.WebRequest]::Create($rustdesk_url)
# Checks for the latest version of RustDesk
$url = 'https://www.github.com//rustdesk/rustdesk/releases/latest'
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()
$realTagUrl = $response.ResponseUri.OriginalString
$rustdesk_version = $realTagUrl.split('/')[-1].Trim('v')
Write-Output("Installing Rustdesk version $rustdesk_version")
$RDLATEST = $realTagUrl.split('/')[-1].Trim('v')
echo "RustDesk $RDLATEST is the latest version."
function OutputIDandPW([String]$rustdesk_id, [String]$rustdesk_pw) {
Write-Output("######################################################")
Write-Output("# #")
Write-Output("# CONNECTION PARAMETERS: #")
Write-Output("# #")
Write-Output("######################################################")
Write-Output("")
Write-Output(" RustDesk-ID: $rustdesk_id")
Write-Output(" RustDesk-Password: $rustdesk_pw")
Write-Output("")
# Checks the version of RustDesk installed.
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
# Skips to inputting the configuration if the latest version of RustDesk is already installed.
if($rdver -eq "$RDLATEST") {
echo "RustDesk $rdver is already installed."
cd $env:ProgramFiles\RustDesk
echo "Inputting configuration now."
.\rustdesk.exe --config $rustdesk_cfg
.\rustdesk.exe --password $rustdesk_pw
$rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
echo "All done! Please double check the Network settings tab in RustDesk."
echo ""
echo "..............................................."
# Show the value of the ID Variable
echo "RustDesk ID: $rustdesk_id"
# Show the value of the Password Variable
echo "Password: $rustdesk_pw"
echo "..............................................."
echo ""
echo "Press Enter to open RustDesk."
pause
.\rustdesk.exe
exit
}
If (!(Test-Path $env:Temp)) {
New-Item -ItemType Directory -Force -Path $env:Temp > null
if (!(Test-Path C:\Temp)) {
New-Item -ItemType Directory -Force -Path C:\Temp > null
}
If (!(Test-Path "$env:ProgramFiles\Rustdesk\RustDesk.exe")) {
cd C:\Temp
echo "Downloading RustDesk version $RDLATEST."
powershell Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/$RDLATEST/rustdesk-$RDLATEST-x86_64.exe" -Outfile "rustdesk.exe"
echo "Installing RustDesk version $RDLATEST."
Start-Process .\rustdesk.exe --silent-install
Start-Sleep -Seconds 10
cd $env:Temp
$ServiceName = 'rustdesk'
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
If ([Environment]::Is64BitOperatingSystem) {
$os_arch = "x64"
} Else {
$os_arch = "x32"
if ($arrService -eq $null)
{
echo "Installing service."
cd $env:ProgramFiles\RustDesk
Start-Process .\rustdesk.exe --install-service -wait -Verbose
Start-Sleep -Seconds 20
}
Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/$rustdesk_version/rustdesk-$rustdesk_version-windows_$os_arch.zip -Outfile rustdesk.zip
Expand-Archive rustdesk.zip
cd rustdesk
Start-Process "rustdesk-$rustdesk_version-putes.exe" -argumentlist "--silent-install" -wait
# Set URL Handler
New-Item -Path "HKLM:\SOFTWARE\Classes\RustDesk" > null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Classes\RustDesk" -Name "(Default)" -Value "URL:RustDesk Protocol" > null
New-ItemProperty -Path "HKLM:\SOFTWARE\Classes\RustDesk" -Name "URL Protocol" -Type STRING > null
New-Item -Path "HKLM:\SOFTWARE\Classes\RustDesk\DefaultIcon" > null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Classes\RustDesk\DefaultIcon" -Name "(Default)" -Value "RustDesk.exe,0" > null
New-Item -Path "HKLM:\SOFTWARE\Classes\RustDesk\shell" > null
New-Item -Path "HKLM:\SOFTWARE\Classes\RustDesk\shell\open" > null
New-Item -Path "HKLM:\SOFTWARE\Classes\RustDesk\shell\open\command" > null
$rustdesklauncher = '"' + $env:ProgramFiles + '\RustDesk\RustDeskURLLauncher.exe" %1"'
Set-ItemProperty -Path "HKLM:\SOFTWARE\Classes\RustDesk\shell\open\command" -Name "(Default)" -Value $rustdesklauncher > null
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force > null
Install-Module ps2exe -Force > null
$urlhandler_ps1 = @"
`$url_handler = `$args[0]
`$rustdesk_id = `$url_handler -creplace '(?s)^.*\:',''
Start-Process -FilePath '$env:ProgramFiles\RustDesk\rustdesk.exe' -ArgumentList "--connect `$rustdesk_id"
"@
New-Item "$env:ProgramFiles\RustDesk\urlhandler.ps1" > null
Set-Content "$env:ProgramFiles\RustDesk\urlhandler.ps1" $urlhandler_ps1 > null
Invoke-Ps2Exe "$env:ProgramFiles\RustDesk\urlhandler.ps1" "$env:ProgramFiles\RustDesk\RustDeskURLLauncher.exe" > null
# Cleanup Tempfiles
Remove-Item "$env:ProgramFiles\RustDesk\urlhandler.ps1" > null
cd $env:Temp
Remove-Item $env:Temp\rustdesk -Recurse > null
Remove-Item $env:Temp\rustdesk.zip > null
while ($arrService.Status -ne 'Running')
{
Start-Service $ServiceName
Start-Sleep -seconds 5
$arrService.Refresh()
}
# Write config
$RustDesk2_toml = @"
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 0
# Waits for installation to complete before proceeding.
echo "Please wait a few seconds."
Start-Sleep -Seconds 10
[options]
custom-rendezvous-server = 'wanipreg'
key = 'keyreg'
relay-server = 'wanipreg'
api-server = 'https://wanipreg'
enable-audio = 'N'
direct-server = 'Y'
"@
cd $env:ProgramFiles\RustDesk
echo "Inputting configuration now."
.\rustdesk.exe --config $rustdesk_cfg
.\rustdesk.exe --password $rustdesk_pw
$rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
echo "All done! Please double check the Network settings tab in RustDesk."
echo ""
echo "..............................................."
# Show the value of the ID Variable
echo "RustDesk ID: $rustdesk_id"
If (!(Test-Path $env:AppData\RustDesk\config\RustDesk2.toml)) {
New-Item $env:AppData\RustDesk\config\RustDesk2.toml > null
}
Set-Content $env:AppData\RustDesk\config\RustDesk2.toml $RustDesk2_toml > null
If (!(Test-Path $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml)) {
New-Item $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml > null
}
Set-Content $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml $RustDesk2_toml > null
$random_pass = (-join ((65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_}))
Start-Process "$env:ProgramFiles\RustDesk\RustDesk.exe" -argumentlist "--password $random_pass" -wait
# Get RustDesk ID
If (!("$env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk.toml")) {
$rustdesk_id = (Get-Content $env:AppData\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("id") })
$rustdesk_id = $rustdesk_id.Split("'")[1]
$rustdesk_pw = (Get-Content $env:AppData\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("password") })
$rustdesk_pw = $rustdesk_pw.Split("'")[1]
Write-Output("Config file found in user folder")
OutputIDandPW $rustdesk_id $rustdesk_pw
} Else {
$rustdesk_id = (Get-Content $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("id") })
$rustdesk_id = $rustdesk_id.Split("'")[1]
$rustdesk_pw = (Get-Content $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk.toml | Where-Object { $_.Contains("password") })
$rustdesk_pw = $rustdesk_pw.Split("'")[1]
Write-Output "Config file found in windows service folder"
OutputIDandPW $rustdesk_id $rustdesk_pw
}
Stop-Process -Name RustDesk -Force > null
Start-Service -Name RustDesk > null
# Show the value of the Password Variable
echo "Password: $rustdesk_pw"
echo "..............................................."
echo ""
echo "Press Enter to open RustDesk."
pause
.\rustdesk.exe

View File

@ -1,10 +1,20 @@
#!/bin/bash
uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c8)
# Assign a random value to the password variable
rustdesk_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
# Get your config string from your Web portal and Fill Below
rustdesk_cfg="secure-string"
# identify OS
################################### Please Do Not Edit Below This Line #########################################
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
# Identify OS
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
@ -18,7 +28,6 @@ if [ -f /etc/os-release ]; then
UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)"
fi
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
@ -29,13 +38,13 @@ elif [ -f /etc/lsb-release ]; then
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
# Older Debian, Ubuntu, etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
elif [ -f /etc/SuSE-release ]; then
# Older SuSE etc.
OS=SuSE
VER=$(cat /etc/SuSe-release)
VER=$(cat /etc/SuSE-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
@ -46,14 +55,21 @@ else
VER=$(uname -r)
fi
# Install Rustdesk
echo "Installing Rustdesk"
# Checks the latest version of RustDesk
RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk/releases/latest -s | grep "tag_name" | awk -F'"' '{print $4}')
# Install RustDesk
echo "Installing RustDesk"
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.deb
sudo apt install -fy ./rustdesk-1.1.9.deb
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.rpm
sudo yum localinstall ./rustdesk-1.1.9.rpm
wget https://github.com/rustdesk/rustdesk/releases/download/${RDLATEST}/rustdesk-${RDLATEST}-x86_64.deb
apt-get install -fy ./rustdesk-${RDLATEST}-x86_64.deb >/dev/null
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "$OS" = "Fedora Linux" ] || [ "${UPSTREAM_ID}" = "rhel" ]; then
wget https://github.com/rustdesk/rustdesk/releases/download/${RDLATEST}/rustdesk-${RDLATEST}.x86_64.rpm
yum localinstall ./rustdesk-${RDLATEST}.x86_64.rpm -y >/dev/null
elif [ "${UPSTREAM_ID}" = "suse" ]; then
wget https://github.com/rustdesk/rustdesk/releases/download/${RDLATEST}/rustdesk-${RDLATEST}.x86_64-suse.rpm
zypper -n install --allow-unsigned-rpm ./rustdesk-${RDLATEST}.x86_64-suse.rpm >/dev/null
else
echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway
@ -62,51 +78,26 @@ else
exit 1
fi
rustdesk --password ${admintoken}
sudo pkill -f "rustdesk"
# Run the rustdesk command with --get-id and store the output in the rustdesk_id variable
rustdesk_id=$(rustdesk --get-id)
# Setup Rustdesk in user profile
rustdesktoml2a="$(cat << EOF
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
# Apply new password to RustDesk
rustdesk --password $rustdesk_pw &> /dev/null
[options]
rendezvous-servers = 'rs-ny.rustdesk.com,rs-sg.rustdesk.com,rs-cn.rustdesk.com'
key = 'keyreg'
custom-rendezvous-server = 'wanipreg'
api-server = 'https://wanipreg'
relay-server = 'wanipreg'
EOF
)"
echo "${rustdesktoml2a}" | sudo tee /home/${uname}/.config/rustdesk/RustDesk2.toml > /dev/null
rustdesk --config $rustdesk_cfg
# Setup Rustdesk in root profile
rustdesktoml2b="$(cat << EOF
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
systemctl restart rustdesk
[options]
rendezvous-servers = 'rs-ny.rustdesk.com,rs-sg.rustdesk.com,rs-cn.rustdesk.com'
key = 'keyreg'
custom-rendezvous-server = 'wanipreg'
api-server = 'https://wanipreg'
relay-server = 'wanipreg'
direct-server = 'Y'
EOF
)"
echo "${rustdesktoml2b}" | sudo tee /root/.config/rustdesk/RustDesk2.toml > /dev/null
echo "All done! Please double check the Network settings tab in RustDesk."
echo ""
echo "..............................................."
# Check if the rustdesk_id is not empty
if [ -n "$rustdesk_id" ]; then
echo "RustDesk ID: $rustdesk_id"
else
echo "Failed to get RustDesk ID."
fi
sudo chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml
sudo systemctl restart rustdesk
echo "ID & Password for Rustdesk ${uname} are:"
grep -w id /home/${uname}/.config/rustdesk/RustDesk.toml
grep -w password /home/${uname}/.config/rustdesk/RustDesk.toml
echo "ID & Password for Rustdesk (root) are:"
sudo grep -w id /root/.config/rustdesk/RustDesk.toml
sudo grep -w password /root/.config/rustdesk/RustDesk.toml
# Echo the value of the password variable
echo "Password: $rustdesk_pw"
echo "..............................................."