#!/bin/bash # Usage: jetbrains_first_run.sh HOME_DIR # Settings of the JetBrains IDEs (CLion, IntelliJ IDEA, PyCharm) for the team # account, so that the teams go straight to work: # - user agreement accepted, no usage data sharing (first-launch questions) # - the home directory /home/team trusted (no "Trust project?" question) # Compiler and interpreter defaults are installed by configure_ides.py. # The folder name under .java is how Java stores the preference node # "privacy_policy". set -eu dest_home=$1 prefs="$dest_home/.java/.userPrefs/jetbrains/"$'_!(!!cg"p!(}!}@"j!(k!|w"w!\'8!b!"p!\':!e@==' consent="$dest_home/.local/share/JetBrains/consentOptions" mkdir -p "$prefs" "$consent" cat > "$prefs/prefs.xml" <<'XML' XML printf 'rsch.send.usage.stat:1.1:0:1791991599000' > "$consent/accepted" for ide in pycharm intellij-idea clion; do [ -f "/opt/$ide/product-info.json" ] || continue dir=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["dataDirectoryName"])' "/opt/$ide/product-info.json") options="$dest_home/.config/JetBrains/$dir/options" mkdir -p "$options" cat > "$options/trusted-paths.xml" <<'XML' XML done if [ "$dest_home" != /etc/skel ]; then owner=$(stat -c %U:%G "$dest_home") chown -R "$owner" "$dest_home/.java" "$dest_home/.local" "$dest_home/.config/JetBrains" fi