From a9e39a4a2daed7b0b402e1097d4ce8eaf573e753 Mon Sep 17 00:00:00 2001 From: Alessandro OSIAS Date: Fri, 6 Oct 2023 12:25:40 +0200 Subject: [PATCH] Updating readme and update installation script generation --- .github/scripts/run_rport_server.sh | 2 +- README.md | 4 +- cmd/rport-pairing.go | 10 +- cors/corsHandler_test.go | 2 +- deposit/depositHandler_test.go | 4 +- go.mod | 2 +- internal/config/config.go | 2 +- internal/config/config_test.go | 2 +- retrieve/installerHandler.go | 2 +- retrieve/installerHandler_test.go | 6 +- retrieve/templates/header.txt | 5 +- retrieve/templates/linux/functions.sh | 191 +++++++++++++++++++++++++- retrieve/templates/linux/install.sh | 150 ++++++++++++++------ retrieve/templates/linux/uninstall.sh | 6 +- retrieve/templates/linux/update.sh | 4 +- retrieve/updateHandler.go | 2 +- retrieve/updateHandler_test.go | 2 +- 17 files changed, 329 insertions(+), 67 deletions(-) diff --git a/.github/scripts/run_rport_server.sh b/.github/scripts/run_rport_server.sh index 55055aa..519c559 100644 --- a/.github/scripts/run_rport_server.sh +++ b/.github/scripts/run_rport_server.sh @@ -6,7 +6,7 @@ trap 'echo "exit $? due to $previous_command"' EXIT # Run a local instance of the RPort server to test if the pairing scripts successfully connects to this server. # cd /tmp -curl -Ls "https://download.rport.io/rportd/stable/?arch=Linux_x86_64" -o rportd.tar.gz +curl -Ls "https://download.openrport.io/rportd/stable/?arch=Linux_x86_64" -o rportd.tar.gz tar xvzf rportd.tar.gz rportd mkdir /tmp/rport-data cat<rportd.conf diff --git a/README.md b/README.md index 454064b..d0cc2d6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A service to install and connect rport clients easily. -> 📣 This repository holds the sources used to run the public pairing service on https://pairing.rport.io. +> 📣 This repository holds the sources used to run the public pairing service on https://pairing.openrport.io. ## 👫 Use the pairing service Below you will get detailed information how the pairing works. The explained requests are executed by the RPort user interface when you click on the "Install Client" button. @@ -80,7 +80,7 @@ sudo sh rport-update.sh ``` ## 🚚 Install and run a pairing service -Because the service does not store any data, there is nothing to stop you using the public and free service on https://pairing.rport.io. +Because the service does not store any data, there is nothing to stop you using the public and free service on https://pairing.openrport.io. This public service is also the predefined default on all RPort server installations. To run the service on your server proceed as follows. diff --git a/cmd/rport-pairing.go b/cmd/rport-pairing.go index 7c80250..0718731 100644 --- a/cmd/rport-pairing.go +++ b/cmd/rport-pairing.go @@ -3,12 +3,12 @@ package main import ( "flag" "fmt" - "github.com/cloudradar-monitoring/rport-pairing/cors" - "github.com/cloudradar-monitoring/rport-pairing/deposit" - "github.com/cloudradar-monitoring/rport-pairing/internal/cache" - "github.com/cloudradar-monitoring/rport-pairing/internal/config" - "github.com/cloudradar-monitoring/rport-pairing/retrieve" "github.com/gorilla/mux" + "github.com/openrport/rport-pairing/cors" + "github.com/openrport/rport-pairing/deposit" + "github.com/openrport/rport-pairing/internal/cache" + "github.com/openrport/rport-pairing/internal/config" + "github.com/openrport/rport-pairing/retrieve" "log" "net/http" "os" diff --git a/cors/corsHandler_test.go b/cors/corsHandler_test.go index 9a9fb93..48cb229 100644 --- a/cors/corsHandler_test.go +++ b/cors/corsHandler_test.go @@ -1,7 +1,7 @@ package cors_test import ( - "github.com/cloudradar-monitoring/rport-pairing/cors" + "github.com/openrport/rport-pairing/cors" "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" diff --git a/deposit/depositHandler_test.go b/deposit/depositHandler_test.go index cd24fcb..4dcd982 100644 --- a/deposit/depositHandler_test.go +++ b/deposit/depositHandler_test.go @@ -3,8 +3,8 @@ package deposit_test import ( "bytes" "encoding/json" - "github.com/cloudradar-monitoring/rport-pairing/deposit" - "github.com/cloudradar-monitoring/rport-pairing/internal/cache" + "github.com/openrport/rport-pairing/deposit" + "github.com/openrport/rport-pairing/internal/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "io" diff --git a/go.mod b/go.mod index 32a00f1..4758991 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/cloudradar-monitoring/rport-pairing +module github.com/openrport/rport-pairing go 1.18 diff --git a/internal/config/config.go b/internal/config/config.go index 529a480..81e78b9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -2,7 +2,7 @@ package config import ( "fmt" - "github.com/cloudradar-monitoring/rport-pairing/deposit" + "github.com/openrport/rport-pairing/deposit" "github.com/spf13/viper" "log" ) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 089ebaf..1178a8a 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -1,7 +1,7 @@ package config_test import ( - "github.com/cloudradar-monitoring/rport-pairing/internal/config" + "github.com/openrport/rport-pairing/internal/config" "github.com/stretchr/testify/assert" "testing" ) diff --git a/retrieve/installerHandler.go b/retrieve/installerHandler.go index a08c370..9eb4ea4 100644 --- a/retrieve/installerHandler.go +++ b/retrieve/installerHandler.go @@ -2,8 +2,8 @@ package retrieve import ( "fmt" - "github.com/cloudradar-monitoring/rport-pairing/deposit" "github.com/gorilla/mux" + "github.com/openrport/rport-pairing/deposit" "github.com/patrickmn/go-cache" "net/http" ) diff --git a/retrieve/installerHandler_test.go b/retrieve/installerHandler_test.go index ef1919e..55846e7 100644 --- a/retrieve/installerHandler_test.go +++ b/retrieve/installerHandler_test.go @@ -2,10 +2,10 @@ package retrieve_test import ( "fmt" - "github.com/cloudradar-monitoring/rport-pairing/deposit" - "github.com/cloudradar-monitoring/rport-pairing/internal/cache" - "github.com/cloudradar-monitoring/rport-pairing/retrieve" "github.com/gorilla/mux" + "github.com/openrport/rport-pairing/deposit" + "github.com/openrport/rport-pairing/internal/cache" + "github.com/openrport/rport-pairing/retrieve" "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" diff --git a/retrieve/templates/header.txt b/retrieve/templates/header.txt index 34cee5a..c9f44be 100644 --- a/retrieve/templates/header.txt +++ b/retrieve/templates/header.txt @@ -4,9 +4,10 @@ ## The scripts creates a initial configuration and connects the client to your server. ## ## For any inquiries use our GitHub forum on -## https://github.com/cloudradar-monitoring/rport-pairing/discussions/ +## https://github.com/openrport/rport-pairing/discussions/ ## ## Copyright cloudradar GmbH, Potsdam Germany, 2022 +## Maintainer openrport, Lille, France, 2023 ## Released under the MIT open-source license. -## https://github.com/cloudradar-monitoring/rport-pairing/blob/main/LICENSE +## https://github.com/openrport/rport-pairing/blob/main/LICENSE ## \ No newline at end of file diff --git a/retrieve/templates/linux/functions.sh b/retrieve/templates/linux/functions.sh index 1366c6e..1f15efb 100644 --- a/retrieve/templates/linux/functions.sh +++ b/retrieve/templates/linux/functions.sh @@ -34,7 +34,8 @@ uninstall() { /usr/local/bin/tacoscript /etc/init.d/rport /var/run/rport.pid - /etc/runlevels/default/rport" + /etc/runlevels/default/rport + /etc/apt/sources.list.d/rport.list" for FILE in $FILES; do if [ -e "$FILE" ]; then rm -f "$FILE" && echo " [ DELETED ] File $FILE" @@ -60,6 +61,9 @@ uninstall() { rm -rf "$FOLDER" && echo " [ DELETED ] Folder $FOLDER" fi done + if dpkg -l 2>&1 | grep -q "rport.*Remote access"; then + apt-get -y remove --purge rport + fi echo "RPort client successfully uninstalled." } @@ -418,6 +422,11 @@ start_rport() { elif is_available service; then service rport start fi + if pidof rport >/dev/null 2>&1; then + return 0 + else + return 1 + fi } stop_rport() { @@ -430,3 +439,183 @@ stop_rport() { service rport stop fi } + +backup_config() { + if [ -z "$CONFIG_FILE" ]; then + throw_fatal "backup_config() \$CONFIG_FILE undefined." + fi + CONFIG_BACKUP="/tmp/.rport-conf.$(date +%s)" + cp "$CONFIG_FILE" "$CONFIG_BACKUP" + throw_debug "Configuration file copied to $CONFIG_BACKUP" +} + +clean_up_legacy_installation() { + # If this is a migration from the old none deb-based installation, clean up + if [ -e /etc/systemd/system/rport.service ]; then + throw_info "Removing old systemd service /etc/systemd/system/rport.service" + rm -f /etc/systemd/system/rport.service + systemctl daemon-reload + fi + if [ -e /usr/local/bin/rport ]; then + throw_info "Removing old version /usr/local/bin/rport" + rm -f /usr/local/bin/rport + fi +} + +install_via_deb_repo() { + if [ -z "$RELEASE" ]; then + throw_fatal "install_via_deb_repo() \$RELEASE undefined" + fi + validate_custom_user + if [ -e /etc/apt/trusted.gpg.d/rport.gpg ] && dpkg -l | grep -q rport; then + throw_info "System is already using the rport deb repo." + else + throw_info "RPort will use Debian package ..." + # shellcheck source=/dev/null + . /etc/os-release + if [ -n "$UBUNTU_CODENAME" ]; then + CODENAME=$UBUNTU_CODENAME + else + CODENAME=$VERSION_CODENAME + fi + curl -sf http://repo.openrport.io/dearmor.gpg >/etc/apt/trusted.gpg.d/rport.gpg + echo "deb [signed-by=/etc/apt/trusted.gpg.d/rport.gpg] http://repo.openrport.io/deb ${CODENAME} ${RELEASE}" >/etc/apt/sources.list.d/rport.list + fi + apt-get update + if dpkg -s rport >/dev/null 2>&1 && ! [ -e /etc/rport/rport.conf ]; then + throw_warning "Broken DEB package installation found." + throw_debug "Will remove old package first." + apt-get -y --purge remove rport + fi + DEBIAN_FRONTEND=noninteractive apt-get --yes -o Dpkg::Options::="--force-confold" install rport + TARGET_VERSION=$(rport --version | cut -d" " -f2) + clean_up_legacy_installation +} + +install_via_rpm_repo() { + if [ -z "$RELEASE" ]; then + throw_fatal "install_via_rpm_repo() \$RELEASE undefined" + fi + validate_custom_user + if [ -e /etc/yum.repos.d/rport.repo ] && rpm -qa | grep -q rport; then + throw_info "System is already using the rport yum repo." + else + throw_info "RPort will use RPM package ..." + rpm --import https://repo.rport.io/key.gpg + cat </etc/yum.repos.d/rport.repo +[rport-stable] +name=RPort $RELEASE +baseurl=http://repo.openrport.io/rpm/$RELEASE/ +enabled=1 +gpgcheck=1 +gpgkey=https://repo.openrport.io/key.gpg +EOF + fi + dnf -y install rport --refresh + TARGET_VERSION=$(rport --version | cut -d" " -f2) + clean_up_legacy_installation +} + +validate_custom_user() { + if [ "$USER" != "rport" ]; then + throw_fatal "RPM/DEB packages cannot be used with a custom user. Try '-p'" + fi +} + +# Check if it's a supported debian system +is_debian() { + if [ "$NO_REPO" -eq 1 ]; then + return 1 + fi + if which apt-get >/dev/null 2>&1 && test -e /etc/apt/sources.list.d/; then + true + else + return 1 + fi + DIST_SUPPORTED="jammy focal bionic bullseye buster bookworm" + for DIST in $DIST_SUPPORTED; do + if grep -qi "CODENAME.*$DIST" /etc/os-release; then + return 0 + fi + done + return 1 +} + +is_rhel() { + if [ "$NO_REPO" -eq 1 ]; then + return 1 + fi + if grep -q "VERSION=.[6-7]" /etc/os-release; then + throw_info "RHEL/CentOS too old for RPM installation. Switching to tar.gz package." + return 1 + fi + + if which rpm >/dev/null 2>&1 && test -e /etc/yum.repos.d; then + return 0 + fi + return 1 +} + +validate_pkg_url() { + if echo "${PKG_URL}" | grep -q -E "https*:\/\/.*_linux_$(uname -m)\.(tar\.gz|deb|rpm)$"; then + true + else + throw_fatal "Invalid PKG_URL '$PKG_URL'." + fi +} + +download_pkg_url() { + DL_AUTH="" + if [ -n "$RPORT_INSTALLER_DL_USERNAME" ] && [ -n "$RPORT_INSTALLER_DL_PASSWORD" ]; then + DL_AUTH="-u ${RPORT_INSTALLER_DL_USERNAME}:${RPORT_INSTALLER_DL_PASSWORD}" + throw_info "Download will use HTTP basic authentication" + fi + throw_info "Downloading from ${PKG_URL} ..." + PKG_DOWNLOAD=$(mktemp) + # shellcheck disable=SC2086 + curl -LSs "${PKG_URL}" ${DL_AUTH} >${PKG_DOWNLOAD} + if [ -n "$(find "${PKG_DOWNLOAD}" -empty)" ]; then + rm -f "${PKG_DOWNLOAD}" + throw_fatal "Download to ${PKG_DOWNLOAD} failed" + fi + throw_info "Download to ${PKG_DOWNLOAD} completed" +} + +install_from_deb_download() { + validate_pkg_url + if echo "${PKG_URL}" | grep -q "deb$"; then + true + else + throw_fatal "URL not pointing to a debian package" + fi + download_pkg_url + mv "${PKG_DOWNLOAD}" "${PKG_DOWNLOAD}".deb + PKG_DOWNLOAD=${PKG_DOWNLOAD}.deb + chmod 0644 "${PKG_DOWNLOAD}" + throw_info "Installing debian package ${PKG_DOWNLOAD}" + DEBIAN_FRONTEND=noninteractive apt-get --yes -o Dpkg::Options::="--force-confold" install "${PKG_DOWNLOAD}" + rm -f "${PKG_DOWNLOAD}" + clean_up_legacy_installation +} + +install_from_rpm_download() { + validate_pkg_url + if echo "${PKG_URL}" | grep -q "rpm$"; then + true + else + throw_fatal "URL not pointing to an rpm package" + fi + download_pkg_url + throw_info "Installing rpm package" + rpm -U "${PKG_DOWNLOAD}" + rm -f "${PKG_DOWNLOAD}" + clean_up_legacy_installation +} + +abort_on_rport_subprocess() { + if is_rport_subprocess; then + throw_hint "Execute the rport update in a process decoupled from its parent, e.g." + throw_hint ' nohup sh -c "curl -s https://pairing.openrport.io/update|sh" >/tmp/rport-update.log 2>&1 &' + throw_fatal "You cannot update rport from an rport subprocess." + fi +} \ No newline at end of file diff --git a/retrieve/templates/linux/install.sh b/retrieve/templates/linux/install.sh index 4ee7788..c291a0a 100755 --- a/retrieve/templates/linux/install.sh +++ b/retrieve/templates/linux/install.sh @@ -40,16 +40,16 @@ test_connection() { #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: download_and_extract # DESCRIPTION: Download the package from Github and unpack to the temp folder -# https://downloads.rport.io/ acts a redirector service +# https://downloads.openrport.io/ acts a redirector service # returning the real download URL of GitHub in a more handy fashion #---------------------------------------------------------------------------------------------------------------------- download_and_extract() { cd "${TMP_FOLDER}" # Download the tar.gz package if is_available curl; then - curl -LSs "https://downloads.rport.io/rport/${RELEASE}/latest.php?arch=Linux_${ARCH}" -o rport.tar.gz + curl -LSs "https://downloads.openrport.io/rport/${RELEASE}/latest.php?arch=Linux_${ARCH}" -o rport.tar.gz elif is_available wget; then - wget -q "https://downloads.rport.io/rport/${RELEASE}/latest.php?arch=Linux_${ARCH}" -O rport.tar.gz + wget -q "https://downloads.openrport.io/rport/${RELEASE}/latest.php?arch=Linux_${ARCH}" -O rport.tar.gz else abort "No download tool found. Install curl or wget." fi @@ -57,6 +57,37 @@ download_and_extract() { tar xzf rport.tar.gz } +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: download_and_extract_from_url +# DESCRIPTION: Download the package from any URL and unpack to the temp folder +#---------------------------------------------------------------------------------------------------------------------- +download_and_extract_from_url() { + cd "${TMP_FOLDER}" + ARCH=$(uname -m) + DL_AUTH="" + DL="rport.tar.gz" + # Use a specific version + if echo "$PKG_URL" | grep -q -E "^https?:\/\/.*\_linux_${ARCH}.tar.gz"; then + DOWNLOAD_URL="$PKG_URL" + else + echo "PKG_URL does not match 'http(s)://... _linux_${ARCH}.tar.gz'" + abort "Invalid download URL." + fi + if [ -n "$RPORT_INSTALLER_DL_USERNAME" ] && [ -n "$RPORT_INSTALLER_DL_PASSWORD" ]; then + DL_AUTH="-u ${RPORT_INSTALLER_DL_USERNAME}:${RPORT_INSTALLER_DL_PASSWORD}" + confirm "Download will use HTTP basic authentication" + fi + echo "Downloading from ${DOWNLOAD_URL}" + [ -e "${DL}" ] && rm -f "${DL}" + # shellcheck disable=SC2086 + curl -LSs "${DOWNLOAD_URL}" -o "${DL}" ${DL_AUTH} + echo "Verifying download" + FILES_IN_TAR=$(tar tzf "${DL}") + confirm "Package contains $(echo "$FILES_IN_TAR" | wc -w) files" + tar xzf "${DL}" rport + tar xzf "${DL}" rport.example.conf + rm -f "${DL}" +} #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: install_bin # DESCRIPTION: Install a binary located in the temp folder to /usr/local/bin @@ -81,14 +112,17 @@ install_bin() { # PARAMETERS: config name relative to the temp folder without suffix .example.conf #---------------------------------------------------------------------------------------------------------------------- install_config() { - test -e "$CONF_DIR" || mkdir "$CONF_DIR" - CONFIG_FILE=${CONF_DIR}/${1}.conf - if [ -e "${CONFIG_FILE}" ]; then - mv "${CONFIG_FILE}" "${CONFIG_FILE}".bak - confirm "Old config has been backed up to ${CONFIG_FILE}.bak" - fi - mv "${TMP_FOLDER}/rport.example.conf" "${CONFIG_FILE}" - confirm "${CONFIG_FILE} created." + test -e "$CONF_DIR" || mkdir "$CONF_DIR" + CONFIG_FILE=${CONF_DIR}/${1}.conf + if [ -e "${CONFIG_FILE}" ]; then + true + elif [ -e "${TMP_FOLDER}/rport.example.conf" ]; then + mv "${TMP_FOLDER}/rport.example.conf" "${CONFIG_FILE}" + else + throw_hint "If you have used the RPort RPM or DEB package previously, remove it first using the package manager." + throw_fatal "No rport.conf file found." + fi + confirm "${CONFIG_FILE} created." } #--- FUNCTION ------------------------------------------------------------------------------------------------------- @@ -109,15 +143,29 @@ create_user() { abort "No command found to add a user" fi fi - test -e "$LOG_DIR" || mkdir -p "$LOG_DIR" - test -e /var/lib/rport/scripts || mkdir -p /var/lib/rport/scripts - chown "${USER}":root "$LOG_DIR" - chown "${USER}":root /var/lib/rport/scripts - chmod 0700 /var/lib/rport/scripts - chown "${USER}":root "$CONFIG_FILE" - chmod 0640 "$CONFIG_FILE" - chown root:root /usr/local/bin/rport - chmod 0755 /usr/local/bin/rport +# test -e "$LOG_DIR" || mkdir -p "$LOG_DIR" +# test -e /var/lib/rport/scripts || mkdir -p /var/lib/rport/scripts +# chown "${USER}":root "$LOG_DIR" +# chown "${USER}":root /var/lib/rport/scripts +# chmod 0700 /var/lib/rport/scripts +# chown "${USER}":root "$CONFIG_FILE" +# chmod 0640 "$CONFIG_FILE" +# chown root:root /usr/local/bin/rport +# chmod 0755 /usr/local/bin/rport +} + +set_file_and_dir_owner() { + test -e "$LOG_DIR" || mkdir -p "$LOG_DIR" + test -e /var/lib/rport/scripts || mkdir -p /var/lib/rport/scripts + chown "${USER}":root "$LOG_DIR" + chown "${USER}":root /var/lib/rport/scripts + chmod 0700 /var/lib/rport/scripts + chown "${USER}":root "$CONFIG_FILE" + chmod 0640 "$CONFIG_FILE" + if [ -e /usr/local/bin/rport ]; then + chown root:root /usr/local/bin/rport + chmod 0755 /usr/local/bin/rport + fi } #--- FUNCTION ------------------------------------------------------------------------------------------------------- @@ -125,10 +173,14 @@ create_user() { # DESCRIPTION: Install a systemd service file #---------------------------------------------------------------------------------------------------------------------- create_systemd_service() { - echo "Installing systemd service for rport" - test -e /etc/systemd/system/rport.service && rm -f /etc/systemd/system/rport.service - /usr/local/bin/rport --service install --service-user "${USER}" --config /etc/rport/rport.conf - start_rport + if [ -e /lib/systemd/system/rport.service ]; then + echo "Systemd service already present." + else + echo "Installing systemd service for rport" + test -e /etc/systemd/system/rport.service && rm -f /etc/systemd/system/rport.service + /usr/local/bin/rport --service install --service-user "${USER}" --config /etc/rport/rport.conf + fi + start_rport } #--- FUNCTION ------------------------------------------------------------------------------------------------------- @@ -198,18 +250,28 @@ prepare_config() { fi fi - if get_geodata; then - if [ -n "$TAGS" ]; then - TAGS=$(printf "%s:%s:%s" "$TAGS" "$COUNTRY" "$CITY") + # Activate client attributes + if get_geodata; then + LABELS="\"city\":\"${CITY}\", \"country\":\"${COUNTRY}\"" + fi + if [ -n "$XTAG" ]; then + XTAG="\"$XTAG\"" + fi + CLIENT_ATTRIBUTES="/var/lib/rport/client_attributes.json" + if [ -e /var/lib/rport ]; then + true else - TAGS=$(printf "%s:%s" "$COUNTRY" "$CITY") + mkdir /var/lib/rport + chown "${USER}":root /var/lib/rport fi - fi - if [ -n "$TAGS" ]; then - # shellcheck disable=SC2001 - TAGS='["'$(echo "$TAGS" | sed s/":"/\",\"/g)'"]' - sed -i "s/#tags = .*/tags = ${TAGS}/g" "$CONFIG_FILE" - fi + cat <$CLIENT_ATTRIBUTES +{ + "tags": [${TAGS}], + "labels": { ${LABELS} } +} +EOF + sed -i "s|#attributes_file_path = \"/var/.*|attributes_file_path = \"${CLIENT_ATTRIBUTES}\"|g" "$CONFIG_FILE" + chown "${USER}" "${CLIENT_ATTRIBUTES}" } #--- FUNCTION ------------------------------------------------------------------------------------------------------- @@ -257,7 +319,7 @@ install_client() { echo "" echo "Your system has SELinux enabled. This installer will not create the needed policies." echo "Rport will not connect with out the right policies." - echo "Read more https://kb.rport.io/digging-deeper/advanced-client-management/run-with-selinux" + echo "Read more https://kb.openrport.io/digging-deeper/advanced-client-management/run-with-selinux" echo "Excute '$0 ${RAW_ARGS} -l' to skip this warning and install anyways. You must create the polcies later." exit 1 fi @@ -268,6 +330,7 @@ install_client() { prepare_config enable_lan_monitoring detect_interpreters + set_file_and_dir_owner create_user if is_available openrc; then create_openrc_service @@ -383,8 +446,13 @@ Options: -l Install with SELinux enabled. -g Add an extra tag to the client. -d Do not use /etc/machine-id to identify this machine. A random UUID will be used instead. +-z Download the rport client tar.gz from the given URL instead of using GitHub releases. See environment variables. + +Environment variables: + If RPORT_INSTALLER_DL_USERNAME and RPORT_INSTALLER_DL_PASSWORD are set, downloads of custom packages triggered with + '-z' are initiated with HTTP basic authentication. -Learn more https://kb.rport.io/connecting-clients#advanced-pairing-options +Learn more https://kb.openrport.io/connecting-clients#advanced-pairing-options EOF exit 0 } @@ -403,10 +471,10 @@ finish() { # Look at $CONFIG_FILE and explore all options. # Logs are written to /var/log/rport/rport.log. # -# READ THE DOCS ON https://kb.rport.io/ +# READ THE DOCS ON https://kb.openrport.io/ # # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# Give us a star on https://github.com/cloudradar-monitoring/rport +# Give us a star on https://github.com/openrport/openrport # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # @@ -470,6 +538,8 @@ SELINUX_FORCE=0 ENABLE_FILEREC=0 ENABLE_FILEREC_SUDO=0 TAGS="" +XTAG="" +NO_REPO=0 while getopts 'hvfcsuxstildrba:g:' opt; do case "${opt}" in @@ -492,8 +562,10 @@ while getopts 'hvfcsuxstildrba:g:' opt; do r) ENABLE_FILEREC=1 ;; b) ENABLE_FILEREC_SUDO=1 ;; a) USER=${OPTARG} ;; - g) TAGS=${OPTARG} ;; + g) XTAG=${OPTARG} ;; + z) export PKG_URL="${OPTARG}" ;; d) MACHINE_ID=gen_uuid ;; + p) NO_REPO=1 ;; \?) echo "Option does not exist." diff --git a/retrieve/templates/linux/uninstall.sh b/retrieve/templates/linux/uninstall.sh index 465aa1e..6d5280f 100644 --- a/retrieve/templates/linux/uninstall.sh +++ b/retrieve/templates/linux/uninstall.sh @@ -7,12 +7,12 @@ # # DESCRIPTION: Rport removal for various systems/distributions # -# BUGS: https://github.com/cloudradar-monitoring/rport/issues +# BUGS: https://github.com/openrport/openrport/issues # # COPYRIGHT: (c) 2021 by the CloudRadar Team, # # LICENSE: MIT -# ORGANIZATION: cloudradar GmbH, Potsdam, Germany (cloudradar.io) +# ORGANIZATION: openrport , Lille, France (openrport.io) # CREATED: 30/09/2021 #====================================================================================================================== @@ -25,5 +25,5 @@ echo " [ FINISH ] RPort client removed." echo "" echo "#" echo "# If you dislike RPort, please share your feedback on " -echo "# https://github.com/cloudradar-monitoring/rport/discussions/categories/general " +echo "# https://github.com/openrport/openrport/discussions/categories/general " echo "# " \ No newline at end of file diff --git a/retrieve/templates/linux/update.sh b/retrieve/templates/linux/update.sh index 8925c52..324a9e4 100644 --- a/retrieve/templates/linux/update.sh +++ b/retrieve/templates/linux/update.sh @@ -3,7 +3,7 @@ CURRENT_VERSION=$(/usr/local/bin/rport --version | awk '{print $2}') download_package() { if [ "$VERSION" != "undef" ]; then RELEASE=custom - URL="https://github.com/cloudradar-monitoring/rport/releases/download/${VERSION}/rport_${VERSION}_Linux_${ARCH}.tar.gz" + URL="https://github.com/openrport/openrport/releases/download/${VERSION}/rport_${VERSION}_Linux_${ARCH}.tar.gz" if curl -fI "$URL" >/dev/null 2>&1; then true else @@ -11,7 +11,7 @@ download_package() { exit 1 fi else - URL="https://download.rport.io/rport/${RELEASE}/?arch=Linux_${ARCH}>=${CURRENT_VERSION}" + URL="https://download.openrport.io/rport/${RELEASE}/?arch=Linux_${ARCH}>=${CURRENT_VERSION}" fi curl -Ls "${URL}" -o rport.tar.gz } diff --git a/retrieve/updateHandler.go b/retrieve/updateHandler.go index 1e53b85..78a859c 100644 --- a/retrieve/updateHandler.go +++ b/retrieve/updateHandler.go @@ -1,7 +1,7 @@ package retrieve import ( - "github.com/cloudradar-monitoring/rport-pairing/deposit" + "github.com/openrport/rport-pairing/deposit" "net/http" ) diff --git a/retrieve/updateHandler_test.go b/retrieve/updateHandler_test.go index 3d77b21..f7b32a7 100644 --- a/retrieve/updateHandler_test.go +++ b/retrieve/updateHandler_test.go @@ -2,7 +2,7 @@ package retrieve_test import ( "fmt" - "github.com/cloudradar-monitoring/rport-pairing/retrieve" + "github.com/openrport/rport-pairing/retrieve" "github.com/stretchr/testify/assert" "net/http" "net/http/httptest"