5
0
Fork 0
mirror of https://codeberg.org/Computertruhe/Setup-Skripte.git synced 2025-06-28 11:26:18 +02:00

Rewrite script for OEM installation. Closes #23 (#25)

Do everything as root. For OEM installation

Inform user about cleanup

Co-authored-by: ml <ml@visu.li>
Reviewed-by: stefan230 <stefan230@noreply.codeberg.org>
Reviewed-by: York-Simon Johannsen <yosijo@noreply.codeberg.org>
This commit is contained in:
ml 2020-02-13 21:12:20 +01:00
parent 43a1d2b5dd
commit b796931d4f

View file

@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# execute self with sudo if user is not root
[[ $UID -ne 0 ]] && exec sudo ./"$0"
### ###
# Set variables # Set variables
### ###
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
DPKG_CFG_FRAGMENT=/etc/dpkg/dpkg.cfg.d/non-interactive DPKG_CFG_FRAGMENT=/etc/dpkg/dpkg.cfg.d/non-interactive
# Color of prefix (>>>) to distinguish user and root echos
color_prefix=32 # green
# Linux distro # Linux distro
script_distro='Linux Mint 19.x' script_distro='Linux Mint 19.x'
@ -88,13 +88,10 @@ packages=(
### ###
# Functions # Functions
### ###
is_root() {
[[ $UID -eq 0 ]]
}
# $*: message to echo # $*: message to echo
e() { e() {
printf "\e[%sm>>>\e[0m %s\n" "$color_prefix" "$*" printf "\e[31m>>>\e[0m %s\n" "$*"
} }
# It's a pain to stop (ctrl+c, kill) execution with all the Python applications # It's a pain to stop (ctrl+c, kill) execution with all the Python applications
@ -106,8 +103,8 @@ handle_signal() {
# always executed on shell exit regardless of reason. for cleanup tasks # always executed on shell exit regardless of reason. for cleanup tasks
handle_exit() { handle_exit() {
# Remove temporary dpkg cfg if root e "Finales Cleanup wird durchgeführt..."
is_root && rm -f "$DPKG_CFG_FRAGMENT" rm -f "$DPKG_CFG_FRAGMENT"
} }
trap handle_signal SIGINT SIGTERM trap handle_signal SIGINT SIGTERM
@ -118,16 +115,26 @@ pkg() {
} }
### ###
# Root setup # Greeting
### ###
if is_root; then echo "\
color_prefix=31 # red #####################################
if [[ $1 != "root-setup" ]]; then # Computertruhe-Installationsskript #
e "Dieses Script sollte nicht direkt als Root ausgeführt werden!" >&2 #####################################
e "Privilegien werden automatisch eskaliert sobald es notwendig ist." >&2
exit 1
fi
###
# Maintainer: Computertruhe e. V.
# Website: https://computertruhe.de/
# Version: 0.2.0
# Repo: https://codeberg.org/Computertruhe/computertruhe-setup
# Distro: ${script_distro}
###
"
e "Starte initiales Setup für Rechner mit frisch installiertem '${script_distro}' ..."
###
# Automatic installation
###
# place temporary dpkg configurations to ensure non-interactive upgrade # place temporary dpkg configurations to ensure non-interactive upgrade
cat <<'DPKG' >"$DPKG_CFG_FRAGMENT" cat <<'DPKG' >"$DPKG_CFG_FRAGMENT"
force-confold force-confold
@ -164,42 +171,27 @@ DPKG
apt clean --yes --quiet apt clean --yes --quiet
apt autoremove --yes --quiet apt autoremove --yes --quiet
e "Root Setup abgeschlossen." # https://askubuntu.com/questions/1037553/how-to-configure-a-dconf-key-globally-across-all-user-accounts#1037557
# It's very important to exit here. We don't want root past this point! # https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/desktop_migration_and_administration_guide/custom-default-values-system-settings
exit e "Tastatur- und Desktopoptionen werden angepasst"
fi mkdir -vp /etc/dconf/{profile,db/local.d}
### cat <<'EOF' > /etc/dconf/profile/user
# Greeting user-db:user
### system-db:local
echo "\ EOF
#####################################
# Computertruhe-Installationsskript #
#####################################
### cat <<'EOF' > /etc/dconf/db/local.d/00-keyboard-layout
# Maintainer: Computertruhe e. V. [org/gnome/libgnomekbd/keyboard]
# Website: https://computertruhe.de/ layouts=['de', 'ara', 'ir']
# Version: 0.2.0
# Repo: https://codeberg.org/Computertruhe/computertruhe-setup
# Distro: ${script_distro}
###
"
e "Starte initiales Setup für Rechner mit frisch installiertem '${script_distro}' ..."
### [org/cinnamon/desktop/interface]
# Automatic installation keyboard-layout-show-flags=false
### keyboard-layout-use-upper=true
e "Script wird als Root ausgeführt für privilegierte Aufgaben" keyboard-layout-prefer-variant-names=true
sudo ./"$0" root-setup EOF
e "Richte arabisches und persisches Tastatur-Layout ein..." dconf update
gsettings set org.gnome.libgnomekbd.keyboard layouts "['de', 'ara', 'ir']"
e "Ändere Anzeigeoptionen für die Tastatur auf die richtigen Werte..."
gsettings set org.cinnamon.desktop.interface keyboard-layout-show-flags false
gsettings set org.cinnamon.desktop.interface keyboard-layout-use-upper true
gsettings set org.cinnamon.desktop.interface keyboard-layout-prefer-variant-names true
### ###
# Finalisation # Finalisation