Cloudflare Tunnel Demo (I use arch btw)

GCP Chrome Remote Desktop Setup Script


Navigation

Nextcloud Setup

Tailscale Setup

Ubuntu Docker Install

Ubuntu Tunnel Setup

Ubuntu Service Setup


#!/bin/bash 

LOG_FILE="/tmp/crd_setup_$(date +%Y%m%d_%H%M%S).log"
exec > >(tee -i ${LOG_FILE}) 2>&1
set -x

echo "--- Starting Chrome Remote Desktop Setup Script ---"
echo "Log file: ${LOG_FILE}"

function install_desktop_env {
  PACKAGES="desktop-base xscreensaver dbus-x11"
  if [[ "$INSTALL_XFCE" != "yes" && "$INSTALL_CINNAMON" != "yes" ]] ; then
    INSTALL_XFCE=yes
    INSTALL_CINNAMON=yes
  fi
  if [[ "$INSTALL_XFCE" = "yes" ]] ; then
    PACKAGES="$PACKAGES xfce4"
    echo "exec xfce4-session" > /etc/chrome-remote-desktop-session
    [[ "$INSTALL_FULL_DESKTOP" = "yes" ]] && PACKAGES="$PACKAGES task-xfce-desktop"
  fi
  if [[ "$INSTALL_CINNAMON" = "yes" ]] ; then
    PACKAGES="$PACKAGES cinnamon-core"
    echo "exec cinnamon-session-cinnamon2d" > /etc/chrome-remote-desktop-session
    [[ "$INSTALL_FULL_DESKTOP" = "yes" ]] && PACKAGES="$PACKAGES task-cinnamon-desktop"
  fi

  DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes $PACKAGES $EXTRA_PACKAGES
  systemctl disable lightdm.service
}

function download_and_install {
  if [[ -e "$2" ]] ; then
    echo "cannot download $1 to $2 - file exists"
    return 1
  fi
  curl -L -o "$2" "$1" &&
    apt-get install --assume-yes --fix-broken "$2" &&
    rm "$2"
}

function is_installed {
  dpkg-query --list "$1" | grep -q "^ii" 2>/dev/null
  return $?
}

INSTALL_XFCE=yes
INSTALL_CINNAMON=yes
INSTALL_CHROME=yes
INSTALL_FULL_DESKTOP=yes
EXTRA_PACKAGES="less bzip2 zip unzip tasksel wget"

apt-get update

if ! is_installed chrome-remote-desktop; then
  if [[ ! -e /etc/apt/keyrings/google-chrome.gpg ]]; then
    echo "Adding Google GPG key to prevent NO_PUBKEY errors."
    wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg
  fi

  if [[ ! -e /etc/apt/sources.list.d/chrome-remote-desktop.list ]]; then
    echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] https://dl.google.com/linux/chrome-remote-desktop/deb stable main" |
      tee -a /etc/apt/sources.list.d/chrome-remote-desktop.list
  fi

  apt-get update
  DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes chrome-remote-desktop
fi

install_desktop_env

[[ "$INSTALL_CHROME" = "yes" ]] && ! is_installed google-chrome-stable &&
  download_and_install \
    https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    /tmp/google-chrome-stable_current_amd64.deb

echo "Chrome remote desktop installation completed"
echo "--- Script finished at $(date) ---"