From cb1e4934b5b7f3906209e85ee7348efaca9e3819 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sat, 19 Jul 2025 15:53:25 +0200 Subject: [PATCH] up ckeck installed --- bin/borg | Bin bin/guessfilename | 8 + initialization/check_installed.sh | 73 ++++++++ initialization/check_installed_in_history.sh | 167 ------------------- initialization/fast.sh | 126 +------------- 5 files changed, 90 insertions(+), 284 deletions(-) mode change 100644 => 100755 bin/borg create mode 100755 bin/guessfilename create mode 100755 initialization/check_installed.sh diff --git a/bin/borg b/bin/borg old mode 100644 new mode 100755 diff --git a/bin/guessfilename b/bin/guessfilename new file mode 100755 index 0000000..2306b8f --- /dev/null +++ b/bin/guessfilename @@ -0,0 +1,8 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from guessfilename import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/initialization/check_installed.sh b/initialization/check_installed.sh new file mode 100755 index 0000000..c0bf001 --- /dev/null +++ b/initialization/check_installed.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +echo "========== Checking installed programs and files =======" +source $HOME/Nextcloud/ressources/workflow_nextcloud/public_workflow/workflow_variables.sh + +# Check if apt-installed packages are present +echo "Checking apt-installed packages..." +PACKAGES="adduser ansible arp-scan automysqlbackup borgbackup calibre certbot curl docker docker-compose etckeeper eza fail2ban geeqie git gnupg htop jq meld nano ncdu nginx npm pandoc php-curl php-mysql php-xml php8.4 php8.4-fpm php8.4-xml python3 python3-pip python3-setuptools rbenv restic rsync smartmontools snapd sshfs syncthing testdisk texlive tig unattended-upgrades vrms zsh" + +MISSING_PACKAGES="" +for pkg in $PACKAGES; do + if ! dpkg -l | grep -q " $pkg "; then + MISSING_PACKAGES="$MISSING_PACKAGES $pkg" + fi +done + +if [ -n "$MISSING_PACKAGES" ]; then + echo -e "\e[31mThe following packages are missing:$MISSING_PACKAGES\e[0m" +else + echo "All apt packages are installed." +fi + +# Check if snap-installed packages are present +echo "Checking snap-installed packages..." +SNAP_PACKAGES="btop emacs" + +MISSING_SNAP_PACKAGES="" +for pkg in $SNAP_PACKAGES; do + if ! snap list | grep -q "$pkg"; then + MISSING_SNAP_PACKAGES="$MISSING_SNAP_PACKAGES $pkg" + fi +done + +if [ -n "$MISSING_SNAP_PACKAGES" ]; then + echo -e "\e[31mThe following snap packages are missing:$MISSING_SNAP_PACKAGES\e[0m" +else + echo "All snap packages are installed." +fi + +cd $WORKFLOW_PATH_PUBLIC/bin +# Check if AppImages are present +echo "Checking AppImages..." +if [ ! -f "$WORKFLOW_PATH_PUBLIC/bin/Nextcloud-3.16.6-x86_64.AppImage" ]; then + echo -e "\e[31m Nextcloud AppImage is missing.\e[0m" +fi + +if [ ! -f "$WORKFLOW_PATH_PUBLIC/bin/VeraCrypt-1.26.24-x86_64.AppImage" ]; then + echo -e "\e[31m VeraCrypt AppImage is missing.\e[0m" +fi + +if [ ! -f "$HOME/Nextcloud/ressources/workflow_nextcloud/secrets_vars.sh" ]; then + echo -e "\e[31m secret vars file is missing. $HOME/Nextcloud/ressources/workflow_nextcloud/secrets_vars.sh \e[0m" +fi + +# Check if configuration files are present in home directory +echo "Checking configuration files in home directory..." +# Note: .bash_custom_aliases is downloaded as .bash_aliases in fast.sh +CONFIG_FILES=".bash_aliases .bashrc .zshrc" + +MISSING_CONFIG_FILES="" +for file in $CONFIG_FILES; do + if [ ! -f "$HOME/$file" ]; then + MISSING_CONFIG_FILES="$MISSING_CONFIG_FILES $file" + fi +done + +if [ -n "$MISSING_CONFIG_FILES" ]; then + echo -e "\e[31mThe following configuration files are missing in your home directory:$MISSING_CONFIG_FILES\e[0m" +else + echo "All configuration files are present in your home directory." +fi + +echo "========== Check completed =======" diff --git a/initialization/check_installed_in_history.sh b/initialization/check_installed_in_history.sh index 4e199a9..e69de29 100644 --- a/initialization/check_installed_in_history.sh +++ b/initialization/check_installed_in_history.sh @@ -1,167 +0,0 @@ -#!/bin/bash - -# Script to search for installed packages in bash and zsh history -# It looks for installations via apt, apt-get, snap, pipx, pip, and npm - -# Define arrays to store package names -declare -a APT_PACKAGES=() -declare -a APTGET_PACKAGES=() -declare -a SNAP_PACKAGES=() -declare -a PIPX_PACKAGES=() -declare -a PIP_PACKAGES=() -declare -a NPM_PACKAGES=() - -# Function to extract package names from apt install commands -extract_apt_packages() { - local line="$1" - # Remove sudo and apt install/apt-get install part - local packages=$(echo "$line" | sed -E 's/^.*apt(-get)? install(-y)? //g') - # Split by spaces and add to array - for pkg in $packages; do - # Skip options that start with - - if [[ ! "$pkg" =~ ^- ]]; then - APT_PACKAGES+=("$pkg") - fi - done -} - -# Function to extract package names from apt-get install commands -extract_aptget_packages() { - local line="$1" - # Remove sudo and apt-get install part - local packages=$(echo "$line" | sed -E 's/^.*apt-get install(-y)? //g') - # Split by spaces and add to array - for pkg in $packages; do - # Skip options that start with - - if [[ ! "$pkg" =~ ^- ]]; then - APTGET_PACKAGES+=("$pkg") - fi - done -} - -# Function to extract package names from snap install commands -extract_snap_packages() { - local line="$1" - # Remove sudo and snap install part - local packages=$(echo "$line" | sed -E 's/^.*snap install //g') - # Split by spaces and add to array - for pkg in $packages; do - # Skip options that start with - - if [[ ! "$pkg" =~ ^- && ! "$pkg" =~ ^--classic$ ]]; then - SNAP_PACKAGES+=("$pkg") - fi - done -} - -# Function to extract package names from pipx install commands -extract_pipx_packages() { - local line="$1" - # Remove pipx install part - local packages=$(echo "$line" | sed -E 's/^.*pipx install //g') - # Split by spaces and add to array - for pkg in $packages; do - # Skip options that start with - - if [[ ! "$pkg" =~ ^- ]]; then - PIPX_PACKAGES+=("$pkg") - fi - done -} - -# Function to extract package names from pip install commands -extract_pip_packages() { - local line="$1" - # Remove pip/pip3 install part - local packages=$(echo "$line" | sed -E 's/^.*(pip|pip3) install //g') - # Split by spaces and add to array - for pkg in $packages; do - # Skip options that start with - - if [[ ! "$pkg" =~ ^- ]]; then - PIP_PACKAGES+=("$pkg") - fi - done -} - -# Function to extract package names from npm install commands -extract_npm_packages() { - local line="$1" - # Remove npm install part - local packages=$(echo "$line" | sed -E 's/^.*npm install(-g)? //g') - # Split by spaces and add to array - for pkg in $packages; do - # Skip options that start with - - if [[ ! "$pkg" =~ ^- ]]; then - NPM_PACKAGES+=("$pkg") - fi - done -} - -echo "Searching for installed packages in bash and zsh history..." - -# Parse bash history if it exists -if [ -f ~/.bash_history ]; then - echo "Parsing bash history..." - while IFS= read -r line; do - if [[ "$line" =~ apt\ install ]]; then - extract_apt_packages "$line" - elif [[ "$line" =~ apt-get\ install ]]; then - extract_aptget_packages "$line" - elif [[ "$line" =~ snap\ install ]]; then - extract_snap_packages "$line" - elif [[ "$line" =~ pipx\ install ]]; then - extract_pipx_packages "$line" - elif [[ "$line" =~ (pip|pip3)\ install ]]; then - extract_pip_packages "$line" - elif [[ "$line" =~ npm\ install ]]; then - extract_npm_packages "$line" - fi - done < ~/.bash_history -else - echo "Bash history file not found." -fi - -# Parse zsh history if it exists -if [ -f ~/.zsh_history ]; then - echo "Parsing zsh history..." - while IFS= read -r line; do - # ZSH history has a different format, we need to extract the command part - # Format is typically: : timestamp:0;command - cmd=$(echo "$line" | sed -E 's/^: [0-9]+:[0-9];(.*)$/\1/') - - if [[ "$cmd" =~ apt\ install ]]; then - extract_apt_packages "$cmd" - elif [[ "$cmd" =~ apt-get\ install ]]; then - extract_aptget_packages "$cmd" - elif [[ "$cmd" =~ snap\ install ]]; then - extract_snap_packages "$cmd" - elif [[ "$cmd" =~ pipx\ install ]]; then - extract_pipx_packages "$cmd" - elif [[ "$cmd" =~ (pip|pip3)\ install ]]; then - extract_pip_packages "$cmd" - elif [[ "$cmd" =~ npm\ install ]]; then - extract_npm_packages "$cmd" - fi - done < ~/.zsh_history -else - echo "ZSH history file not found." -fi - -# Display results -echo -e "\n=== Packages installed via apt ===" -printf '%s\n' "${APT_PACKAGES[@]}" | sort -u - -echo -e "\n=== Packages installed via apt-get ===" -printf '%s\n' "${APTGET_PACKAGES[@]}" | sort -u - -echo -e "\n=== Packages installed via snap ===" -printf '%s\n' "${SNAP_PACKAGES[@]}" | sort -u - -echo -e "\n=== Packages installed via pipx ===" -printf '%s\n' "${PIPX_PACKAGES[@]}" | sort -u - -echo -e "\n=== Packages installed via pip/pip3 ===" -printf '%s\n' "${PIP_PACKAGES[@]}" | sort -u - -echo -e "\n=== Packages installed via npm ===" -printf '%s\n' "${NPM_PACKAGES[@]}" | sort -u - -echo -e "\nSearch complete." \ No newline at end of file diff --git a/initialization/fast.sh b/initialization/fast.sh index f038a56..d472857 100644 --- a/initialization/fast.sh +++ b/initialization/fast.sh @@ -3,141 +3,33 @@ sudo apt update -y sudo apt upgrade -y sudo apt autoremove -y -# Liste des programmes à installer avec apt -APT_PACKAGES=( - ansible - python3-pip - arp-scan - borgbackup - curl - docker - docker-compose - etckeeper - git - gnupg - jq - meld - nano - ncdu - nginx - restic - npm - pandoc - php8.4 - python3 - python3-pip - tig - zsh - testdisk - texlive - rbenv - htop - python3-setuptools - automysqlbackup - certbot - smartmontools - fail2ban - snapd - unattended-upgrades - php8.4-fpm - php-xml - php-mysql - rsync - php8.4-xml - php-curl - vrms - syncthing - sshfs - geeqie - calibre - adduser - snapd - borgbackup - eza - adduser -) - -# Fonction pour vérifier l'installation des programmes -verify_installation() { - echo "Vérification de l'installation des programmes..." - local missing_packages=() - - for package in "${APT_PACKAGES[@]}"; do - # Vérification simplifiée - on pourrait améliorer avec dpkg -l | grep -q "^ii.*$package" - if ! command -v "$package" &> /dev/null && ! dpkg -l | grep -q "$package"; then - missing_packages+=("$package") - fi - done - - if [ ${#missing_packages[@]} -eq 0 ]; then - echo "✅ Tous les programmes ont été installés avec succès." - else - echo "❌ Les programmes suivants n'ont pas été installés correctement:" - for package in "${missing_packages[@]}"; do - echo " - $package" - done - fi -} - -# Fonction pour vérifier l'existence des alias -verify_aliases() { - echo "Vérification des alias..." - local missing_aliases=() - - # Vérification de l'alias gst - if ! alias gst &> /dev/null; then - missing_aliases+=("gst") - fi - - # Vérification de l'alias phps - if ! alias phps &> /dev/null; then - missing_aliases+=("phps") - fi - - if [ ${#missing_aliases[@]} -eq 0 ]; then - echo "✅ Tous les alias requis sont disponibles." - else - echo "❌ Les alias suivants ne sont pas disponibles:" - for alias_name in "${missing_aliases[@]}"; do - echo " - $alias_name" - done - echo "Note: Les alias sont définis dans le fichier .bash_aliases, assurez-vous de l'avoir chargé avec 'source ~/.bash_aliases'" - fi -} - mkdir -p $HOME/Nextcloud/ressources/workflow_nextcloud/ cd $HOME/Nextcloud/ressources/workflow_nextcloud/ git clone https://source.cipherbliss.com/tykayn/workflow public_workflow -cd public_workflow +cd $HOME/Nextcloud/ressources/workflow_nextcloud/public_workflow git pull sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B188E2B695BD4743 -source $HOME/Nextcloud/ressources/workflow_nextcloud/public_workflow/workflow_variables.sh +source "$HOME/Nextcloud/ressources/workflow_nextcloud/public_workflow/workflow_variables.sh" +source "$HOME/Nextcloud/ressources/workflow_nextcloud/secrets_vars.sh" -# Installation des paquets -echo "Installation des paquets apt..." -sudo apt install -y "${APT_PACKAGES[@]}" +apt install ansible python3-pip arp-scan borgbackup curl docker docker-compose etckeeper git gnupg jq meld nano ncdu nginx restic npm pandoc php8.4 python3 python3-pip tig zsh testdisk texlive rbenv htop python3-setuptools automysqlbackup certbot smartmontools fail2ban snapd unattended-upgrades php8.4-fpm php-xml php-mysql rsync php8.4-xml php-curl vrms syncthing sshfs geeqie calibre adduser snapd borgbackup eza adduser + +cd $HOME/Nextcloud/ressources/workflow_nextcloud/public_workflow/bin wget https://github.com/nextcloud-releases/desktop/releases/download/v3.16.6/Nextcloud-3.16.6-x86_64.AppImage chmod +x Nextcloud-3.16.6-x86_64.AppImage wget https://launchpad.net/veracrypt/trunk/1.26.24/+download/VeraCrypt-1.26.24-x86_64.AppImage chmod +x VeraCrypt-1.26.24-x86_64.AppImage snap install btop +snap install czkawka snap install emacs --classic cd wget https://source.cipherbliss.com/tykayn/workflow/raw/branch/main/assets/.bash_custom_aliases -O .bash_aliases wget https://source.cipherbliss.com/tykayn/workflow/raw/branch/main/assets/.bashrc +wget https://source.cipherbliss.com/tykayn/workflow/raw/branch/main/assets/.zshrc curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh > install_oh_my_zsh.sh -bash install_oh_my_zsh.sh - -# Charger les alias pour pouvoir les vérifier -source ~/.bash_aliases - -# Vérification des installations et des alias -verify_installation -verify_aliases - -echo "========== Fin de l'initialisation du workflow =======" +bash install_oh_my_zsh.sh \ No newline at end of file