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 TARGETOS
ARG TARGETARCH 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 RUN apk update && apk add --no-cache supervisor && mkdir -p /opt/rustdesk && mkdir /public && mkdir /data

View File

@ -1,130 +1,104 @@
$ErrorActionPreference= 'silentlycontinue' $ErrorActionPreference= 'silentlycontinue'
#Run as administrator and stays in the current directory
# 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 (-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) { if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`""; Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
Exit; 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' # Checks for the latest version of RustDesk
$request = [System.Net.WebRequest]::Create($rustdesk_url) $url = 'https://www.github.com//rustdesk/rustdesk/releases/latest'
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse() $response = $request.GetResponse()
$realTagUrl = $response.ResponseUri.OriginalString $realTagUrl = $response.ResponseUri.OriginalString
$rustdesk_version = $realTagUrl.split('/')[-1].Trim('v') $RDLATEST = $realTagUrl.split('/')[-1].Trim('v')
Write-Output("Installing Rustdesk version $rustdesk_version") echo "RustDesk $RDLATEST is the latest version."
function OutputIDandPW([String]$rustdesk_id, [String]$rustdesk_pw) { # Checks the version of RustDesk installed.
Write-Output("######################################################") $rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
Write-Output("# #")
Write-Output("# CONNECTION PARAMETERS: #") # Skips to inputting the configuration if the latest version of RustDesk is already installed.
Write-Output("# #") if($rdver -eq "$RDLATEST") {
Write-Output("######################################################") echo "RustDesk $rdver is already installed."
Write-Output("") cd $env:ProgramFiles\RustDesk
Write-Output(" RustDesk-ID: $rustdesk_id") echo "Inputting configuration now."
Write-Output(" RustDesk-Password: $rustdesk_pw") .\rustdesk.exe --config $rustdesk_cfg
Write-Output("") .\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)) { if (!(Test-Path C:\Temp)) {
New-Item -ItemType Directory -Force -Path $env:Temp > null 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) { if ($arrService -eq $null)
$os_arch = "x64" {
} Else { echo "Installing service."
$os_arch = "x32" 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
} }
# Write config while ($arrService.Status -ne 'Running')
$RustDesk2_toml = @" {
rendezvous_server = 'wanipreg' Start-Service $ServiceName
nat_type = 1 Start-Sleep -seconds 5
serial = 0 $arrService.Refresh()
[options]
custom-rendezvous-server = 'wanipreg'
key = 'keyreg'
relay-server = 'wanipreg'
api-server = 'https://wanipreg'
enable-audio = 'N'
direct-server = 'Y'
"@
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 # Waits for installation to complete before proceeding.
Start-Service -Name RustDesk > null echo "Please wait a few seconds."
Start-Sleep -Seconds 10
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

View File

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