From 7e136c8804a4dd20677367734208026361777b73 Mon Sep 17 00:00:00 2001 From: Esteban Carnevale Date: Wed, 5 Nov 2014 11:37:52 -0300 Subject: parautinst: Add scripts --- parautinst | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ parautinst-chroot | 32 ++++++++++++++ 2 files changed, 160 insertions(+) create mode 100755 parautinst create mode 100644 parautinst-chroot diff --git a/parautinst b/parautinst new file mode 100755 index 0000000..bf50a1d --- /dev/null +++ b/parautinst @@ -0,0 +1,128 @@ +#!/bin/bash + +# Name: parautinst +# Description: Parabola automated installer +# Author: Esteban V. Carnevale - alfplayer@mailoo.org + + +# Binary configuration switches are set like this +# 1 to enable +# 0 to disable + +# sshfs remote cache directory location +#cache_sshfs='USER@HOST:CACHEDIR' + +# Chroot directory +#chrootdir=/tmp/chroot +chrootdir="/mnt" + +# HTTP proxy +#http_proxy=http://HOST:PORT/ + +# Create partition and mount? (binary) +partitioning_and_mount=1 + +# Pacman needs to be updated before installing Parabola? (binary) +pacman_needs_upgrade=0 + +# parabola-keyring needs to be updated before installing Parabola? (binary) +parabola_keyring_needs_upgrade=0 + +# Set a Parabola mirror +#mirror='http://repo.parabolagnulinux.org/$repo/os/$arch' + +# Hostname +hostname="parabola" + +# Time zone +timezone="/usr/share/zoneinfo/America/Buenos_Aires" + +# Locale +locale="en_US.UTF-8 UTF-8" + +# Keymap +keymap="es" + +# Install virtio initramfs modules? (binary) +virtio=0 + + + +red='\e[31m' # Red +cyan_bg='\e[46m' # Cyan background +txtrst='\e[0m' # Text Reset + +info() { echo -e ${cyan_bg}PARAUTINST:${txtrst} "$@" ; } + +error() { echo -e ${cyan_bg}PARAUTINST error:${txtrst} "$@" 1>&2 ; exit 1 ; } + +[[ "$@" ]] || error "Usage: parautinst [partition]\nExample: parautinst sda1\nWARNING! All data on the specified partition will be lost." + +info "${red}WARNING! All data on the partition $1 will be lost.${txtrst}\n\nPress any key to continue, or Ctrl-C to cancel." + +read -n1 + +echo + +part="$1" +hdd=${part%?} + +export red cyan_bg txtrst info error part hdd chrootdir hostname timezone locale keymap virtio + +export -f info error + +[[ ! -e ${chrootdir} ]] && mkdir "${chrootdir}" + +[[ ${mirror} ]] && echo "Server = ${mirror}" > /etc/pacman.d/mirrorlist + +pacmancmd='pacman --cachedir /tmp -Sy --noconfirm --needed' + +(( ${partitioning_and_mount} )) & { + info "Unmounting ${part}" + umount /dev/${part} + info "Partitioning ${hdd}" + parted /dev/${hdd} -s "mklabel msdos" + parted /dev/${hdd} -s "mkpart primary ext4 1MiB -1s" + info "Creating filesystem on ${part}" + mkfs.ext4 /dev/${part} + info "Mounting ${part} on ${chrootdir}" + mount /dev/${part} "${chrootdir}" +} + +(( ${pacman_needs_upgrade} )) && { + info "Updating pacman database" + pacman -Sy + info "Updating pacman" + ${pacmancmd} pacman +} + +[[ ${cache_sshfs} ]] && { + info "Installing sshfs" + ${pacmancmd} sshfs + info "Mounting package cache over sshfs" + if grep -s '\s/var/cache/pacman/pkg\s' /etc/mtab ; then + info "Package cache already mounted" + else + mount -t fuse.sshfs -o noauto,user,idmap=user,comment=x-systemd.automount,allow_other,StrictHostKeyChecking=no "${cache_sshfs}" /var/cache/pacman/pkg || error "Error mounting the package cache using sshfs" + fi +} + +(( ${parabola_keyring_needs_upgrade} )) && { + info "Installing parabola-keyring" + ${pacmancmd} parabola-keyring +} + +info "Running parautinst and installing base group and grub" +pacstrap -c "${chrootdir}" base grub +#cp /etc/libretools.conf /etc/makepkg.conf ${chrootdir}/etc + +info "Running genfstab" +genfstab -p "${chrootdir}" >> "${chrootdir}"/etc/fstab + +cp parautinst-chroot "${chrootdir}"/parautinst-chroot + +#chmod +x ${chrootdir}/parautinst-chroot + +arch-chroot "${chrootdir}" /bin/bash parautinst-chroot + +rm "${chrootdir}"/parautinst-chroot diff --git a/parautinst-chroot b/parautinst-chroot new file mode 100644 index 0000000..ad51f64 --- /dev/null +++ b/parautinst-chroot @@ -0,0 +1,32 @@ +#!/bin/bash + +red='\e[31m' # Red +cyan_bg='\e[46m' # Cyan background +txtrst='\e[0m' # Text Reset + +info() { echo -e ${cyan_bg}PARAUTINST chroot:${txtrst} "$@" ; } + +error() { echo -e ${cyan_bg}PARAUTINST chroot error:${txtrst} "$@" 1>&2 ; exit 1 ; } + +info Setting system config files +echo "${hostname}" > /etc/hostname +ln -s "${timezone}" /etc/localtime +echo "${locale}" >> /etc/locale.gen +echo "KEYMAP=${keymap}" > /etc/vconsole.conf +locale-gen + +if (( $virtio )) ; then + info "Recreating initramfs to add virtio modules" + sed -i 's/MODULES=\"\"/MODULES="virtio_blk virtio_pci virtio_net"/' /etc/mkinitcpio.conf +fi + +mkinitcpio -p linux-libre + +info "Setting root password" +passwd + +info "Installing Grub 2" +grub-install --recheck /dev/"${hdd}" + +info "Configuring Grub 2" +grub-mkconfig -o /boot/grub/grub.cfg -- cgit v1.2.2