140 lines
5.1 KiB
Bash
Executable file
140 lines
5.1 KiB
Bash
Executable file
#!/bin/bash -x
|
|
|
|
|
|
# This script configures converted Lenovo N42 ChromeBooks loaded with Linux Mint XFCE.
|
|
|
|
|
|
function configureMachine() {
|
|
|
|
# Update everything.
|
|
sudo apt-get -y update
|
|
sudo apt-get -y upgrade
|
|
sudo apt-get -y dist-upgrade
|
|
sudo apt-get -y autoremove
|
|
|
|
# Tools for us.
|
|
sudo apt-get -y install mc joe openssh-server byobu
|
|
|
|
# Tools for this script.
|
|
sudo apt-get -y install shc git build-essential
|
|
|
|
# Remove unnwanted software.
|
|
sudo apt-get -y purge evolution-data-server
|
|
|
|
# Disable screensaver/blanking/dimming.
|
|
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-enabled -t bool -s false --create
|
|
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-ac -t int -s 0 --create
|
|
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/brightness-on-ac -t int -s 9 --create
|
|
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/brightness-level-on-ac -t int -s 100 --create
|
|
|
|
# Change clock format.
|
|
plugin_name="$( xfconf-query -c xfce4-panel -p /plugins -lv | grep -E '/plugins/plugin-[0-9]+.*clock' | cut -d" " -f '1-1' )"
|
|
xfconf-query -c xfce4-panel -p ${plugin_name}/digital-time-format -t string -s '%l:%M:%S %P' --create
|
|
xfconf-query -c xfce4-panel -p ${plugin_name}/digital-date-format -t string -s '%b %d, %Y' --create
|
|
|
|
# Disable unneeded desktop services.
|
|
mkdir -p /home/${USER}/.config/autostart
|
|
declare -a disable=("light-locker" "mintreport" "mintupdate" "mintwelcome" "nvidia-prime" "sticky" "warpinator-autostart")
|
|
for i in "${disable[@]}"; do
|
|
echo -e "[Desktop Entry]\nHidden=True\n" > /home/${USER}/.config/autostart/${i}.desktop
|
|
done
|
|
|
|
# Install Moonlight.
|
|
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
sudo flatpak install -y flathub com.moonlight_stream.Moonlight
|
|
echo -e '#!/bin/bash\nflatpak run com.moonlight_stream.Moonlight\n' > /home/${USER}/moonlight.sh
|
|
chmod +x /home/${USER}/moonlight.sh
|
|
|
|
# Configure Moonlight.
|
|
flatpak run com.moonlight_stream.Moonlight quit # This generates the ~/.var/ structure for the config.
|
|
wget https://forge.duensing.digital/Duensing_Digital/chromebook-linux/raw/branch/master/Moonlight.conf
|
|
mv Moonlight.conf "/home/${USER}/.var/app/com.moonlight_stream.Moonlight/config/Moonlight Game Streaming Project/."
|
|
|
|
# Add icon to desktop
|
|
cat <<- ICON > /home/${USER}/Desktop/Moonlight.desktop
|
|
[Desktop Entry]
|
|
Version=1.0
|
|
Type=Application
|
|
Name=Moonlight
|
|
Comment=Game Streaming Client
|
|
Exec=/home/${USER}/moonlight.sh
|
|
Icon=network-idle
|
|
Path=/home/${USER}
|
|
Terminal=false
|
|
StartupNotify=false
|
|
ICON
|
|
chmod +x "/home/${USER}/Desktop/Moonlight.desktop"
|
|
gio set -t string "/home/${USER}/Desktop/Moonlight.desktop" metadata::xfce-exe-checksum "$(sha256sum "/home/${USER}/Desktop/Moonlight.desktop" | awk '{print $1}')"
|
|
|
|
# Make Moonlight run on startup.
|
|
#ln -s /home/${USER}/Desktop/Moonlight.desktop /home/${USER}/.config/autostart/.
|
|
|
|
# Create auto-update scripts. ***TODO*** This should probably do the root updates first.
|
|
cat <<- UPDATE > /home/${USER}/unsafe-update.sh
|
|
#!/bin/bash
|
|
###
|
|
### THIS IS TOTALLY NOT A SECURE WAY TO UPDATE ANYTHING! ###
|
|
###
|
|
echo "Waiting for network."
|
|
while [ "\$(hostname -I)" = "" ]; do
|
|
sleep 1
|
|
done
|
|
if [[ "\${1}x" == "rootx" ]]; then
|
|
if [[ -f unsafe-update-payload.sh ]]; then
|
|
source unsafe-update-payload.sh
|
|
unsafeUpdateRoot 2>&1 | tee -a /home/\${USER}/unsafe-update.log
|
|
fi
|
|
else
|
|
if [[ -f unsafe-update-payload.sh ]]; then
|
|
rm -f unsafe-update-payload.sh
|
|
fi
|
|
wget https://forge.duensing.digital/Duensing_Digital/chromebook-linux/raw/branch/master/unsafe-update-payload.sh 2>&1 | tee /home/\${USER}/unsafe-update.log
|
|
if [[ -f unsafe-update-payload.sh ]]; then
|
|
source unsafe-update-payload.sh
|
|
unsafeUpdate 2>&1 | tee -a /home/\${USER}/unsafe-update.log
|
|
fi
|
|
./unsafe-update-root.sh.x root
|
|
fi
|
|
UPDATE
|
|
chmod +x /home/${USER}/unsafe-update.sh
|
|
# Compile root update script so it can be suid.
|
|
shc -S -f /home/${USER}/unsafe-update.sh
|
|
mv -f /home/${USER}/unsafe-update.sh.x /home/${USER}/unsafe-update-root.sh.x
|
|
sudo chown root:root /home/${USER}/unsafe-update-root.sh.x
|
|
sudo chmod u+s /home/${USER}/unsafe-update-root.sh.x
|
|
sudo chmod a-w /home/${USER}/unsafe-update.sh /home/${USER}/unsafe-update-root.sh.x
|
|
rm /home/${USER}/unsafe-update.sh.x.c
|
|
|
|
# Add auto update icon to autostart.
|
|
cat <<- ICON > /home/${USER}/.config/autostart/AutoUpdate.desktop
|
|
[Desktop Entry]
|
|
Version=1.0
|
|
Type=Application
|
|
Name=Auto Update
|
|
Comment=Duensing Digital Client Auto Update
|
|
Exec=/home/${USER}/unsafe-update.sh
|
|
Icon=mintupdate-type-backport
|
|
Path=/home/${USER}
|
|
Terminal=true
|
|
StartupNotify=false
|
|
ICON
|
|
|
|
# Install keyboard remapper.
|
|
if [[ ! -d /home/${USER}/chromebook-linux ]]; then
|
|
git clone https://forge.duensing.digital/Duensing_Digital/chromebook-linux.git /home/${USER}/chromebook-linux
|
|
fi
|
|
cd /home/${USER}/chromebook-linux
|
|
./install-keyboard-map.sh
|
|
|
|
# Reboot!
|
|
sudo reboot
|
|
}
|
|
|
|
|
|
if [[ ${EUID} -eq 0 ]]; then
|
|
echo "${0} must NOT be run as root."
|
|
exit 1
|
|
fi
|
|
|
|
# All the config is in a function so we can stream this script from forge.duensing.digital.
|
|
configureMachine 2>&1 | tee /home/${USER}/install.log
|