From fd7cd3f89333a84e435bf260b7206daec057dcb2 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Fri, 1 Aug 2025 13:14:34 +0200 Subject: [PATCH] feat: make main script more automatic --- fresh-install/main.sh | 18 ++++---- fresh-install/pacman_packages.txt | 22 +++++++++- scripts/nvidia_troubleshoot.sh | 53 +++++++++++++++++++--- scripts/setup_pc_startup_monitor.sh | 59 ++++++++++++++++++++----- scripts/setup_periodic_system.sh | 50 ++++++++++++++++++--- scripts/setup_thorium_startup.sh | 68 +++++++++++++++++++++++++---- 6 files changed, 229 insertions(+), 41 deletions(-) diff --git a/fresh-install/main.sh b/fresh-install/main.sh index 9a0c848..eaf3e0c 100755 --- a/fresh-install/main.sh +++ b/fresh-install/main.sh @@ -191,22 +191,22 @@ fi cp mpv.conf "$HOME/.config/mpv/mpv.conf" if [ ! -d "$HOME/.oh-my-zsh" ]; then - sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" + yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" else echo "Oh My Zsh is already installed" fi cd ~/linux-configuration -hosts/install.sh +sudo hosts/install.sh i3-configuration/install.sh scripts/install_pacman_wrapper.sh -scripts/nvidia_troubleshoots.sh -scripts/setup_activitywatch.sh -scripts/setup_media_organizer.sh -scripts/setup_pc_startup_monitor.sh -scripts/setup_periodic_system.sh -scripts/setup_thorium_startup.sh -protonup +scripts/nvidia_troubleshoot.sh +sudo scripts/setup_activitywatch.sh +sudo scripts/setup_media_organizer.sh +sudo scripts/setup_pc_startup_monitor.sh +yes | sudo scripts/setup_periodic_system.sh +sudo scripts/setup_thorium_startup.sh +yes | protonup yes | sudo pacman -Syuu #cd unreal-engine diff --git a/fresh-install/pacman_packages.txt b/fresh-install/pacman_packages.txt index 4cea081..0770d5d 100644 --- a/fresh-install/pacman_packages.txt +++ b/fresh-install/pacman_packages.txt @@ -74,27 +74,47 @@ asciidoctor man-db # git for large files like LLM git-lfs -# +# hell for servers nodejs +# hell for desktop electron +# better npm yarn +# for compatibility of some packages openssl-1.1 +# needed for some packages tk +# needed for some packages jpeg jasper +# opencv dependency libdc1394 +# needed for a lot of packages cblas +# Parsing Expression Grammar Template Library consider removing pegtl +# needed for a lot of packages hdf5 +# needed for a lot of packages proj +# needed for a lot of packages gcc-fortran +# needed for a lot of packages python-nose +# needed for a lot of packages python-pyproject-metadata +# needed for a lot of packages meson-python +# needed for a lot of packages lapack +# needed for a lot of packages python-numpy +# needed for a lot of packages openmpi +# needed for a lot of packages boost +# needed for some packages suitesparse +# needed for some packages vtk junit java-hamcrest diff --git a/scripts/nvidia_troubleshoot.sh b/scripts/nvidia_troubleshoot.sh index 481360d..f11e3f1 100755 --- a/scripts/nvidia_troubleshoot.sh +++ b/scripts/nvidia_troubleshoot.sh @@ -5,6 +5,31 @@ set -e # Exit on any error +# Default to non-interactive mode +INTERACTIVE_MODE=false + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + -i|--interactive) + INTERACTIVE_MODE=true + shift + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -i, --interactive Enable interactive prompts (default: auto-yes)" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Use -h or --help for usage information" + exit 1 + ;; + esac +done + # Function to check and request sudo privileges check_sudo() { if [[ $EUID -ne 0 ]]; then @@ -14,7 +39,7 @@ check_sudo() { fi } -# Check for sudo privileges first +# Check for sudo privileges after argument parsing check_sudo "$@" echo "NVIDIA Comprehensive Troubleshooter & GSP Disabler" @@ -22,6 +47,11 @@ echo "==================================================" echo "Current Date: $(date)" echo "User: $USER" echo "Original user: ${SUDO_USER:-$USER}" +if [[ "$INTERACTIVE_MODE" == "true" ]]; then + echo "Mode: Interactive (prompts enabled)" +else + echo "Mode: Automatic (auto-yes, use --interactive for prompts)" +fi # Check if nvidia module is loaded if ! lsmod | grep -q nvidia; then @@ -40,7 +70,7 @@ mkdir -p "$MODPROBE_DIR" # Create the configuration file cat > "$CONFIG_FILE" << EOF # Disable NVIDIA GSP firmware to prevent Vulkan failures and crashes -# Created by disable-gsp-firmware.sh on $(date) +# Created by nvidia_troubleshoot.sh on $(date) options nvidia NVreg_EnableGpuFirmware=0 EOF @@ -75,7 +105,7 @@ configure_xorg() { # Create NVIDIA-specific configuration cat > "$NVIDIA_CONF" << EOF # NVIDIA configuration with RenderAccel disabled -# Created by disable-gsp-firmware.sh on $(date) +# Created by nvidia_troubleshoot.sh on $(date) Section "Device" Identifier "NVIDIA Card" Driver "nvidia" @@ -99,7 +129,7 @@ configure_gcc_workaround() { if ! grep -q "IGNORE_CC_MISMATCH" "$PROFILE_FILE"; then echo "" >> "$PROFILE_FILE" echo "# NVIDIA GCC version mismatch workaround" >> "$PROFILE_FILE" - echo "# Added by disable-gsp-firmware.sh on $(date)" >> "$PROFILE_FILE" + echo "# Added by nvidia_troubleshoot.sh on $(date)" >> "$PROFILE_FILE" echo "export IGNORE_CC_MISMATCH=1" >> "$PROFILE_FILE" echo "✓ Added IGNORE_CC_MISMATCH=1 to $PROFILE_FILE" else @@ -120,10 +150,19 @@ install_pyroveil() { echo "like Final Fantasy VII Rebirth. Pyroveil can work around these problems." echo "" - read -p "Would you like to install Pyroveil? (y/N): " -n 1 -r - echo + local install_pyroveil=true - if [[ $REPLY =~ ^[Yy]$ ]]; then + if [[ "$INTERACTIVE_MODE" == "true" ]]; then + read -p "Would you like to install Pyroveil? (y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + install_pyroveil=false + fi + else + echo "Auto-installing Pyroveil (use --interactive to prompt)" + fi + + if [[ "$install_pyroveil" == "true" ]]; then # Check for required dependencies local missing_deps=() diff --git a/scripts/setup_pc_startup_monitor.sh b/scripts/setup_pc_startup_monitor.sh index a6dc647..98c56fe 100755 --- a/scripts/setup_pc_startup_monitor.sh +++ b/scripts/setup_pc_startup_monitor.sh @@ -5,10 +5,40 @@ set -e # Exit on any error +# Default to non-interactive mode +INTERACTIVE_MODE=false + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + -i|--interactive) + INTERACTIVE_MODE=true + shift + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -i, --interactive Enable interactive prompts (default: auto-yes)" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Use -h or --help for usage information" + exit 1 + ;; + esac +done + echo "PC Startup Time Monitor for Arch Linux" echo "======================================" echo "Current Date: $(date)" echo "User: ${SUDO_USER:-$USER}" +if [[ "$INTERACTIVE_MODE" == "true" ]]; then + echo "Mode: Interactive (prompts enabled)" +else + echo "Mode: Automatic (auto-yes, use --interactive for prompts)" +fi # Function to check and request sudo privileges check_sudo() { @@ -492,18 +522,25 @@ confirm_setup() { echo "- Check time: 8:30 AM daily" echo "- Action: Show warning if PC wasn't started in expected window" echo "" - read -p "Do you want to proceed? (y/N): " confirm - case "$confirm" in - [yY]|[yY][eE][sS]) - echo "Proceeding with setup..." - return 0 - ;; - *) - echo "Setup cancelled." - exit 0 - ;; - esac + if [[ "$INTERACTIVE_MODE" == "true" ]]; then + read -p "Do you want to proceed? (y/N): " confirm + + case "$confirm" in + [yY]|[yY][eE][sS]) + echo "Proceeding with setup..." + return 0 + ;; + *) + echo "Setup cancelled." + exit 0 + ;; + esac + else + echo "Auto-proceeding with setup (use --interactive to prompt)" + echo "Proceeding with setup..." + return 0 + fi } # Main execution flow diff --git a/scripts/setup_periodic_system.sh b/scripts/setup_periodic_system.sh index 22b5018..21151b4 100755 --- a/scripts/setup_periodic_system.sh +++ b/scripts/setup_periodic_system.sh @@ -5,6 +5,31 @@ set -e # Exit on any error +# Default to non-interactive mode +INTERACTIVE_MODE=false + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + -i|--interactive) + INTERACTIVE_MODE=true + shift + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -i, --interactive Enable interactive prompts (default: auto-yes)" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Use -h or --help for usage information" + exit 1 + ;; + esac +done + # Function to check and request sudo privileges check_sudo() { if [[ $EUID -ne 0 ]]; then @@ -14,7 +39,7 @@ check_sudo() { fi } -# Check for sudo privileges first +# Check for sudo privileges after argument parsing check_sudo "$@" echo "Periodic System Setup - Pacman Wrapper & Hosts File" @@ -22,6 +47,11 @@ echo "===================================================" echo "Current Date: $(date)" echo "User: $USER" echo "Original user: ${SUDO_USER:-$USER}" +if [[ "$INTERACTIVE_MODE" == "true" ]]; then + echo "Mode: Interactive (prompts enabled)" +else + echo "Mode: Automatic (auto-yes, use --interactive for prompts)" +fi # Get the directory where this script is located SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" @@ -470,11 +500,21 @@ run_initial_execution() { echo "9. Running Initial Execution..." echo "===============================" - echo "Would you like to run the system maintenance now to test the setup?" - read -p "Run initial execution? (y/N): " -n 1 -r - echo + local run_initial=true - if [[ $REPLY =~ ^[Yy]$ ]]; then + if [[ "$INTERACTIVE_MODE" == "true" ]]; then + echo "Would you like to run the system maintenance now to test the setup?" + read -p "Run initial execution? (y/N): " -n 1 -r + echo + + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + run_initial=false + fi + else + echo "Auto-running initial execution to test the setup (use --interactive to prompt)" + fi + + if [[ "$run_initial" == "true" ]]; then echo "Running initial system maintenance..." /usr/local/bin/periodic-system-maintenance.sh echo "✓ Initial execution completed" diff --git a/scripts/setup_thorium_startup.sh b/scripts/setup_thorium_startup.sh index cea9470..86e5f79 100755 --- a/scripts/setup_thorium_startup.sh +++ b/scripts/setup_thorium_startup.sh @@ -4,6 +4,31 @@ set -e # Exit on any error +# Default to non-interactive mode +INTERACTIVE_MODE=false + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + -i|--interactive) + INTERACTIVE_MODE=true + shift + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -i, --interactive Enable interactive prompts (default: auto-yes)" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Use -h or --help for usage information" + exit 1 + ;; + esac +done + # Function to check and request sudo privileges check_sudo() { if [[ $EUID -ne 0 ]]; then @@ -13,7 +38,7 @@ check_sudo() { fi } -# Check for sudo privileges first +# Check for sudo privileges after argument parsing check_sudo "$@" echo "Thorium Browser Auto-Startup Setup" @@ -21,6 +46,11 @@ echo "==================================" echo "Current Date: $(date)" echo "User: $USER" echo "Original user: ${SUDO_USER:-$USER}" +if [[ "$INTERACTIVE_MODE" == "true" ]]; then + echo "Mode: Interactive (prompts enabled)" +else + echo "Mode: Automatic (auto-yes, use --interactive for prompts)" +fi # Target URL TARGET_URL="https://www.fitatu.com/app/planner" @@ -68,9 +98,21 @@ check_thorium_browser() { echo "You can install Thorium browser from:" echo "https://thorium.rocks/" echo "" - read -p "Continue anyway? The service will be created but may fail to start (y/N): " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then + + local continue_anyway=false + + if [[ "$INTERACTIVE_MODE" == "true" ]]; then + read -p "Continue anyway? The service will be created but may fail to start (y/N): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + continue_anyway=true + fi + else + echo "Auto-continuing anyway - service will be created but may fail to start (use --interactive to prompt)" + continue_anyway=true + fi + + if [[ "$continue_anyway" != true ]]; then exit 1 fi fi @@ -363,11 +405,21 @@ test_setup() { echo "8. Testing Setup..." echo "==================" - echo "Would you like to test the browser launcher now?" - read -p "Test launch Thorium browser with Fitatu? (y/N): " -n 1 -r - echo + local run_test=true - if [[ $REPLY =~ ^[Yy]$ ]]; then + if [[ "$INTERACTIVE_MODE" == "true" ]]; then + echo "Would you like to test the browser launcher now?" + read -p "Test launch Thorium browser with Fitatu? (y/N): " -n 1 -r + echo + + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + run_test=false + fi + else + echo "Auto-testing the browser launcher (use --interactive to prompt)" + fi + + if [[ "$run_test" == "true" ]]; then echo "Testing browser launch..." echo "Note: This will open Thorium browser with Fitatu website"