From aa1b3f8b9e7beedd3534b121ea1ed2460549347e Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 8 Sep 2023 23:42:28 +0400 Subject: [PATCH] goldendict --- src/bookworm | 291 --------------------------------------------- src/bullseye | 330 --------------------------------------------------- src/main | 284 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 282 insertions(+), 623 deletions(-) delete mode 100755 src/bookworm delete mode 100755 src/bullseye diff --git a/src/bookworm b/src/bookworm deleted file mode 100755 index 07d4b87..0000000 --- a/src/bookworm +++ /dev/null @@ -1,291 +0,0 @@ -#!/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=( - bash-completion - vim git wget curl - htop jq unzip - python3-pip - gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0 gnome-system-monitor - tilix wl-clipboard - nextcloud-desktop nautilus-nextcloud nautilus-share nautilus-image-converter - cups hplip - ttf-mscorefonts-installer -) - -## MAIN -## --------- - -[ $(id -u) -eq 0 ] && echo 'normal user required' && exit -1 - -echo "# configure apt sources to the mithril's" -echo "========================================" -if grep cdrom /etc/apt/sources.list; then - echo "deb http://debian.mithril.re/debian bookworm main contrib non-free-firmware" | sudo tee /etc/apt/sources.list - echo "deb http://debian.mithril.re/debian bookworm-updates main contrib non-free-firmware" | sudo tee -a /etc/apt/sources.list - echo "deb http://debian.mithril.re/debian-security bookworm-security main contrib non-free-firmware" | sudo tee -a /etc/apt/sources.list - sudo apt update - sudo apt autoremove -y -else - 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 -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 "## 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 - - -firefox_lang=$(echo $LANG | cut -d_ -f1) -[[ $firefox_lang == "en" ]] && firefox_lang="en-US" -echo $firefox_lang - - -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=$firefox_lang" | 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 -sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ - -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 net-show-text false -gsettings set org.gnome.shell.extensions.system-monitor net-graph-width 40 -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.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 </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 hplip - ttf-mscorefonts-installer -) - -## MAIN -## --------- - -[ $(id -u) -eq 0 ] && echo 'normal user required' && exit -1 - -echo "# configure apt sources to the mithril's" -echo "========================================" - -if ! grep -q debian.mithril.re /etc/apt/sources.list; then - echo "deb http://debian.mithril.re/debian bullseye main contrib non-free" | sudo tee /etc/apt/sources.list - echo "deb http://debian.mithril.re/debian bullseye-updates main contrib non-free" | sudo tee -a /etc/apt/sources.list - echo "deb http://debian.mithril.re/debian-security/ bullseye-security main contrib non-free" | sudo tee -a /etc/apt/sources.list - sudo apt update - sudo apt autoremove -y -else - 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 -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 -sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ # recompile each time - -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.netspeed use-bytes 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 </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=( + bash-completion + vim git wget curl + htop jq unzip + python3-pip + gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0 gnome-system-monitor + tilix wl-clipboard + cups hplip + ttf-mscorefonts-installer + nautilus-share nautilus-image-converter + goldendict +) + +## MAIN +## --------- + +[ $(id -u) -eq 0 ] && echo 'normal user required' && exit -1 + +echo "# configure apt sources to the mithril's" +echo "========================================" +if grep cdrom /etc/apt/sources.list; then + echo "deb http://debian.mithril.re/debian bookworm main contrib non-free-firmware" | sudo tee /etc/apt/sources.list + echo "deb http://debian.mithril.re/debian bookworm-updates main contrib non-free-firmware" | sudo tee -a /etc/apt/sources.list + echo "deb http://debian.mithril.re/debian-security bookworm-security main contrib non-free-firmware" | sudo tee -a /etc/apt/sources.list + sudo apt update + sudo apt autoremove -y +else + 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 +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 "## 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 + +firefox_lang=$(echo $LANG | cut -d_ -f1) +[[ $firefox_lang == "en" ]] && firefox_lang="en-US" +echo $firefox_lang + +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=$firefox_lang" | 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 +sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ + +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 net-show-text false +gsettings set org.gnome.shell.extensions.system-monitor net-graph-width 40 +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.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 <