#!/bin/bash ## FUNCTIONS ## --------- function trap_error() { error_code=$1 error_line=$2 printf "\nEXIT #${error_code} due to error at line ${error_line} : \n-----------------------------------------\n" sed "${error_line}q;d" $0 echo exit $error_code } function runVoid() { trap - ERR local COMMAND="$@" bash -c "${COMMAND}" >/dev/null 2>&1 runVoidError=$? trap 'trap_error $? $LINENO' ERR } function askConfirmation() { case "$1" in y | Y | yes | YES) QUESTION="(Y/n)?" DEFAULT=0 ;; *) QUESTION="(y/N)?" DEFAULT=1 ;; esac read -p "$QUESTION : " choice case "$choice" in y | Y | yes | YES) return 0 ;; #true n | no | N | NO) return 1 ;; #false *) return $DEFAULT ;; esac } # Variables and constants ## --------- BASEDIR=/opt/debian-gnome ALLOWED_USERS=$(id -un) #CUSTOMIZE if needed! REQUIRED_PACKAGES=( vim git wget python3 python3-pip gir1.2-gtop-2.0 htop tilix jq unzip tilix bash-completion nextcloud-desktop nautilus-nextcloud nautilus-share nautilus-image-converter wl-clipboard cups ) ## MAIN ## --------- [ $(id -u) -eq 0 ] && echo 'normal user required' && exit -1 echo "# updating repositories" echo "===================" if [[ $(date --date='-12 hours' +%s) -gt $(date -d "$(stat -c %y /var/lib/apt/lists/partial)" +%s) ]]; then sudo apt update sudo apt autoremove -y else echo "repositories recently updated!" fi echo "# required packages" echo "===================" for package in ${REQUIRED_PACKAGES[@]}; do runVoid dpkg-query --status $package if [ $runVoidError -ne 0 ]; then echo -n "installing package <$package> ... " sudo DEBIAN_FRONTEND=noninteractive apt install -y $package echo "DONE" fi done #echo "## remove hplip annoyance" #echo "=========================" #if [[ -f /etc/xdg/autostart/hplip-systray.desktop ]]; then # sudo rm /etc/xdg/autostart/hplip-systray.desktop #else # echo "hplip annoyance already removed!" #fi echo "## debian-bash" echo "==============" if [[ ! -d /opt/debian-bash ]]; then curl https://git.artcode.re/pvincent/debian-bash/raw/branch/master/install.sh | sudo bash -s -- --host else echo "debian-bash already installed!" fi echo "## openssh-server" echo "=================" PGKNAME='openssh-server' runVoid dpkg-query --status $PGKNAME if [ $runVoidError -ne 0 ]; then set -e sudo apt install -y $PGKNAME sudo /opt/debian-bash/tools/append_or_replace "^#\?PermitRootLogin.*$" "PermitRootLogin no" /etc/ssh/sshd_config sudo /opt/debian-bash/tools/append_or_replace "^#\?PasswordAuthentication.*$" "PasswordAuthentication no" /etc/ssh/sshd_config sudo /opt/debian-bash/tools/append_or_replace "^#\?AllowUsers.*$" "AllowUsers $ALLOWED_USERS" /etc/ssh/sshd_config sudo systemctl restart sshd set +e else echo "${PGKNAME} already installed!" fi echo "## allow hotplug eth0" echo "=====================" if [[ $(grep 'auto eth0' /etc/network/interfaces.d/setup) ]]; then sudo /opt/debian-bash/tools/append_or_replace "^auto eth0.*$" "allow-hotplug eth0" /etc/network/interfaces.d/setup else echo "allow-hotplug already set up" fi echo "## firefox latest" echo "=================" if [[ ! /usr/local/bin/firefox -ef /opt/firefox/firefox ]]; then set -e cd /tmp wget $(curl 'https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US' | cut -d '"' -f2) -O firefox-latest.tar.bz2 sudo mkdir /opt/firefox -p sudo chown $USER /opt/firefox tar -xjf firefox-latest.tar.bz2 -C /opt cat < already installed!" fi done echo "# gnome extra settings" echo "======================" gsettings set org.gnome.shell.extensions.system-monitor show-tooltip true gsettings set org.gnome.shell.extensions.system-monitor cpu-show-text false gsettings set org.gnome.shell.extensions.system-monitor cpu-graph-width 60 gsettings set org.gnome.shell.extensions.system-monitor memory-display false gsettings set org.gnome.shell.extensions.system-monitor net-display false gsettings set org.gnome.shell.extensions.system-monitor disk-display false gsettings set org.gnome.shell.extensions.system-monitor icon-display false gsettings set org.gnome.shell.extensions.netspeed show-sum true gsettings set org.gnome.shell.extensions.dash-to-dock dock-fixed true gsettings set org.gnome.shell.extensions.dash-to-dock apply-custom-theme true gsettings set org.gnome.shell.extensions.dash-to-dock extend-height true gsettings set org.gnome.shell.extensions.dash-to-dock multi-monitor true echo "# firefox addons" echo "================" declare -A FIREFOX_ADDONS FIREFOX_ADDONS['uBlock0@raymondhill.net']="3740966/ublock_origin-1.34.0-an+fx.xpi" FIREFOX_ADDONS['fr-dicollecte@dictionaries.addons.mozilla.org']='3581786/dictionnaire_francais-7.0b.xpi' FIREFOX_ADDONS['chrome-gnome-shell@gnome.org']='898030/gnome_shell_integration-10.1-an+fx-linux.xpi' FIREFOX_ADDONS['jid1-ZAdIEUB7XOzOJw@jetpack']='3741831/duckduckgo_privacy_essentials-2021.3.8-an+fx.xpi' mkdir -p /opt/firefox/distribution/extensions for addon_id in "${!FIREFOX_ADDONS[@]}"; do addon_part_url="${FIREFOX_ADDONS[$addon_id]}" addon_xpi="/opt/firefox/distribution/extensions/${addon_id}.xpi" if [[ ! -f "$addon_xpi" ]]; then echo -n "Firefox addon <$addon_id> installing ..." wget -q "https://addons.mozilla.org/firefox/downloads/file/${addon_part_url}" -O $addon_xpi echo DONE else echo "Firefox addon <$addon_id> already installed!" fi done echo "# Firefox default settings" echo "#=========================" if [[ ! -f /opt/firefox/firefox.cfg ]]; then cat <