From 2ce72cee335a395b8b159e53ac751d53f19719b9 Mon Sep 17 00:00:00 2001 From: Eric Yu Date: Sat, 2 Mar 2024 01:09:24 -0800 Subject: [PATCH] chrome installer --- tools/scripts/get_chrome | 42 ++++++++++++++++++++++++++++++++++++++ tools/scripts/install_code | 9 +++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 tools/scripts/get_chrome diff --git a/tools/scripts/get_chrome b/tools/scripts/get_chrome new file mode 100755 index 0000000..b429d18 --- /dev/null +++ b/tools/scripts/get_chrome @@ -0,0 +1,42 @@ +#!/bin/bash + +# Define the source file and target directory +target_dir="$HOME/bin" + +# Check if $HOME/bin directory exists, if not, create it +if [ ! -d "$target_dir" ]; then + mkdir -p "$target_dir" + echo "Created $target_dir" +fi + +# check if chrome directory exist, if yes, delete it and then create it +if [ -d "chrome" ]; then + rm -rf "chrome" +fi + +mkdir chrome +cd chrome + +# Download Chrome +curl -L -o chrome.rpm "https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm" + +rpm2cpio chrome.rpm | cpio -idv + +rm -rf chrome.rpm + +# correct permissions +cd opt/google/chrome +chmod +x google-chrome + +# Since we don't have sudo, modify a line of the Chromium backend to allow non-roots to run +sed -i 's/\(exec -a "$0" "$HERE\/chrome"\)/\1 --no-sandbox --user-data-dir=\/tmp\/google-chrome\/$HOSTNAME$DISPLAY/' google-chrome + +# create shortcut to user's bin folder, which by default is already something in PATH, so that we can run it from anywhere +# but first, check if the link already exists, if yes, delete it +if [ -L "$target_dir/chrome" ]; then + rm -rf "$target_dir/chrome" +fi +ln -s $PWD/google-chrome $target_dir/chrome + +# Make sure the linked one also has perm +chmod +x $target_dir/chrome diff --git a/tools/scripts/install_code b/tools/scripts/install_code index 2acff09..ad3c60a 100755 --- a/tools/scripts/install_code +++ b/tools/scripts/install_code @@ -4,7 +4,6 @@ code_version="1.82.3" # Define the source file and target directory -source_file="source_file.txt" target_dir="$HOME/bin" # Check if $HOME/bin directory exists, if not, create it @@ -13,6 +12,10 @@ if [ ! -d "$target_dir" ]; then echo "Created $target_dir" fi +# check if the directory exist, if yes, delete it and then create it +if [ -d "code" ]; then + rm -rf "code" +fi mkdir code cd code @@ -32,6 +35,10 @@ chmod +x code sed -i 's/\(ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node\)/\1 --no-sandbox/' code # create shortcut to user's bin folder, which by default is already something in PATH +# but first, check if the link already exists, if yes, delete it +if [ -L "$target_dir/code" ]; then + rm -rf "$target_dir/code" +fi ln -s $PWD/code $target_dir/code # Make sure the linked one also has perm