diff options
Diffstat (limited to 'abs/extra/syslinux/syslinux-install_update')
-rw-r--r-- | abs/extra/syslinux/syslinux-install_update | 126 |
1 files changed, 58 insertions, 68 deletions
diff --git a/abs/extra/syslinux/syslinux-install_update b/abs/extra/syslinux/syslinux-install_update index cd1baa5..3843b5f 100644 --- a/abs/extra/syslinux/syslinux-install_update +++ b/abs/extra/syslinux/syslinux-install_update @@ -1,7 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash # -# Sylinux Installer / Updater Scripts -# Copyright (C) 2011 Matthew Gyurgyik <pyther@pyther.net> +# Syslinux Installer / Updater Script (for BIOS only) +# Copyright (C) 2011-2013 Matthew Gyurgyik <pyther@pyther.net> +# Copyright (C) 2013 Keshav Padram Amburay <(the) (ddoott) (ridikulus) (ddoott) (rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -18,21 +19,24 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # #----------------- +# ChangeLog: +# 2013-10-23 : Keshav Padram Amburay : Updated script to work with Syslinux 6.02 Arch Linux pkg +#----------------- # Exit Codes: # 1 - get_boot_device or other function failed # 2 - install/update failed # 3 - set_active failed # 4 - install_mbr failed -# +#----------------- + shopt -s nullglob -libpath="/usr/lib/syslinux" -bootpath="/boot/syslinux" -extlinux="/usr/sbin/extlinux" +bios_libpath="/usr/lib/syslinux/bios" +bios_bootpath="/boot/syslinux" +EXTLINUX="/usr/bin/extlinux" -autoupdate_file=/boot/syslinux/SYSLINUX_AUTOUPDATE -com32_files=(menu.c32 vesamenu.c32 chain.c32 hdt.c32 reboot.c32 poweroff.com) -pciids_file=/usr/share/hwdata/pci.ids +bios_autoupdate_file="/boot/syslinux/SYSLINUX_AUTOUPDATE" +pciids_file="/usr/share/hwdata/pci.ids" ## Helper functions ## # Taken from libui-sh @@ -120,7 +124,7 @@ usage() { cat << EOF usage: $0 options -This script will install or upgrade Syslinux +This script will install or upgrade Syslinux (for BIOS only) OPTIONS: -h Show this message @@ -133,16 +137,16 @@ OPTIONS: Arguments Required: -c Chroot install (ex: -c /mnt) -Example Usage: syslinux-install_update.sh -i -a -m (install, set boot flag, install mbr) - syslinux-install_update.sh -u (update) +Example Usage: $0 -i -a -m # (install, set boot flag, install mbr) + $0 -u # (update) EOF } # Trys to find the partition that /boot resides on # This will either be on /boot or / (root) getBoot() { - if [[ ! -d "$bootpath" ]]; then - echo "Could not find $bootpath" + if [[ ! -d "$bios_bootpath" ]]; then + echo "Could not find $bios_bootpath" echo "Is boot mounted? Is Syslinux installed?" exit 1 fi @@ -278,9 +282,9 @@ install_mbr() { { echo "ABORT! MBR installation to partition ($disk)!"; exit 4;} if [[ "$ptb" = MBR ]]; then - mbrfile="$libpath/mbr.bin" + mbrfile="$bios_libpath/mbr.bin" elif [[ "$ptb" = GPT ]]; then - mbrfile="$libpath/gptmbr.bin" + mbrfile="$bios_libpath/gptmbr.bin" fi if dd bs=440 count=1 conv=notrunc if="$mbrfile" of="$disk" &> /dev/null; then @@ -293,67 +297,53 @@ install_mbr() { return 0 } -_install() { - # Copy files to /boot - for file in "${com32_files[@]}"; do - # Symlink files even if links exist - if [[ "$boot" = root ]]; then - ln -s "${libpath#$CHROOT}/$file" "$bootpath/$file" &> /dev/null - elif [[ "$boot" = boot ]]; then - cp "$libpath/$file" "$bootpath/$file" - fi - done +install_modules() { + # Copy all syslinux *.c32 modules to /boot + rm "$bios_bootpath"/*.c32 &> /dev/null + cp "$bios_libpath"/*.c32 "$bios_bootpath"/ &> /dev/null - # Copy / Symlink pci.ids if we copy the com32 module and if pci.ids exists in the FS - if check_is_in "hdt.c32" "${com32_files[@]}" && [[ -f $pciids_file ]]; then - if [[ "$boot" = root ]]; then - ln -s "$pciids_file" "$bootpath/pci.ids" &> /dev/null - elif [[ "$boot" = boot ]]; then - cp "$pciids_file" "$bootpath/pci.ids" &> /dev/null - fi + # Copy / Symlink pci.ids if pci.ids exists on the FS + if [[ -f "$pciids_file" ]]; then + rm "$bios_bootpath/pci.ids" &> /dev/null + cp "$pciids_file" "$bios_bootpath/pci.ids" &> /dev/null fi +} - if device_is_raid "$bootpart"; then +_install() { + install_modules + + if device_is_raid "$bootpart" ; then echo "Detected RAID on /boot - installing Syslinux with --raid" - "$extlinux" --install "$bootpath" -r > /dev/null 2>&1 + "$EXTLINUX" --install "$bios_bootpath" --raid &> /dev/null else - "$extlinux" --install "$bootpath" > /dev/null 2>&1 + "$EXTLINUX" --install "$bios_bootpath" &> /dev/null fi if (( $? )); then - echo "Syslinux install failed" + echo "Syslinux BIOS install failed" exit 2 else - echo "Syslinux install successful" + echo "Syslinux BIOS install successful" fi - touch "$CHROOT/$autoupdate_file" + touch "$CHROOT/$bios_autoupdate_file" } update() { - # Update any com and c32 files in /boot - if [[ "$boot" = boot ]]; then - for file in "$bootpath"/*.{c32,com}; do - file=$(basename "$file") - cp "$libpath/$file" "$bootpath/$file" &> /dev/null - done - if [[ -f "$bootpath/pci.ids" ]]; then - cp "$pciids_file" "$bootpath/pci.ids" &> /dev/null - fi - fi + install_modules - if device_is_raid $bootpart; then - echo "Detected RAID on /boot - installing Syslinux with --raid" - "$extlinux" --update "$bootpath" -r &> /dev/null + if device_is_raid "$bootpart" ; then + echo "Detected RAID on /boot - updating Syslinux with --raid" + "$EXTLINUX" --update "$bios_bootpath" --raid &> /dev/null else - "$extlinux" --update "$bootpath" &> /dev/null + "$EXTLINUX" --update "$bios_bootpath" &> /dev/null fi if (($?)); then - echo "Syslinux update failed" + echo "Syslinux BIOS update failed" exit 2 else - echo "Syslinux update successful" + echo "Syslinux BIOS update successful" fi } @@ -388,7 +378,7 @@ while getopts "c:uihmas" opt; do ;; s) # If AUTOUPDATE_FILE does not exist exit the script - if [[ -f $autoupdate_file ]]; then + if [[ -f $bios_autoupdate_file ]]; then UPDATE="True" else exit 0 @@ -406,28 +396,28 @@ if [[ $USAGE ]]; then exit 0 fi -# Make sure only root can run our script -if (( $(id -u) != 0 )); then - echo "This script must be run as root" 1>&2 - exit 1 -fi - # Display Usage Information if both Install and Update are passed if [[ $INSTALL && $UPDATE ]]; then usage exit 1 fi +# Make sure only root can run our script +if (( $(id -u) != 0 )); then + echo "This script must be run as root" 1>&2 + exit 1 +fi + # If a chroot dir is path set variables to reflect chroot if [[ "$CHROOT" ]]; then - libpath="$CHROOT$libpath" - bootpath="$CHROOT$bootpath" - extlinux="$CHROOT$extlinux" + bios_libpath="$CHROOT$bios_libpath" + bios_bootpath="$CHROOT$bios_bootpath" + EXTLINUX="$CHROOT$EXTLINUX" fi # Exit if no /boot path exists -if ( f=("$bootpath"/*); (( ! ${#f[@]} )) ); then - echo "Error: $bootpath is empty!" +if ( f=("$bios_bootpath"/*); (( ! ${#f[@]} )) ); then + echo "Error: $bios_bootpath is empty!" echo "Is /boot mounted?" exit 1 fi |