]> ###2026-08-01 - Initial release &bundleURL; &md5bundle; ratholezip_url_base="https://github.com/rathole-org/rathole/releases/download" ratholezip_name="rathole-x86_64-unknown-linux-gnu.zip" installdir="/boot/config/plugins/rathole/install" # Read the version of any existing local binary if [ -f "${installdir}/rathole" ]; then cp "${installdir}/rathole" /usr/sbin/ratholeorig.new mv /usr/sbin/ratholeorig.new /usr/sbin/ratholeorig chown root:root /usr/sbin/ratholeorig chmod 755 /usr/sbin/ratholeorig version=$(ratholeorig --version 2>&1 | grep -Po "[\d]+\.[\d]+\.[\d]+" | head -1) fi for f in /boot/config/plugins/rathole/install/rathole-*.txz; do [[ "${f}" != *"&bundleversion;"* ]] && rm -f "${f}" done curl -fsS --connect-timeout 10 https://api.github.com/ >/dev/null 2>&1 if [ $? -eq 0 ]; then latest_tag=$(curl -fs --connect-timeout 15 https://api.github.com/repos/rathole-org/rathole/releases/latest | grep -Po '"tag_name":\s*"\K[^"]+') if [ -z "${latest_tag}" ]; then echo "Warning: Could not determine latest rathole version from GitHub API" fi latest_version=$(echo "${latest_tag}" | grep -Po "[\d]+\.[\d]+\.[\d]+") if [ -n "${version}" ] && [ -n "${latest_version}" ] && [ "${version}" = "${latest_version}" ]; then echo "Local rathole binary is up-to-date (${version})" else echo "Downloading rathole ${latest_tag}..." mkdir -p "${installdir}" curl -fL --connect-timeout 15 --retry 3 --retry-delay 2 --retry-max-time 60 \ -o "${installdir}/${ratholezip_name}" \ "${ratholezip_url_base}/${latest_tag}/${ratholezip_name}" if [ $? -ne 0 ]; then echo "Download failed" else unzip -o "${installdir}/${ratholezip_name}" rathole -d "${installdir}/" rm -f "${installdir}/${ratholezip_name}" cp "${installdir}/rathole" /usr/sbin/ratholeorig.new mv /usr/sbin/ratholeorig.new /usr/sbin/ratholeorig chown root:root /usr/sbin/ratholeorig chmod 755 /usr/sbin/ratholeorig fi fi else echo "Connection error - Could not reach GitHub API - Will try fallback to existing binary" if [ ! -f /usr/sbin/ratholeorig ]; then echo "Install failed - No binary found" removepkg rathole-&bundleversion;-bundle >/dev/null rm -f /var/lib/pkgtools/packages/rathole-*-bundle rm -rf /usr/local/emhttp/plugins/rathole exit 1 fi fi if [ ! -f /usr/sbin/ratholeorig ]; then echo "Install failed - No binary found" removepkg rathole-&bundleversion;-bundle >/dev/null rm -f /var/lib/pkgtools/packages/rathole-*-bundle rm -rf /usr/local/emhttp/plugins/rathole exit 1 fi if [ ! -f /boot/config/plugins/rathole/rathole.toml ]; then mkdir -p /boot/config/plugins/rathole cat > /boot/config/plugins/rathole/rathole.toml << 'EOF' [client] remote_addr = "myserver.example.com:2333" [client.services.my_service] type = "tcp" local_addr = "127.0.0.1:8080" EOF fi chown root:root /etc/rc.d/rc.rathole chmod 755 /etc/rc.d/rc.rathole chmod 755 /usr/local/emhttp/plugins/rathole/scripts/rc.rathole /etc/rc.d/rc.rathole restart echo "" echo "-----------------------------------------------------------" echo " rathole has been installed." echo "-----------------------------------------------------------" echo "" rathole.toml /etc/rc.d/rc.rathole stop rm -rf /boot/config/plugins/rathole/install rm -f /boot/config/plugins/rathole/.gitignore rmdir /boot/config/plugins/rathole 2>/dev/null rm -f /usr/sbin/ratholeorig rm -f /etc/rc.d/rc.rathole rm -f /var/log/rathole.log removepkg rathole-&bundleversion;-bundle >/dev/null rm -f /var/lib/pkgtools/packages/rathole-*-bundle rm -rf /usr/local/emhttp/plugins/rathole echo "" echo "-----------------------------------------------------------" echo " rathole has been uninstalled." echo "-----------------------------------------------------------" echo ""