From 07507b1485cbbd2e0e00e0b94683549f5b1b9647 Mon Sep 17 00:00:00 2001 From: Timothy Pidashev Date: Thu, 10 Apr 2025 10:59:39 -0700 Subject: [PATCH] Create run.sh --- README.md | 2 +- arch-init.sh | 93 ------------------------------------------------- arch-post.sh | 59 -------------------------------- run.sh | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 153 deletions(-) delete mode 100644 arch-init.sh delete mode 100644 arch-post.sh create mode 100755 run.sh diff --git a/README.md b/README.md index ebd7ccf..121b763 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # scripts -A collection of shell scripts :) +A collection of handy shell scripts :) diff --git a/arch-init.sh b/arch-init.sh deleted file mode 100644 index 8091f6d..0000000 --- a/arch-init.sh +++ /dev/null @@ -1,93 +0,0 @@ -#! /bin/bash - -echo "Timmy's Arch Installer" && sleep 1 - -# Figure out if we are running on a Legacy or UEFI system -echo "1) UEFI System 2) Legacy System" -read -r -p "What kind of computer are you running on? (default 1): " sys - -case $sys in -[1]) - SYSTEM="UEFI" - ;; -[2]) - SYSTEM="LEGACY" - ;; -[4]) - SYSTEM="" - ;; -[*]) - SYSTEM="UEFI" - ;; -esac - -# Format disk with FDisk -echo "Formatting /dev/sda for $SYSTEM system..." - -# UEFI format -if [ $sys -eq 1 ] -then - # fdisk formatting - ( - echo g; - echo w; - echo q - ) | fdisk /dev/sda - - ( - echo n; - echo ""; - echo ""; - echo +512M; - echo t; - echo 1; - echo n; - echo ""; - echo ""; - echo +25G; - echo n; - echo ""; - echo ""; - echo "" - echo w; - echo q - ) | fdisk /dev/sda - - # actually format the partitions afterwards... - mkfs.fat -F32 /dev/sda1 - mkfs.ext4 /dev/sda2 - mkfs.ext4 /dev/sda3 - - # mount partitions - echo "Mounting partitions..." && sleep 1 - mount /dev/sda2 /mnt - mkdir /mnt/home - mount /dev/sda3 /mnt/home - - lsblk - - echo "Disk-related stuff complete. phew..." && sleep 1 -fi - -# EFI format -if [ $sys -eq 2 ] -then - echo "efi" -fi - -# download linux firmware and important modules -echo "Downloading needed dependencies..." -pacstrap -i /mnt base linux linux-firmware sudo nano git - -# generate file-system table -genfstab -U -p /mnt >> /mnt/etc/fstab && sleep 1 -echo "Generated file-system table..." - -# post install -echo "Fetching post-install script and chrooting..." && sleep 1 -cp arch-post.sh /mnt/root/arch-post.sh -arch-chroot /mnt "/bin/bash" "/root/arch-post.sh" - -#after post-install completes -umount /mnt -echo "Configuration complete! Please reboot your system and take out your arch installation medium." diff --git a/arch-post.sh b/arch-post.sh deleted file mode 100644 index bfe1536..0000000 --- a/arch-post.sh +++ /dev/null @@ -1,59 +0,0 @@ -#! /bin/bash - -# generate locales -sed --in-place=.bak 's/^#en_US\.UTF-8/en_US\.UTF-8/' /etc/locale.gen -locale-gen -echo "LANG=en_US.UTF-8" > /etc/locale.cong -echo "Generated locales..." - -# set localtime -ln -sf /usr/share/zoneinfo/America/Seattle /etc/localtime -echo "Localtime set..." - -# hardware clock -hwclock --systohc --utc -echo "Configured hardware clock..." - -# name and host config -read -r -p "What would you like to call this computer? " HOSTNAME -echo $HOSTNAME > /etc/hostname -sed -i "/localhost/s/$/ $HOSTNAME/" /etc/hosts #MAY BE BROKEN :( - -# install networkmanager -echo "installing NetworkManager..." && sleep 1 -pacman -S --noconfirm networkmanager -systemctl enable NetworkManager - -# change password -echo "Set your root password please." -passwd - -# Bootloader installation -echo "Sorry, computer's sometimes forget stuff too. What kind of system is this again?" -read -r -p "1) UEFI System 2) LEGACY System" sys -if [ $sys -eq 1 ] -then - # install grub and the boot manager - echo "Installing boot manager..." && sleep 1 - pacman -S --noconfirm grub efibootmgr - - # mount bootmgr - echo "Mounting all systems..." && sleep 1 - mkdir /boot/efi - mount /dev/sda1 /boot/efi - - # Install grub to system - echo "Installing and configuring grub..." && sleep 1 - grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi --removable --debug - grub-mkconfig -o /boot/grub/grub.cfg -fi - -if [ $sys -eq 2 ] -then - echo "efi goes here :)" -fi - -# complete setup -echo "Configuration complete! Unmounting and rebooting system. Please take out your arch installation medium." -umount -r /mnt -exit diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e439eb8 --- /dev/null +++ b/run.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +# Base URL for fetching additional scripts +BASE_URL="https://timmypidashev.dev/scripts" + +# Parse arguments +SCRIPT_TYPE="" +while [ $# -gt 0 ]; do + case $1 in + --type|-t) + SCRIPT_TYPE="$2" + shift 2 + ;; + --help|-h) + echo "Usage: curl -fsSL https://timmypidashev.dev/scripts/run | sh -s -- [OPTIONS]" + echo "" + echo "Options:" + echo " -t, --type TYPE Specify which script to run" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + # Remaining arguments will be passed to the script + break + ;; + esac +done + +# Create a temporary directory for our scripts +TEMP_DIR=$(mktemp -d) +cleanup() { + rm -rf "$TEMP_DIR" +} +trap cleanup EXIT + +# Function to download a script +download_script() { + script_path="$1" + output_path="$TEMP_DIR/$script_path" + + # Create directory if needed + mkdir -p "$(dirname "$output_path")" + + # Download the script + echo "Downloading $script_path..." + curl -fsSL "$BASE_URL/$script_path" -o "$output_path" + chmod +x "$output_path" +} + +# Download common utilities first +#download_script "utils/common" + +# Source common utilities +#. "$TEMP_DIR/utils/common" + +# Interactive menu if no script type was specified +if [ -z "$SCRIPT_TYPE" ]; then + echo "╔════════════════════════════════════════════╗" + echo "║ Welcome to Timmy's scripts library! ║" + echo "╚════════════════════════════════════════════╝" + echo "" + echo "Please select a script to run:" + echo "1) coreboot-t440p - Coreboot a T440p" + echo "5) Quit" + echo "" + + selected=0 + while [ $selected -lt 1 ] || [ $selected -gt 5 ]; do + printf "Enter your choice [1-5]: " + read -r selected + + # Validate input + if ! echo "$selected" | grep -q '^[1-5]$'; then + echo "Please enter a number between 1 and 5." + selected=0 + fi + done + + case $selected in + 1) SCRIPT_TYPE="coreboot-t440p" ;; + 5) echo "Exiting."; exit 0 ;; + esac + + echo "Running $SCRIPT_TYPE script..." +fi + +# Run the requested script type +case "$SCRIPT_TYPE" in + coreboot-t440p) + download_script "scripts/coreboot" + "$TEMP_DIR/scripts/coreboot" "$@" + ;; + *) + echo "Unknown script type: $SCRIPT_TYPE" + exit 1 + ;; +esac