Create run.sh

This commit is contained in:
2025-04-10 10:59:39 -07:00
parent b555dc1e10
commit 07507b1485
4 changed files with 98 additions and 153 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
# scripts
A collection of shell scripts :)
A collection of handy shell scripts :)
-93
View File
@@ -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."
-59
View File
@@ -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
Executable
+97
View File
@@ -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