From 9cf6f830c4dc9e98f82154dda481b4b849e3b2fd Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 13 Jul 2023 22:40:35 +0530 Subject: [PATCH 1/2] BAN-1241: Change in install file for starting the raasvc/raal service used in prompted/silent asssit --- .../Linux - remote-assist - Installation script.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PowerShell/JumpCloud Commands Gallery/Linux Commands/Linux - remote-assist - Installation script.md b/PowerShell/JumpCloud Commands Gallery/Linux Commands/Linux - remote-assist - Installation script.md index 605f16671..fb71e826b 100644 --- a/PowerShell/JumpCloud Commands Gallery/Linux Commands/Linux - remote-assist - Installation script.md +++ b/PowerShell/JumpCloud Commands Gallery/Linux Commands/Linux - remote-assist - Installation script.md @@ -49,6 +49,7 @@ declare -r apps_path="/usr/share/applications" declare -r raa_directory="${install_prefix}/jumpcloud-remote-assist" declare -r raa_desktop_file="${raa_directory}/resources/build-app/linux/jumpcloud-remote-assist.desktop" declare -r uninstaller_path="${install_prefix}/bin/uninstall-${raa_binary_name}" +declare -r raa_service_install_file="${raa_directory}/resources/build-app/linux/raasvc-install.sh" declare -r remote_pub_key_url="https://jumpcloud-windows-agent.s3.amazonaws.com/production/remote-assist/jumpcloud-remote-assist-agent.gpg.asc" declare -r remote_tgz_url="https://jumpcloud-windows-agent.s3.amazonaws.com/production/remote-assist/versions/${raa_version}/jumpcloud-remote-assist-agent_x86_64.tar.gz" @@ -160,6 +161,14 @@ function install_desktop_file() { fi } +function install_raasvc_file() { + echo "Installing raasvc and raal service" + if [[ -f "${raa_service_install_file}" ]]; then + chmod +x "${raa_service_install_file}" + /bin/bash "${raa_service_install_file}" + fi +} + function install_uninstall_script() { mkdir -p "$(dirname "${uninstaller_path}")" cat > "${uninstaller_path}" <<'EOF' @@ -176,6 +185,7 @@ function main() { kill_running_raa_instance install_new_raa install_desktop_file + install_raasvc_file install_uninstall_script } From e3e713026e4839f09726ee385ae33428ea0e5523 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 13 Jul 2023 17:14:35 +0000 Subject: [PATCH 2/2] Updating Commands.json;[skip ci] --- PowerShell/JumpCloud Commands Gallery/commands.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Commands Gallery/commands.json b/PowerShell/JumpCloud Commands Gallery/commands.json index 25144da17..96deb19c1 100644 --- a/PowerShell/JumpCloud Commands Gallery/commands.json +++ b/PowerShell/JumpCloud Commands Gallery/commands.json @@ -100,7 +100,7 @@ { "name": "Linux - remote-assist - Installation script | v1.0 JCCG", "type": "linux", - "command": "#!/usr/bin/env bash\n################################################################################\n# This script will install remote assist application on a Linux device\n################################################################################\n\n# Disable following external sources\n# shellcheck disable=SC1091,SC1090,SC2059\n\nif [[ \"${UID}\" != 0 ]]; then\n (>&2 echo \"Error: $0 must be run as root\")\n exit 1\nfi\n\nset -u\n\n# set the RAA version string in the below variable before running the script.\n# the example format of version: v0.75.0\ndeclare -t raa_version=\"\"\n\nif [[ \"$raa_version\" == \"\" ]]; then\n echo \"'raa_version' need to be provided in the script (eg. v0.75.0)\"\n exit 0\nfi\n\ntmp_dir=$(mktemp -d)\n\ndeclare -r timeout=900\ndeclare -r max_retries=4\ndeclare -r max_retry_time=3600\n\ndeclare -r tmp_dir\n\ndeclare -r pub_key_name=\"jumpcloud-remote-assist-agent.gpg.asc\"\ndeclare -r raa_binary_name=\"jumpcloud-remote-assist\"\n\ndeclare -r install_prefix=\"/opt/jc_user_ro\"\ndeclare -r apps_path=\"/usr/share/applications\"\ndeclare -r raa_directory=\"${install_prefix}/jumpcloud-remote-assist\"\ndeclare -r raa_desktop_file=\"${raa_directory}/resources/build-app/linux/jumpcloud-remote-assist.desktop\"\ndeclare -r uninstaller_path=\"${install_prefix}/bin/uninstall-${raa_binary_name}\"\n\ndeclare -r remote_pub_key_url=\"https://jumpcloud-windows-agent.s3.amazonaws.com/production/remote-assist/jumpcloud-remote-assist-agent.gpg.asc\"\ndeclare -r remote_tgz_url=\"https://jumpcloud-windows-agent.s3.amazonaws.com/production/remote-assist/versions/${raa_version}/jumpcloud-remote-assist-agent_x86_64.tar.gz\"\n\ndeclare -r old_pub_key_fingerprint=\"83463C47A34D1BC1\"\ndeclare -r pub_key_fingerprint=\"8C31C1376B37D307\"\ndeclare -r owner_trust=\"C2122200660347DB094054808C31C1376B37D307:6:\"\ndeclare -r tgz_name=\"jumpcloud-remote-assist-agent.tar.gz\"\ndeclare -r sig_name=\"${tgz_name}.zig\"\n\ndeclare -r local_pub_key_path=\"${tmp_dir}/${pub_key_name}\"\ndeclare -r local_tgz_tmp_path=\"${tmp_dir}/${tgz_name}\"\ndeclare -r local_sig_tmp_path=\"${tmp_dir}/${sig_name}\"\n\ndeclare -r remote_sig_url=\"${remote_tgz_url}.sig\"\n\nfunction cleanup() {\n rm -rf \"${tmp_dir}\"\n}\n\nfunction download_single_file() {\n local url=${1}\n local local_file=${2}\n\n echo \"Downloading ${url}\"\n\n curl_output=$(curl -v --trace-time \\\n --max-time \"${timeout}\" --retry \"${max_retries}\" \\\n --retry-max-time \"${max_retry_time}\" \\\n --output \"${local_file}\" \"${url}\" -C - 2>&1)\n\n rc=$?\n if [[ \"$rc\" != \"0\" ]]; then\n echo \"Failed to download ${url}\"\n echo \"${curl_output}\"\n exit ${rc}\n fi\n}\n\nfunction remove_old_pub_key() {\n if gpg --list-keys | grep -q \"${old_pub_key_fingerprint}\"; then\n echo \"Removing old public key ${old_pub_key_fingerprint}\"\n gpg --batch --yes --delete-key \"${old_pub_key_fingerprint}\"\n fi\n}\n\nfunction install_pub_key() {\n remove_old_pub_key\n\n output=$(gpg --list-keys | grep \"${pub_key_fingerprint}\")\n if [[ \"${output}\" == \"\" ]]; then\n download_single_file \"${remote_pub_key_url}\" \"${local_pub_key_path}\"\n echo \"Importing public key ${pub_key_fingerprint}\"\n gpg --import \"${local_pub_key_path}\"\n echo \"${owner_trust}\" | gpg --import-ownertrust\n fi\n}\n\nfunction verify_signature() {\n local sig=\"${1}\"\n local tgz=\"${2}\"\n gpg --verify \"${sig}\" \"${tgz}\" 2>&1\n}\n\nfunction download_files() {\n download_single_file \"${remote_tgz_url}\" \"${local_tgz_tmp_path}\"\n download_single_file \"${remote_sig_url}\" \"${local_sig_tmp_path}\"\n if ! verify_signature \"${local_sig_tmp_path}\" \"${local_tgz_tmp_path}\"; then\n echo \"Unable to verify signature for ${tgz_name}\"\n exit 1\n fi\n}\n\nfunction uncompress_tarball() {\n echo \"Installing new RAA\"\n mkdir -p \"${install_prefix}\"\n chmod 755 \"${install_prefix}\"\n tar zxf \"${local_tgz_tmp_path}\" -C \"${install_prefix}\"\n}\n\nfunction remove_old_raa_dir() {\n if [[ -d \"${raa_directory}\" ]]; then\n echo \"Removing old RAA\"\n rm -rf \"${raa_directory}\"\n fi\n}\n\nfunction kill_running_raa_instance() {\n local pid_list\n pid_list=$(pidof \"${raa_binary_name}\")\n for raa_pid in ${pid_list}; do\n echo \"Stopping remote assist process ${raa_pid}\"\n kill \"${raa_pid}\"\n done\n}\n\nfunction install_new_raa() {\n remove_old_raa_dir\n uncompress_tarball\n}\n\nfunction install_desktop_file() {\n echo \"Installing desktop shortcut\"\n if [[ -d \"${apps_path}\" ]]; then\n cp \"${raa_desktop_file}\" \"${apps_path}\"\n if command -v \"update-desktop-database\" &>/dev/null; then\n update-desktop-database\n fi\n fi\n}\n\nfunction install_uninstall_script() {\n mkdir -p \"$(dirname \"${uninstaller_path}\")\"\n cat > \"${uninstaller_path}\" <<'EOF'\n{{template \"linuxUninstall.tmpl.sh\" .}}\nEOF\n chmod -x \"${uninstaller_path}\"\n chmod 700 \"${uninstaller_path}\"\n}\n\nfunction main() {\n trap cleanup EXIT\n install_pub_key\n download_files\n kill_running_raa_instance\n install_new_raa\n install_desktop_file\n install_uninstall_script\n}\n\nmain", + "command": "#!/usr/bin/env bash\n################################################################################\n# This script will install remote assist application on a Linux device\n################################################################################\n\n# Disable following external sources\n# shellcheck disable=SC1091,SC1090,SC2059\n\nif [[ \"${UID}\" != 0 ]]; then\n (>&2 echo \"Error: $0 must be run as root\")\n exit 1\nfi\n\nset -u\n\n# set the RAA version string in the below variable before running the script.\n# the example format of version: v0.75.0\ndeclare -t raa_version=\"\"\n\nif [[ \"$raa_version\" == \"\" ]]; then\n echo \"'raa_version' need to be provided in the script (eg. v0.75.0)\"\n exit 0\nfi\n\ntmp_dir=$(mktemp -d)\n\ndeclare -r timeout=900\ndeclare -r max_retries=4\ndeclare -r max_retry_time=3600\n\ndeclare -r tmp_dir\n\ndeclare -r pub_key_name=\"jumpcloud-remote-assist-agent.gpg.asc\"\ndeclare -r raa_binary_name=\"jumpcloud-remote-assist\"\n\ndeclare -r install_prefix=\"/opt/jc_user_ro\"\ndeclare -r apps_path=\"/usr/share/applications\"\ndeclare -r raa_directory=\"${install_prefix}/jumpcloud-remote-assist\"\ndeclare -r raa_desktop_file=\"${raa_directory}/resources/build-app/linux/jumpcloud-remote-assist.desktop\"\ndeclare -r uninstaller_path=\"${install_prefix}/bin/uninstall-${raa_binary_name}\"\ndeclare -r raa_service_install_file=\"${raa_directory}/resources/build-app/linux/raasvc-install.sh\"\n\ndeclare -r remote_pub_key_url=\"https://jumpcloud-windows-agent.s3.amazonaws.com/production/remote-assist/jumpcloud-remote-assist-agent.gpg.asc\"\ndeclare -r remote_tgz_url=\"https://jumpcloud-windows-agent.s3.amazonaws.com/production/remote-assist/versions/${raa_version}/jumpcloud-remote-assist-agent_x86_64.tar.gz\"\n\ndeclare -r old_pub_key_fingerprint=\"83463C47A34D1BC1\"\ndeclare -r pub_key_fingerprint=\"8C31C1376B37D307\"\ndeclare -r owner_trust=\"C2122200660347DB094054808C31C1376B37D307:6:\"\ndeclare -r tgz_name=\"jumpcloud-remote-assist-agent.tar.gz\"\ndeclare -r sig_name=\"${tgz_name}.zig\"\n\ndeclare -r local_pub_key_path=\"${tmp_dir}/${pub_key_name}\"\ndeclare -r local_tgz_tmp_path=\"${tmp_dir}/${tgz_name}\"\ndeclare -r local_sig_tmp_path=\"${tmp_dir}/${sig_name}\"\n\ndeclare -r remote_sig_url=\"${remote_tgz_url}.sig\"\n\nfunction cleanup() {\n rm -rf \"${tmp_dir}\"\n}\n\nfunction download_single_file() {\n local url=${1}\n local local_file=${2}\n\n echo \"Downloading ${url}\"\n\n curl_output=$(curl -v --trace-time \\\n --max-time \"${timeout}\" --retry \"${max_retries}\" \\\n --retry-max-time \"${max_retry_time}\" \\\n --output \"${local_file}\" \"${url}\" -C - 2>&1)\n\n rc=$?\n if [[ \"$rc\" != \"0\" ]]; then\n echo \"Failed to download ${url}\"\n echo \"${curl_output}\"\n exit ${rc}\n fi\n}\n\nfunction remove_old_pub_key() {\n if gpg --list-keys | grep -q \"${old_pub_key_fingerprint}\"; then\n echo \"Removing old public key ${old_pub_key_fingerprint}\"\n gpg --batch --yes --delete-key \"${old_pub_key_fingerprint}\"\n fi\n}\n\nfunction install_pub_key() {\n remove_old_pub_key\n\n output=$(gpg --list-keys | grep \"${pub_key_fingerprint}\")\n if [[ \"${output}\" == \"\" ]]; then\n download_single_file \"${remote_pub_key_url}\" \"${local_pub_key_path}\"\n echo \"Importing public key ${pub_key_fingerprint}\"\n gpg --import \"${local_pub_key_path}\"\n echo \"${owner_trust}\" | gpg --import-ownertrust\n fi\n}\n\nfunction verify_signature() {\n local sig=\"${1}\"\n local tgz=\"${2}\"\n gpg --verify \"${sig}\" \"${tgz}\" 2>&1\n}\n\nfunction download_files() {\n download_single_file \"${remote_tgz_url}\" \"${local_tgz_tmp_path}\"\n download_single_file \"${remote_sig_url}\" \"${local_sig_tmp_path}\"\n if ! verify_signature \"${local_sig_tmp_path}\" \"${local_tgz_tmp_path}\"; then\n echo \"Unable to verify signature for ${tgz_name}\"\n exit 1\n fi\n}\n\nfunction uncompress_tarball() {\n echo \"Installing new RAA\"\n mkdir -p \"${install_prefix}\"\n chmod 755 \"${install_prefix}\"\n tar zxf \"${local_tgz_tmp_path}\" -C \"${install_prefix}\"\n}\n\nfunction remove_old_raa_dir() {\n if [[ -d \"${raa_directory}\" ]]; then\n echo \"Removing old RAA\"\n rm -rf \"${raa_directory}\"\n fi\n}\n\nfunction kill_running_raa_instance() {\n local pid_list\n pid_list=$(pidof \"${raa_binary_name}\")\n for raa_pid in ${pid_list}; do\n echo \"Stopping remote assist process ${raa_pid}\"\n kill \"${raa_pid}\"\n done\n}\n\nfunction install_new_raa() {\n remove_old_raa_dir\n uncompress_tarball\n}\n\nfunction install_desktop_file() {\n echo \"Installing desktop shortcut\"\n if [[ -d \"${apps_path}\" ]]; then\n cp \"${raa_desktop_file}\" \"${apps_path}\"\n if command -v \"update-desktop-database\" &>/dev/null; then\n update-desktop-database\n fi\n fi\n}\n\nfunction install_raasvc_file() {\n echo \"Installing raasvc and raal service\"\n if [[ -f \"${raa_service_install_file}\" ]]; then\n chmod +x \"${raa_service_install_file}\"\n /bin/bash \"${raa_service_install_file}\"\n fi\n}\n\nfunction install_uninstall_script() {\n mkdir -p \"$(dirname \"${uninstaller_path}\")\"\n cat > \"${uninstaller_path}\" <<'EOF'\n{{template \"linuxUninstall.tmpl.sh\" .}}\nEOF\n chmod -x \"${uninstaller_path}\"\n chmod 700 \"${uninstaller_path}\"\n}\n\nfunction main() {\n trap cleanup EXIT\n install_pub_key\n download_files\n kill_running_raa_instance\n install_new_raa\n install_desktop_file\n install_raasvc_file\n install_uninstall_script\n}\n\nmain", "link": "https://github.com/TheJumpCloud/support/blob/master/PowerShell/JumpCloud%20Commands%20Gallery/Linux%20Commands/Linux%20-%20remote-assist%20-%20Installation%20script.md", "description": "This script installs rempte assist application on the Linux machine." },