mirror of
https://github.com/techahold/rustdeskinstall.git
synced 2025-12-19 15:11:30 +01:00
Merge pull request #99 from justokaou/fix-install-no-sudo
feat: add --no-sudo option with automatic fallback
This commit is contained in:
85
install.sh
85
install.sh
@@ -16,6 +16,8 @@ while getopts i:-: option; do
|
|||||||
http="true";;
|
http="true";;
|
||||||
skip-http)
|
skip-http)
|
||||||
http="false";;
|
http="false";;
|
||||||
|
no-sudo)
|
||||||
|
usesudo="false";;
|
||||||
esac;;
|
esac;;
|
||||||
i) resolveip="true";;
|
i) resolveip="true";;
|
||||||
esac
|
esac
|
||||||
@@ -29,10 +31,31 @@ function displayhelp() {
|
|||||||
echo '--resolvedns "fqdn" Use FQDN for server name. Cannot use in combination with --resolveip or -i'
|
echo '--resolvedns "fqdn" Use FQDN for server name. Cannot use in combination with --resolveip or -i'
|
||||||
echo "--install-http Install http server to host installation scripts. Cannot use in combination with --skip-http or -n"
|
echo "--install-http Install http server to host installation scripts. Cannot use in combination with --skip-http or -n"
|
||||||
echo "--skip-http Skip installation of http server. Cannot use in combination with --install-http or -h"
|
echo "--skip-http Skip installation of http server. Cannot use in combination with --install-http or -h"
|
||||||
|
echo "--no-sudo Do not use sudo for commands. If sudo is not installed, it will be ignored automatically."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
displayhelp
|
displayhelp
|
||||||
|
|
||||||
|
# Default: use sudo unless --no-sudo is specified
|
||||||
|
usesudo="${usesudo:-true}"
|
||||||
|
|
||||||
|
# Check if sudo is available and wanted
|
||||||
|
if [[ "$usesudo" == "true" ]]; then
|
||||||
|
if command -v sudo &>/dev/null; then
|
||||||
|
SUDO="sudo"
|
||||||
|
echo "sudo detected and will be used."
|
||||||
|
else
|
||||||
|
echo "sudo not found. Switching to no-sudo mode."
|
||||||
|
SUDO=""
|
||||||
|
echo "Some installation steps may fail if run without root privileges."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
SUDO=""
|
||||||
|
echo "Running in no-sudo mode."
|
||||||
|
echo "Some installation steps may fail if run without root privileges."
|
||||||
|
fi
|
||||||
|
|
||||||
# Get Username
|
# Get Username
|
||||||
uname=$(whoami)
|
uname=$(whoami)
|
||||||
gname=$(id -gn ${uname})
|
gname=$(id -gn ${uname})
|
||||||
@@ -100,17 +123,17 @@ PREREQARCH="bind"
|
|||||||
|
|
||||||
echo "Installing prerequisites"
|
echo "Installing prerequisites"
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
sudo apt-get update
|
$SUDO apt-get update
|
||||||
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
|
$SUDO apt-get install -y ${PREREQ} ${PREREQDEB} # git
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
|
||||||
# opensuse 15.4 fails to run the relay service and hangs waiting for it
|
# opensuse 15.4 fails to run the relay service and hangs waiting for it
|
||||||
# needs more work before it can be enabled
|
# needs more work before it can be enabled
|
||||||
# || [ "${UPSTREAM_ID}" = "suse" ]
|
# || [ "${UPSTREAM_ID}" = "suse" ]
|
||||||
sudo yum update -y
|
$SUDO yum update -y
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
$SUDO yum install -y ${PREREQ} ${PREREQRPM} # git
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
sudo pacman -Syu
|
$SUDO pacman -Syu
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
$SUDO pacman -S ${PREREQ} ${PREREQARCH}
|
||||||
else
|
else
|
||||||
echo "Unsupported OS"
|
echo "Unsupported OS"
|
||||||
# give them the option to continue
|
# give them the option to continue
|
||||||
@@ -166,9 +189,9 @@ fi
|
|||||||
# Make Folder /opt/rustdesk/
|
# Make Folder /opt/rustdesk/
|
||||||
if [ ! -d "/opt/rustdesk" ]; then
|
if [ ! -d "/opt/rustdesk" ]; then
|
||||||
echo "Creating /opt/rustdesk"
|
echo "Creating /opt/rustdesk"
|
||||||
sudo mkdir -p /opt/rustdesk/
|
$SUDO mkdir -p /opt/rustdesk/
|
||||||
fi
|
fi
|
||||||
sudo chown "${uname}" -R /opt/rustdesk
|
$SUDO chown "${uname}" -R /opt/rustdesk
|
||||||
cd /opt/rustdesk/ || exit 1
|
cd /opt/rustdesk/ || exit 1
|
||||||
|
|
||||||
|
|
||||||
@@ -197,9 +220,9 @@ chmod +x /opt/rustdesk/hbbr
|
|||||||
# Make Folder /var/log/rustdesk/
|
# Make Folder /var/log/rustdesk/
|
||||||
if [ ! -d "/var/log/rustdesk" ]; then
|
if [ ! -d "/var/log/rustdesk" ]; then
|
||||||
echo "Creating /var/log/rustdesk"
|
echo "Creating /var/log/rustdesk"
|
||||||
sudo mkdir -p /var/log/rustdesk/
|
$SUDO mkdir -p /var/log/rustdesk/
|
||||||
fi
|
fi
|
||||||
sudo chown "${uname}" -R /var/log/rustdesk/
|
$SUDO chown "${uname}" -R /var/log/rustdesk/
|
||||||
|
|
||||||
# Setup Systemd to launch hbbs
|
# Setup Systemd to launch hbbs
|
||||||
rustdesksignal="$(cat << EOF
|
rustdesksignal="$(cat << EOF
|
||||||
@@ -221,10 +244,10 @@ RestartSec=10
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
echo "${rustdesksignal}" | sudo tee /etc/systemd/system/rustdesksignal.service > /dev/null
|
echo "${rustdesksignal}" | $SUDO tee /etc/systemd/system/rustdesksignal.service > /dev/null
|
||||||
sudo systemctl daemon-reload
|
$SUDO systemctl daemon-reload
|
||||||
sudo systemctl enable rustdesksignal.service
|
$SUDO systemctl enable rustdesksignal.service
|
||||||
sudo systemctl start rustdesksignal.service
|
$SUDO systemctl start rustdesksignal.service
|
||||||
|
|
||||||
# Setup Systemd to launch hbbr
|
# Setup Systemd to launch hbbr
|
||||||
rustdeskrelay="$(cat << EOF
|
rustdeskrelay="$(cat << EOF
|
||||||
@@ -246,13 +269,13 @@ RestartSec=10
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
echo "${rustdeskrelay}" | sudo tee /etc/systemd/system/rustdeskrelay.service > /dev/null
|
echo "${rustdeskrelay}" | $SUDO tee /etc/systemd/system/rustdeskrelay.service > /dev/null
|
||||||
sudo systemctl daemon-reload
|
$SUDO systemctl daemon-reload
|
||||||
sudo systemctl enable rustdeskrelay.service
|
$SUDO systemctl enable rustdeskrelay.service
|
||||||
sudo systemctl start rustdeskrelay.service
|
$SUDO systemctl start rustdeskrelay.service
|
||||||
|
|
||||||
while ! [[ $CHECK_RUSTDESK_READY ]]; do
|
while ! [[ $CHECK_RUSTDESK_READY ]]; do
|
||||||
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdeskrelay.service | grep "Active: active (running)")
|
CHECK_RUSTDESK_READY=$($SUDO systemctl status rustdeskrelay.service | grep "Active: active (running)")
|
||||||
echo -ne "Rustdesk Relay not ready yet...${NC}\n"
|
echo -ne "Rustdesk Relay not ready yet...${NC}\n"
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
@@ -282,20 +305,20 @@ echo "$string64rev"
|
|||||||
function setuphttp () {
|
function setuphttp () {
|
||||||
# Create windows install script
|
# Create windows install script
|
||||||
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
|
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
|
||||||
sudo sed -i "s|secure-string|${string64rev}|g" WindowsAgentAIOInstall.ps1
|
$SUDO sed -i "s|secure-string|${string64rev}|g" WindowsAgentAIOInstall.ps1
|
||||||
|
|
||||||
# Create linux install script
|
# Create linux install script
|
||||||
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
|
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
|
||||||
sudo sed -i "s|secure-string|${string64rev}|g" linuxclientinstall.sh
|
$SUDO sed -i "s|secure-string|${string64rev}|g" linuxclientinstall.sh
|
||||||
|
|
||||||
# Download and install gohttpserver
|
# Download and install gohttpserver
|
||||||
# Make Folder /opt/gohttp/
|
# Make Folder /opt/gohttp/
|
||||||
if [ ! -d "/opt/gohttp" ]; then
|
if [ ! -d "/opt/gohttp" ]; then
|
||||||
echo "Creating /opt/gohttp"
|
echo "Creating /opt/gohttp"
|
||||||
sudo mkdir -p /opt/gohttp/
|
$SUDO mkdir -p /opt/gohttp/
|
||||||
sudo mkdir -p /opt/gohttp/public
|
$SUDO mkdir -p /opt/gohttp/public
|
||||||
fi
|
fi
|
||||||
sudo chown "${uname}" -R /opt/gohttp
|
$SUDO chown "${uname}" -R /opt/gohttp
|
||||||
cd /opt/gohttp
|
cd /opt/gohttp
|
||||||
GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
|
GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
|
||||||
|
|
||||||
@@ -320,9 +343,9 @@ function setuphttp () {
|
|||||||
# Make gohttp log folders
|
# Make gohttp log folders
|
||||||
if [ ! -d "/var/log/gohttp" ]; then
|
if [ ! -d "/var/log/gohttp" ]; then
|
||||||
echo "Creating /var/log/gohttp"
|
echo "Creating /var/log/gohttp"
|
||||||
sudo mkdir -p /var/log/gohttp/
|
$SUDO mkdir -p /var/log/gohttp/
|
||||||
fi
|
fi
|
||||||
sudo chown "${uname}" -R /var/log/gohttp/
|
$SUDO chown "${uname}" -R /var/log/gohttp/
|
||||||
|
|
||||||
echo "Tidying up Go HTTP Server Install"
|
echo "Tidying up Go HTTP Server Install"
|
||||||
if [ "${ARCH}" = "x86_64" ] ; then
|
if [ "${ARCH}" = "x86_64" ] ; then
|
||||||
@@ -352,10 +375,10 @@ RestartSec=10
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
echo "${gohttpserver}" | sudo tee /etc/systemd/system/gohttpserver.service > /dev/null
|
echo "${gohttpserver}" | $SUDO tee /etc/systemd/system/gohttpserver.service > /dev/null
|
||||||
sudo systemctl daemon-reload
|
$SUDO systemctl daemon-reload
|
||||||
sudo systemctl enable gohttpserver.service
|
$SUDO systemctl enable gohttpserver.service
|
||||||
sudo systemctl start gohttpserver.service
|
$SUDO systemctl start gohttpserver.service
|
||||||
|
|
||||||
|
|
||||||
echo -e "Your IP/DNS Address is ${wanip}"
|
echo -e "Your IP/DNS Address is ${wanip}"
|
||||||
@@ -392,7 +415,7 @@ if [[ -z "$http" ]]; then
|
|||||||
echo -e "Your public key is ${key}"
|
echo -e "Your public key is ${key}"
|
||||||
echo -e "Install Rustdesk on your machines and change your public key and IP/DNS name to the above"
|
echo -e "Install Rustdesk on your machines and change your public key and IP/DNS name to the above"
|
||||||
|
|
||||||
echo - e "You can get a free API with Addressbook etc via https://github.com/infiniteremote/installer"
|
echo -e "You can get a free API with Addressbook etc via https://github.com/infiniteremote/installer"
|
||||||
|
|
||||||
echo "Press any key to finish install"
|
echo "Press any key to finish install"
|
||||||
while [ true ] ; do
|
while [ true ] ; do
|
||||||
|
|||||||
Reference in New Issue
Block a user