Merge pull request #7 from dinger1986/dev

Dev
This commit is contained in:
dinger1986 2022-08-12 15:49:22 +01:00 committed by GitHub
commit 2457f046e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 239 additions and 47 deletions

View File

@ -4,6 +4,81 @@
uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16)
# identify OS
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
UPSTREAM_ID=${ID_LIKE,,}
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; 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)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
OS=SuSE
VER=$(cat /etc/SuSe-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
VER=$(cat /etc/redhat-release)
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# output ebugging info if $DEBUG set
if [ "$DEBUG" = "true" ]; then
echo "OS: $OS"
echo "VER: $VER"
echo "UPSTREAM_ID: $UPSTREAM_ID"
exit 0
fi
# Setup prereqs for server
# common named prereqs
PREREQ="curl wget unzip tar"
PREREQDEB="dnsutils"
PREREQRPM="bind-utils"
echo "Installing prerequisites"
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
sudo apt-get update
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
# opensuse 15.4 fails to run the relay service and hangs waiting for it
# needs more work before it can be enabled
# || [ "${UPSTREAM_ID}" = "suse" ]
sudo yum update -y
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
else
echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway
# if they say yes, then do the install
# if they say no, exit the script
exit 1
fi
# Choice for DNS or IP
PS3='Choose your preferred option, IP or DNS/Domain:'
WAN=("IP" "DNS/Domain")
@ -17,25 +92,42 @@ break
"DNS/Domain")
echo -ne "Enter your preferred domain/dns address ${NC}: "
read wanip
#check wanip is valid domain
if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then
echo -e "${RED}Invalid domain/dns address${NC}"
exit 1
fi
break
;;
*) echo "invalid option $REPLY";;
esac
done
# Setup prereqs for server
if [[ $(which yum) ]]; then
sudo yum install unzip -y
sudo yum install bind-utils -y
sudo yum install tar -y
elif [[ $(which apt) ]]; then
sudo apt-get update
sudo apt-get install unzip -y
sudo apt-get install dnsutils -y
sudo apt-get install tar -y
else
echo "Unknown Platform, the install might fail"
fi
# #/*
# Alternatively since case is faster than if then else
# case ${IDLIKE} in
# ubuntu|debian)
# # Debian/Ubuntu/etc.
# sudo apt-get update
# sudo apt-get install -y curl wget unzip dnsutils tar # git
# ;;
# centos|fedora|redhat) #|amazon)
# # CentOS/RedHat/Fedora/Amazon/etc.
# sudo yum update -y
# sudo yum install -y curl wget unzip bind-utils tar # git
# ;;
# *)
# echo "Unsupported OS"
# echo "Unknown Platform, the install might fail"
# # here you could ask the user for permission to try and install anyway
# # if they say yes, then do the install
# # if they say no, exit the script
# exit 1
# ;;
# esac
# */
# Make Folder /opt/rustdesk/
if [ ! -d "/opt/rustdesk" ]; then
@ -43,11 +135,11 @@ if [ ! -d "/opt/rustdesk" ]; then
sudo mkdir -p /opt/rustdesk/
fi
sudo chown "${uname}" -R /opt/rustdesk
cd /opt/rustdesk/
cd /opt/rustdesk/ || exit 1
#Download latest version of Rustdesk
RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
sudo wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip"
wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip"
unzip rustdesk-server-linux-x64.zip
# Make Folder /var/log/rustdesk/
@ -113,17 +205,17 @@ while ! [[ $CHECK_RUSTDESK_READY ]]; do
sleep 3
done
pubname=$(find /opt/rustdesk -name *.pub)
pubname=$(find /opt/rustdesk -name "*.pub")
key=$(cat "${pubname}")
sudo rm rustdesk-server-linux-x64.zip
rm rustdesk-server-linux-x64.zip
# Create windows install script
# Create windows install script
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
sudo sed -i "s|wanipreg|${wanip}|g" WindowsAgentAIOInstall.ps1
sudo sed -i "s|keyreg|${key}|g" WindowsAgentAIOInstall.ps1
# Create linux install script
# Create linux install script
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
sudo sed -i "s|wanipreg|${wanip}|g" linuxclientinstall.sh
sudo sed -i "s|keyreg|${key}|g" linuxclientinstall.sh
@ -138,7 +230,7 @@ fi
sudo chown "${uname}" -R /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) }')
sudo wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz"
wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz"
tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz
# Copy Rustdesk install scripts to folder
@ -152,7 +244,7 @@ if [ ! -d "/var/log/gohttp" ]; then
fi
sudo chown "${uname}" -R /var/log/gohttp/
sudo rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz
rm gohttpserver_"${GOHTTPLATEST}"_linux_amd64.tar.gz
# Setup Systemd to launch Go HTTP Server
gohttpserver="$(cat << EOF

View File

@ -3,18 +3,62 @@
uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c8)
# Install Rustdesk
if [[ $(which yum) ]]; 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
elif [[ $(which apt) ]]; 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
# identify OS
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
IDLIKE=$ID_LIKE
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
OS=SuSE
VER=$(cat /etc/SuSe-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
VER=$(cat /etc/redhat-release)
else
echo "Unknown Platform, the install will fail"
exit
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# Install Rustdesk
case ${OS,,} in
# or case ${IDLIKE,,} in .. to support derivatives
ubuntu|debian)
# Debian/Ubuntu/etc.
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
;;
fedora|centos|redhat|amazon)
# Red Hat, CentOS, etc.
wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.rpm
sudo yum localinstall ./rustdesk-1.1.9.rpm
# sudo dnf install -y ./rustdesk-1.1.9.rpm
;;
*)
echo "Unsupported OS"
exit 1
;;
esac
rustdesk --password ${admintoken}
pkill -f "rustdesk"
@ -50,12 +94,12 @@ EOF
)"
echo "${rustdesktoml2b}" | sudo tee /root/.config/rustdesk/RustDesk2.toml > /dev/null
chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml
chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml
systemctl restart rustdesk
echo "ID & Password for Rustdesk $(uname} are:"
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

View File

@ -1,23 +1,80 @@
#!/bin/bash
# Get Username
uname=$(whoami)
uname=$(whoami) # not used btw .. yet
sudo systemctl stop gohttpserver.service
sudo systemctl stop rustdesksignal.service
sudo systemctl stop rustdeskrelay.service
# Setup prereqs for server
if [[ $(which yum) ]]; then
sudo yum install unzip -y
sudo yum install bind-utils -y
elif [[ $(which apt) ]]; then
sudo apt-get update
sudo apt-get install unzip -y
sudo apt-get install dnsutils -y
# identify OS
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
UPSTREAM_ID=${ID_LIKE,,}
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; 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)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
OS=SuSE
VER=$(cat /etc/SuSe-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
VER=$(cat /etc/redhat-release)
else
echo "Unknown Platform, the install might fail"
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# output ebugging info if $DEBUG set
if [ "$DEBUG" = "true" ]; then
echo "OS: $OS"
echo "VER: $VER"
echo "UPSTREAM_ID: $UPSTREAM_ID"
exit 0
fi
# Setup prereqs for server
# common named prereqs
PREREQ="curl wget unzip tar"
echo "Installing prerequisites"
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
PREREQ+=" dnsutils"
sudo apt-get update
sudo apt-get install -y "${PREREQ}" # git
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ]; then
PREREQ+=" bind-utils"
sudo yum update -y
sudo yum install -y "${PREREQ}" # git
else
echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway
# if they say yes, then do the install
# if they say no, exit the script
exit 1
fi
cd /opt/rustdesk/
@ -26,7 +83,7 @@ cd /opt/rustdesk/
rm hbbs
rm hbbs
RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
sudo wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip"
wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip"
unzip rustdesk-server-linux-x64.zip
sudo systemctl start rustdesksignal.service
@ -38,16 +95,15 @@ while ! [[ $CHECK_RUSTDESK_READY ]]; do
sleep 3
done
sudo rm rustdesk-server-linux-x64.zip
rm rustdesk-server-linux-x64.zip
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) }')
sudo wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz"
wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz"
tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz
sudo rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz
rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz
sudo systemctl start gohttpserver.service
echo -e "Updates are complete"