77 lines
2 KiB
Bash
77 lines
2 KiB
Bash
#!/bin/bash
|
|
|
|
# Variables
|
|
RUSTDESK_URL="https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.deb"
|
|
RUSTDESK_DEB="rustdesk-1.2.3-x86_64.deb"
|
|
ID_SERVER="192.168.1.242"
|
|
PACKAGE_NAME="rustdesk"
|
|
|
|
# Check for curl
|
|
if ! command -v curl &> /dev/null; then
|
|
echo "Error: curl is not installed. Please install curl and try again."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if RustDesk is already installed and remove it
|
|
if dpkg -l | grep -qw "$PACKAGE_NAME"; then
|
|
echo "RustDesk is already installed. Removing..."
|
|
if sudo dpkg --purge "$PACKAGE_NAME"; then
|
|
echo "Successfully removed existing RustDesk installation."
|
|
else
|
|
echo "Failed to remove existing RustDesk. Exiting."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "Downloading RustDesk..."
|
|
|
|
# Download the RustDesk .deb package
|
|
if curl -L "$RUSTDESK_URL" -o "$RUSTDESK_DEB"; then
|
|
echo "Download successful."
|
|
else
|
|
echo "Download failed. Please check the URL and try again."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the file was actually downloaded
|
|
if [ ! -f "$RUSTDESK_DEB" ]; then
|
|
echo "Error: The RustDesk .deb file was not downloaded. Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing RustDesk..."
|
|
|
|
# Attempt to install the RustDesk package
|
|
if sudo dpkg -i "$RUSTDESK_DEB"; then
|
|
echo "RustDesk installed successfully."
|
|
else
|
|
echo "Error: dpkg encountered an issue installing RustDesk. Attempting to fix..."
|
|
if ! sudo apt-get install -f; then
|
|
echo "Error: Failed to resolve dependencies. Exiting."
|
|
exit 1
|
|
else
|
|
echo "Dependencies resolved. Please try installing RustDesk again."
|
|
fi
|
|
fi
|
|
|
|
echo "Configuring RustDesk..."
|
|
|
|
# Configure RustDesk
|
|
CONFIG_PATH="$HOME/.config/rustdesk/hbb.conf"
|
|
mkdir -p "$(dirname "$CONFIG_PATH")"
|
|
echo "id_server = \"$ID_SERVER\"" > "$CONFIG_PATH"
|
|
echo "Configuration updated."
|
|
|
|
echo "Starting RustDesk..."
|
|
|
|
# Start RustDesk
|
|
if ! pgrep -x "rustdesk" > /dev/null; then
|
|
rustdesk &> /dev/null &
|
|
echo "RustDesk client started."
|
|
else
|
|
echo "RustDesk is already running."
|
|
fi
|
|
|
|
echo "Cleaning up..."
|
|
rm -f "$RUSTDESK_DEB"
|
|
echo "Installation complete."
|