Update install.sh

This commit is contained in:
dinger1986
2023-07-22 22:49:02 +01:00
committed by GitHub
parent 8232f56757
commit 402eca59b2

View File

@@ -1,12 +1,5 @@
#!/bin/bash
# Many things here need root access, so verify user is root
# If not, fail out and give an explanation
if [ $(id -u) -ne 0 ]; then
echo "error: must be root (use sudo)"
exit 1
fi
# Get Username
uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16)
@@ -74,14 +67,14 @@ PREREQARCH="bind"
echo "Installing prerequisites"
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
apt-get update
apt-get install -y ${PREREQ} ${PREREQDEB} # git
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" ]
yum update -y
yum install -y ${PREREQ} ${PREREQRPM} # git
sudo yum update -y
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
sudo pacman -Syu
sudo pacman -S ${PREREQ} ${PREREQARCH}
@@ -127,9 +120,9 @@ done
# Make Folder /opt/rustdesk/
if [ ! -d "/opt/rustdesk" ]; then
echo "Creating /opt/rustdesk"
mkdir -p /opt/rustdesk/
sudo mkdir -p /opt/rustdesk/
fi
chown "${uname}" -R /opt/rustdesk
sudo chown "${uname}" -R /opt/rustdesk
cd /opt/rustdesk/ || exit 1
@@ -158,9 +151,9 @@ chmod +x /opt/rustdesk/hbbr
# Make Folder /var/log/rustdesk/
if [ ! -d "/var/log/rustdesk" ]; then
echo "Creating /var/log/rustdesk"
mkdir -p /var/log/rustdesk/
sudo mkdir -p /var/log/rustdesk/
fi
chown "${uname}" -R /var/log/rustdesk/
sudo chown "${uname}" -R /var/log/rustdesk/
# Setup Systemd to launch hbbs
rustdesksignal="$(cat << EOF
@@ -182,10 +175,10 @@ RestartSec=10
WantedBy=multi-user.target
EOF
)"
echo "${rustdesksignal}" | tee /etc/systemd/system/rustdesksignal.service > /dev/null
systemctl daemon-reload
systemctl enable rustdesksignal.service
systemctl start rustdesksignal.service
echo "${rustdesksignal}" | sudo tee /etc/systemd/system/rustdesksignal.service > /dev/null
sudo systemctl daemon-reload
sudo systemctl enable rustdesksignal.service
sudo systemctl start rustdesksignal.service
# Setup Systemd to launch hbbr
rustdeskrelay="$(cat << EOF
@@ -207,13 +200,13 @@ RestartSec=10
WantedBy=multi-user.target
EOF
)"
echo "${rustdeskrelay}" | tee /etc/systemd/system/rustdeskrelay.service > /dev/null
systemctl daemon-reload
systemctl enable rustdeskrelay.service
systemctl start rustdeskrelay.service
echo "${rustdeskrelay}" | sudo tee /etc/systemd/system/rustdeskrelay.service > /dev/null
sudo systemctl daemon-reload
sudo systemctl enable rustdeskrelay.service
sudo systemctl start rustdeskrelay.service
while ! [[ $CHECK_RUSTDESK_READY ]]; do
CHECK_RUSTDESK_READY=$(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"
sleep 3
done
@@ -243,22 +236,22 @@ case $EXTRAOPT in
# Create windows install script
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
sed -i "s|wanipreg|${wanip}|g" WindowsAgentAIOInstall.ps1
sed -i "s|keyreg|${key}|g" WindowsAgentAIOInstall.ps1
sudo sed -i "s|wanipreg|${wanip}|g" WindowsAgentAIOInstall.ps1
sudo sed -i "s|keyreg|${key}|g" WindowsAgentAIOInstall.ps1
# Create linux install script
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
sed -i "s|wanipreg|${wanip}|g" linuxclientinstall.sh
sed -i "s|keyreg|${key}|g" linuxclientinstall.sh
sudo sed -i "s|wanipreg|${wanip}|g" linuxclientinstall.sh
sudo sed -i "s|keyreg|${key}|g" linuxclientinstall.sh
# Download and install gohttpserver
# Make Folder /opt/gohttp/
if [ ! -d "/opt/gohttp" ]; then
echo "Creating /opt/gohttp"
mkdir -p /opt/gohttp/
mkdir -p /opt/gohttp/public
sudo mkdir -p /opt/gohttp/
sudo mkdir -p /opt/gohttp/public
fi
chown "${uname}" -R /opt/gohttp
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) }')
@@ -283,9 +276,9 @@ mv /opt/rustdesk/linuxclientinstall.sh /opt/gohttp/public/
# Make gohttp log folders
if [ ! -d "/var/log/gohttp" ]; then
echo "Creating /var/log/gohttp"
mkdir -p /var/log/gohttp/
sudo mkdir -p /var/log/gohttp/
fi
chown "${uname}" -R /var/log/gohttp/
sudo chown "${uname}" -R /var/log/gohttp/
echo "Tidying up Go HTTP Server Install"
if [ "${ARCH}" = "x86_64" ] ; then
@@ -315,10 +308,10 @@ RestartSec=10
WantedBy=multi-user.target
EOF
)"
echo "${gohttpserver}" | tee /etc/systemd/system/gohttpserver.service > /dev/null
systemctl daemon-reload
systemctl enable gohttpserver.service
systemctl start gohttpserver.service
echo "${gohttpserver}" | sudo tee /etc/systemd/system/gohttpserver.service > /dev/null
sudo systemctl daemon-reload
sudo systemctl enable gohttpserver.service
sudo systemctl start gohttpserver.service
echo -e "Your IP/DNS Address is ${wanip}"