#!/bin/bash
# SPDX-Version: 3.0
# SPDX-CreationInfo: 2025-05-05; WEIDNER, Marc S.; <msw@coresecret.dev>
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.live.builder.git
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
# SPDX-PackageName: CISS.debian.live.builder
# SPDX-Security-Contact: security@coresecret.eu
set -C -e -u -o pipefail

printf "\e[95m++++ ++++ ++++ ++++ ++++ ++++ ++ 🧪 '%s' starting ... \e[0m\n" "${0}"
# sleep 1

cd /root

repo="ryanoasis/nerd-fonts"
latest_release=$(curl -s "https://api.github.com/repos/${repo}/releases/latest" | jq -r .tag_name)
download_url="https://github.com/${repo}/releases/download/${latest_release}/Hack.zip"

wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | tee /etc/apt/sources.list.d/gierens.list
chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list

apt-get update -y
apt-get install -y eza

git clone https://github.com/eza-community/eza-themes.git
mkdir -p /root/.config/eza

cat << 'EOF' >| "/root/eza-themes/themes/centurion.yml"
colourful: true

filekinds:
  normal: {foreground: Default}
  directory: {foreground: Purple, is_bold: true}
  symlink: {foreground: Cyan}
  pipe: {foreground: Yellow}
  block_device: {foreground: Yellow, is_bold: true}
  char_device: {foreground: Yellow, is_bold: true}
  socket: {foreground: Red, is_bold: true}
  special: {foreground: Yellow}
  executable: {foreground: Green, is_bold: true}
  mount_point: {foreground: Purple, is_bold: true, is_underlined: true}

perms:
  user_read: {foreground: Yellow, is_bold: true}
  user_write: {foreground: Red, is_bold: true}
  user_execute_file: {foreground: Green, is_bold: true, is_underlined: true}
  user_execute_other: {foreground: Green, is_bold: true}
  group_read: {foreground: Yellow}
  group_write: {foreground: Red}
  group_execute: {foreground: Green}
  other_read: {foreground: Yellow}
  other_write: {foreground: Red}
  other_execute: {foreground: Green}
  special_user_file: {foreground: Purple}
  special_other: {foreground: Purple}
  attribute: {foreground: Default}

size:
  major: {foreground: Green, is_bold: true}
  minor: {foreground: Green}
  number_byte: {foreground: Green, is_bold: true}
  number_kilo: {foreground: Green, is_bold: true}
  number_mega: {foreground: Green, is_bold: true}
  number_giga: {foreground: Green, is_bold: true}
  number_huge: {foreground: Green, is_bold: true}
  unit_byte: {foreground: Green}
  unit_kilo: {foreground: Green}
  unit_mega: {foreground: Green}
  unit_giga: {foreground: Green}
  unit_huge: {foreground: Green}

users:
  user_you: {foreground: Yellow, is_bold: true}
  user_root: {foreground: Default}
  user_other: {foreground: Default}
  group_yours: {foreground: Yellow, is_bold: true}
  group_other: {foreground: Default}
  group_root: {foreground: Default}

links:
  normal: {foreground: Red, is_bold: true}
  multi_link_file: {foreground: Red, background: Yellow}

git:
  new: {foreground: Green}
  modified: {foreground: Blue}
  deleted: {foreground: Red}
  renamed: {foreground: Yellow}
  typechange: {foreground: Purple}
  ignored: {foreground: Default, is_dimmed: true}
  conflicted: {foreground: Red}

git_repo:
  branch_main: {foreground: Green}
  branch_other: {foreground: Yellow}
  git_clean: {foreground: Green}
  git_dirty: {foreground: Yellow}

security_context:
  colon: {foreground: Default, is_dimmed: true}
  user: {foreground: Blue}
  role: {foreground: Green}
  typ: {foreground: Yellow}
  range: {foreground: Cyan}

file_type:
  image: {foreground: Purple}
  video: {foreground: Purple, is_bold: true}
  music: {foreground: Cyan}
  lossless: {foreground: Cyan, is_bold: true}
  crypto: {foreground: Green, is_bold: true}
  document: {foreground: Green}
  compressed: {foreground: Red}
  temp: {foreground: White}
  compiled: {foreground: Yellow}
  build: {foreground: Yellow, is_bold: true, is_underlined: true}
  source: {foreground: Yellow, is_bold: true}

punctuation: {foreground: DarkGray, is_bold: true}
date: {foreground: Cyan}
inode: {foreground: Purple}
blocks: {foreground: Cyan}
header: {foreground: White, is_bold: true, is_underlined: true}
octal: {foreground: Purple}
flags: {foreground: Default}

symlink_path: {foreground: Cyan}
control_char: {foreground: Red}
broken_symlink: {foreground: Red}
broken_path_overlay: {foreground: Default, is_underlined: true}
EOF

chmod 0644 "/root/eza-themes/themes/centurion.yml"
ln -sf "/root/eza-themes/themes/centurion.yml" /root/.config/eza/theme.yml

mkdir -p /tmp/nerd
mkdir -p /root/.local/share/fonts
wget --no-clobber --https-only --secure-protocol=TLSv1_3 -P /tmp/nerd "${download_url}"
unzip /tmp/nerd/Hack.zip -d /root/.local/share/fonts
fc-cache -fv
rm -rf /tmp/nerd

unset repo latest_release download_url

printf "\e[92m++++ ++++ ++++ ++++ ++++ ++++ ++ ✅ '%s' applied successfully. \e[0m\n" "${0}"
# sleep 1

exit 0
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
