Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAN-2126: Changes to Linux RAA install script #556

Merged
merged 5 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ fi
set -u

# set the RAA version string in the below variable before running the script.
# the example format of version: v0.75.0
# the example format of version: v0.172.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be nice automated. I can see customers being confused on what the current version is.

declare -t raa_version=""

if [[ "$raa_version" == "" ]]; then
echo "'raa_version' need to be provided in the script (eg. v0.75.0)"
exit 0
echo "'raa_version' need to be provided in the script (eg. v0.172.0)"
exit 1
fi

tmp_dir=$(mktemp -d)
arch="$(uname -m)"
echo $(arch)

declare -r timeout=900
declare -r max_retries=4
Expand All @@ -42,17 +44,15 @@ declare -r max_retry_time=3600
declare -r tmp_dir

declare -r pub_key_name="jumpcloud-remote-assist-agent.gpg.asc"
declare -r raa_binary_name="jumpcloud-remote-assist"

declare -r install_prefix="/opt/jc_user_ro"
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 raa_binary_path="${raa_directory}/jumpcloud-remote-assist"

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"
declare -r remote_pub_key_url="https://cdn02.jumpcloud.com/production/remote-assist/jumpcloud-remote-assist-agent.gpg.asc"
declare -r remote_tgz_url="https://cdn02.jumpcloud.com/production/remote-assist/versions/${raa_version}/jumpcloud-remote-assist-agent_${arch}.tar.gz"

declare -r old_pub_key_fingerprint="83463C47A34D1BC1"
declare -r pub_key_fingerprint="8C31C1376B37D307"
Expand Down Expand Up @@ -139,10 +139,10 @@ function remove_old_raa_dir() {

function kill_running_raa_instance() {
local pid_list
pid_list=$(pidof "${raa_binary_name}")
pid_list=$(pidof "${raa_binary_path}")
for raa_pid in ${pid_list}; do
echo "Stopping remote assist process ${raa_pid}"
kill "${raa_pid}"
kill -9 "${raa_pid}"
done
}

Expand All @@ -169,15 +169,6 @@ function install_raasvc_file() {
fi
}

function install_uninstall_script() {
mkdir -p "$(dirname "${uninstaller_path}")"
cat > "${uninstaller_path}" <<'EOF'
{{template "linuxUninstall.tmpl.sh" .}}
EOF
chmod -x "${uninstaller_path}"
chmod 700 "${uninstaller_path}"
}

function main() {
trap cleanup EXIT
install_pub_key
Expand All @@ -186,15 +177,14 @@ function main() {
install_new_raa
install_desktop_file
install_raasvc_file
install_uninstall_script
}

main
```

#### Description

This script installs rempte assist application on the Linux machine.
This script installs remote assist application on the Linux machine.

#### _Import This Command_

Expand Down
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Commands Gallery/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
{
"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}\"\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",
"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.172.0\ndeclare -t raa_version=\"\"\n\nif [[ \"$raa_version\" == \"\" ]]; then\n echo \"'raa_version' need to be provided in the script (eg. v0.172.0)\"\n exit 1\nfi\n\ntmp_dir=$(mktemp -d)\narch=\"$(uname -m)\"\necho $(arch)\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 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 raa_service_install_file=\"${raa_directory}/resources/build-app/linux/raasvc-install.sh\"\ndeclare -r raa_binary_path=\"${raa_directory}/jumpcloud-remote-assist\"\n\ndeclare -r remote_pub_key_url=\"https://cdn02.jumpcloud.com/production/remote-assist/jumpcloud-remote-assist-agent.gpg.asc\"\ndeclare -r remote_tgz_url=\"https://cdn02.jumpcloud.com/production/remote-assist/versions/${raa_version}/jumpcloud-remote-assist-agent_${arch}.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_path}\")\n for raa_pid in ${pid_list}; do\n echo \"Stopping remote assist process ${raa_pid}\"\n kill -9 \"${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 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}\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."
"description": "This script installs remote assist application on the Linux machine."
},
{
"name": "Mac - Disable Local User | v1.0 JCCG",
Expand Down
Loading