Skip to content

Instantly share code, notes, and snippets.

@jifalops
Last active Jun 30, 2019
Embed
What would you like to do?
Headless Crostini quick setup script for Flutter, VS Code, Node/npm (via nvm), Firebase tools, and pip for Python3

Headless Crostini quick setup script for Flutter, VS Code, Node/npm (via nvm), Firebase tools, and pip for Python3

Modify lines 20 and 21 with your gist and token for the VS Code settings-sync extension.

The script adds a symbolic link to the ChromeOS Downloads folder at ~/Downloads. For it to work, share your Downloads folder with Linux by right-clicking it in the Files app.

WARNING

  • The script appends to the PATH environment variable each time it runs (at the end).
  • settings.json for VS Code will be overwritten if it exists! (The default settings are empty and it was easier to do it this way than to use jq.)

To get the script, use the Terminal app:

user@penguin:~$ mkdir bin && cd $_
user@penguin:~/bin$ wget https://gist.githubusercontent.com/jifalops/4eabe4684c250cea9e0d416b69271d40/raw/setup-dev-machine.sh
user@penguin:~/bin$ chmod +x setup-dev-machine.sh 
# Replace ___ENTER_GIST_HERE___ and __ENTER_TOKEN_HERE___ on line ~20 to have Settings Sync for VS Code setup for you.
user@penguin:~/bin$ ./setup-dev-machine.sh 

The alt-tab fix seems to be unnecessary as of ChromeOS 75, and has been moved to a separate file.

# Alt-tab fix
echo
echo "Running fix for Alt-tab not working in full-screen mode"
echo "See https://www.reddit.com/r/Crostini/comments/9fntrj/crostini_fullscreened_linux_gui_app_and_alttab/e61h6oe?utm_source=share&utm_medium=web2x"
echo
mkdir -p ~/.config/systemd/user/sommelier-x@0.service.d
echo -e '[Service]\nEnvironment="SOMMELIER_ACCELERATORS=Super_L,<Alt>tab"' > ~/.config/systemd/user/sommelier-x@0.service.d/override.conf
systemctl --user daemon-reload
systemctl --user restart sommelier-x@0.service
cd "$HOME"
curl -s "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" -o ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
rm ~/miniconda.sh
PATH="$PATH:$HOME/miniconda/bin:$HOME/miniconda/condabin"
PATH_CHANGES+=':$HOME/miniconda/bin:$HOME/miniconda/condabin'
#!/bin/bash
echo
echo "###########################################################################"
echo "Setting up this system for development."
echo "VS Code, Flutter, Android SDK, Node and npm (via nvm), and pip for Python 3"
echo "Updated 2019-05-30"
echo
cd "$HOME"
PATH_CHANGES=""
# VS Code with settings-sync
echo
echo "======================================================="
echo "Setting up VS Code by adding it to the apt sources list"
echo "See https://code.visualstudio.com/docs/setup/linux"
echo
CODE_SETTINGS_GIST="___ENTER_GIST_HERE___"
CODE_SETTINGS_TOKEN="__ENTER_TOKEN_HERE___"
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get -y install apt-transport-https
sudo apt-get update
sudo apt-get -y install code # or code-insiders
echo "{ \"sync.gist\": \"$CODE_SETTINGS_GIST\", \"sync.autoDownload\": true, \"sync.autoUpload\": true, \"sync.quietSync\": true }" > "$HOME/.config/Code/User/settings.json"
code --install-extension dart-code.flutter --force
code --install-extension shan.code-settings-sync --force
sudo apt-get -y install jq
tmp=$(mktemp)
jq ".token = \"$CODE_SETTINGS_TOKEN\"" "$HOME/.config/Code/User/syncLocalSettings.json" > "$tmp" && mv "$tmp" "$HOME/.config/Code/User/syncLocalSettings.json"
code
# Flutter
echo
echo "=========================================================================="
echo "Setting up Flutter from GitHub (master)"
echo "See https://flutter.dev/docs/development/tools/sdk/releases for more info."
echo
git clone -b master https://github.com/flutter/flutter.git
./flutter/bin/flutter --version
sudo apt-get -y install lib32stdc++6
PATH="$PATH:$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin"
PATH_CHANGES+='$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin'
# Android SDK and tools
echo
echo "=========================================================="
echo "Setting up the Android SDK (without Android Studio) 4333796"
echo "See https://flutter.dev/docs/get-started/install/chromeos"
echo "and https://developer.android.com/studio/#downloads"
echo
sudo apt-get -y install default-jre
sudo apt-get -y install default-jdk
mkdir android && cd $_
export ANDROID_HOME="$HOME/android"
echo 'export ANDROID_HOME="$HOME/android"' >> "$HOME/.profile"
wget 'https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip'
unzip sdk-tools-linux*
rm "sdk-tools-linux-4333796.zip"
PATH="$PATH:$ANDROID_HOME/tools/bin:$ANDROID_HOME/tools"
PATH_CHANGES+=':$ANDROID_HOME/tools/bin:$ANDROID_HOME/tools'
# Squelches a repeated warning
touch "$HOME/.android/repositories.cfg"
yes | sdkmanager --licenses
sdkmanager "build-tools;28.0.3" "emulator" "tools" "platform-tools" "platforms;android-28" "extras;google;google_play_services" "extras;google;webdriver" "system-images;android-28;google_apis_playstore;x86_64"
PATH="$PATH:$ANDROID_HOME/platform-tools"
PATH_CHANGES+=':$ANDROID_HOME/platform-tools'
cd ..
# Node and npm (via nvm)
echo
echo "======================================================================"
echo "Installing Node and npm via Node Version Manager (nvm) 0.34.0"
echo "See https://github.com/nvm-sh/nvm/blob/master/README.md for more info."
echo
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
source ~/.bashrc
nvm install node
# Firebase tools
npm install -g firebase-tools
# Anaconda data science kit. Includes pip and jupyter for python 3.
echo
echo "==========================="
echo "Installing Anaconda3"
echo
cd "$HOME"
curl -s "https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh" -o ~/anaconda.sh
bash ~/anaconda.sh -b -p $HOME/anaconda
rm ~/anaconda.sh
PATH="$PATH:$HOME/anaconda/bin:$HOME/anaconda/condabin"
PATH_CHANGES+=':$HOME/anaconda/bin:$HOME/anaconda/condabin'
# PyCharm
echo
echo "==========================="
echo "Installing PyCharm"
echo
cd "$HOME"
wget https://download.jetbrains.com/python/pycharm-community-2019.1.3.tar.gz -O pycharm.tar.gz
tar xvf pycharm.tar.gz
rm pycharm.tar.gz
PATH="$PATH:$HOME/pycharm/bin"
PATH_CHANGES+=':$HOME/pycharm/bin'
echo '[Desktop Entry]' >> "$HOME/.local/share/applications/pycharm.desktop"
echo 'Type=Application' >> "$HOME/.local/share/applications/pycharm.desktop"
echo 'Name=PyCharm' >> "$HOME/.local/share/applications/pycharm.desktop"
echo "Exec=$HOME/pycharm/bin/pycharm.sh" >> "$HOME/.local/share/applications/pycharm.desktop"
echo "Icon=$HOME/pycharm/bin/pycharm.png" >> "$HOME/.local/share/applications/pycharm.desktop"
echo 'Terminal=false' >> "$HOME/.local/share/applications/pycharm.desktop"
sudo update-desktop-database
# Finishing up
echo "PATH=\"$PATH_CHANGES:\$PATH\"" >> "$HOME/.profile"
echo 'alias la="ls -a"' >> "$HOME/.profile"
echo 'alias ll="ls -la"' >> "$HOME/.profile"
ln -s /mnt/chromeos/MyFiles/Downloads/ ~/Downloads
flutter doctor
echo
echo "Setup complete, restart your terminal session or source ~/.profile."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment