Skip to content

Instantly share code, notes, and snippets.

@sli
Last active May 15, 2022 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sli/904b5a95b00c7d5a63f88f1e70f79c7f to your computer and use it in GitHub Desktop.
Save sli/904b5a95b00c7d5a63f88f1e70f79c7f to your computer and use it in GitHub Desktop.
Automated Chatterino install.
#!/bin/bash
# This script adapted from the compilation guide here:
# https://github.com/Chatterino/chatterino2/blob/master/BUILDING_ON_LINUX.md
# Install dependencies, including a library required on RasPi/ARM Linux that is
# not listed in the compilation docs (libatomic)
sudo apt install -y qttools5-dev qtmultimedia5-dev libqt5svg5-dev libboost-dev \
libssl-dev libboost-system-dev libboost-filesystem-dev cmake g++ \
libatomic-ops-dev
# Clone the project and switch to the latest release version
# (v2.3.5 as of this writing). If this step has already been done,
# it will be pulled instead of cloned.
if [ -d "chatterino2" ]; then
cd chatterino2
git config pull.rebase false
git pull origin tags/v2.3.5
else
git clone --recurse-submodules https://github.com/Chatterino/chatterino2.git
cd chatterino2
git checkout tags/v2.3.5
fi
# Increase the swap file size during this operation if needed, otherwise the next
# step takes damn near forever.
DEFAULT_SWAP_SIZE=$(sed -n '/^CONF_SWAPSIZE=/ {s///p;q;}' /etc/dphys-swapfile)
if [ $DEFAULT_SWAP_SIZE -lt 1024 ]; then
echo
echo
echo "*******************"
echo "Increasing swap file size for the next step. This will take a moment..."
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=${DEFAULT_SWAP_SIZE}/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
fi
# Compile
mkdir -p build && cd build
qmake .. && make
# Revert swap file size change if needed.
if [ $DEFAULT_SWAP_SIZE -lt 1024 ]; then
echo
echo "*******************"
echo "Reverting swap file size. This will take a moment..."
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=1024/CONF_SWAPSIZE=${DEFAULT_SWAP_SIZE}/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
fi
# Install if the compilation step succeeded
if [ $? -eq 0 ]; then
echo
echo "*******************"
echo "Compilation succeeded! You may be asked for your password (for the Pi,"
echo "not for Twitch) so that Chatterino can complete installation."
read -p "Press Enter to continue." < /dev/tty
echo
# Installs chatterino ins a standard location
sudo make install
# Adds chatterino to LXDE's autorun file if it isn't already there.
echo
if [ -z $(grep "@chatterino" /etc/xdg/lxsession/LXDE-pi/autostart) ]; then
echo "Adding chatterino to autorun."
echo "@chatterino" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart >/dev/null
else
echo "Chatterino already added to autorun config."
fi
echo
echo "*******************"
echo "Launching Chatterino so it can be configured. After setting up"
echo "login (and whatever else), reboot and everything will be"
echo "ready to go."
echo "Note: This will be skipped if running in SSH. Simply configure"
echo "Chatterino in the desktop environment after rebooting."
read -p "Press Enter to continue." < /dev/tty
echo
# Checks whether or not this is an SSH session and only runs
# chatterino if it is not.
if [ -z $SSH_TTY ]; then
chatterino
fi
else
echo
echo "*******************"
echo "Compilation failed. Cannot continue."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment