2017-02-18 02:54:28 +00:00
|
|
|
# !/bin/bash
|
|
|
|
#
|
|
|
|
# Architect Installation Framework (version 2.3.1 - 26-Mar-2016)
|
|
|
|
#
|
|
|
|
# Written by Carl Duff for Architect Linux
|
|
|
|
#
|
|
|
|
# Modified by Chrysostomus to install manjaro instead
|
|
|
|
#
|
|
|
|
# This program is free software, provided under the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation. So feel free to copy, distribute,
|
|
|
|
# or modify it as you wish.
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# Header
|
2017-02-17 21:10:40 +00:00
|
|
|
VERSION="Manjaro Architect Installer v$version"
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
# Host system information
|
|
|
|
ARCHI=$(uname -m) # Display whether 32 or 64 bit system
|
|
|
|
SYSTEM="Unknown" # Display whether system is BIOS or UEFI. Default is "unknown"
|
|
|
|
H_INIT="" # Host init-sys
|
|
|
|
NW_CMD="" # command to launch the available network client
|
|
|
|
|
|
|
|
# Locale and Language
|
|
|
|
CURR_LOCALE="en_US.UTF-8" # Default Locale
|
|
|
|
FONT="" # Set new font if necessary
|
|
|
|
KEYMAP="us" # Virtual console keymap. Default is "us"
|
|
|
|
XKBMAP="us" # X11 keyboard layout. Default is "us"
|
|
|
|
ZONE="" # For time
|
|
|
|
SUBZONE="" # For time
|
|
|
|
LOCALE="en_US.UTF-8" # System locale. Default is "en_US.UTF-8"
|
|
|
|
PROFILES="" # iso-profiles path
|
|
|
|
|
|
|
|
# Menu highlighting (automated step progression)
|
|
|
|
HIGHLIGHT=0 # Highlight items for Main Menu
|
|
|
|
HIGHLIGHT_SUB=0 # Highlight items for submenus
|
|
|
|
SUB_MENU="" # Submenu to be highlighted
|
|
|
|
PARENT="" # the parent menu
|
|
|
|
|
2017-02-18 17:30:47 +00:00
|
|
|
# Temporary files to store menu selections and errors
|
2017-02-19 14:00:37 +00:00
|
|
|
ANSWER="/tmp/.answer" # Basic menu selections
|
2017-02-17 04:19:17 +00:00
|
|
|
PACKAGES="/tmp/.pkgs" # Packages to install
|
|
|
|
MOUNT_OPTS="/tmp/.mnt_opts" # Filesystem Mount options
|
|
|
|
INIT="/tmp/.init" # init systemd|openrc
|
2017-02-18 17:30:47 +00:00
|
|
|
ERR="/tmp/.errlog"
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-02-18 02:54:28 +00:00
|
|
|
# Installer-Log
|
2017-02-18 13:56:20 +00:00
|
|
|
LOGFILE="/var/log/m-a.log"
|
|
|
|
[[ ! -e $LOGFILE ]] && touch $LOGFILE
|
2017-02-18 02:54:28 +00:00
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# file systems
|
|
|
|
BTRFS=0
|
|
|
|
LUKS=0
|
|
|
|
LUKS_DEV=""
|
|
|
|
LUKS_NAME=""
|
|
|
|
LUKS_OPT="" # Default or user-defined?
|
|
|
|
LUKS_UUID=""
|
|
|
|
LVM=0
|
|
|
|
LVM_LV_NAME="" # Name of LV to create or use
|
|
|
|
LVM_VG=""
|
|
|
|
LVM_VG_MB=0
|
|
|
|
VG_PARTS=""
|
|
|
|
LVM_SEP_BOOT=0 # 1 = Seperate /boot, 2 = seperate /boot & LVM
|
|
|
|
LV_SIZE_INVALID=0 # Is LVM LV size entered valid?
|
|
|
|
VG_SIZE_TYPE="" # Is VG in Gigabytes or Megabytes?
|
|
|
|
|
|
|
|
# Mounting
|
|
|
|
MOUNT="" # Installation: All other mounts branching
|
|
|
|
MOUNTPOINT="/mnt" # Installation: Root mount from Root
|
|
|
|
FS_OPTS="" # File system special mount options available
|
|
|
|
CHK_NUM=16 # Used for FS mount options checklist length
|
|
|
|
INCLUDE_PART='part\|lvm\|crypt' # Partition types to include for display and selection.
|
|
|
|
ROOT_PART="" # ROOT partition
|
|
|
|
UEFI_PART="" # UEFI partition
|
|
|
|
UEFI_MOUNT="" # UEFI mountpoint (/boot or /boot/efi)
|
|
|
|
|
|
|
|
# Edit Files
|
|
|
|
FILE="" # File(s) to be reviewed
|
|
|
|
|
|
|
|
# Installation
|
|
|
|
DM_INST="" # Which DMs have been installed?
|
|
|
|
DM_ENABLED=0 # Has a display manager been enabled?
|
|
|
|
NM_INST="" # Which NMs have been installed?
|
|
|
|
NM_ENABLED=0 # Has a network connection manager been enabled?
|
|
|
|
KERNEL="n" # Kernel(s) installed (base install); kernels for mkinitcpio
|
|
|
|
GRAPHIC_CARD="" # graphics card
|
|
|
|
INTEGRATED_GC="" # Integrated graphics card for NVIDIA
|
|
|
|
NVIDIA_INST=0 # Indicates if NVIDIA proprietary driver has been installed
|
|
|
|
NVIDIA="" # NVIDIA driver(s) to install depending on kernel(s)
|
|
|
|
VB_MOD="" # headers packages to install depending on kernel(s)
|
|
|
|
SHOW_ONCE=0 # Show de_wm information only once
|
|
|
|
COPY_PACCONF=0 # Copy over installer /etc/pacman.conf to installed system?
|
|
|
|
|
2017-02-18 00:56:48 +00:00
|
|
|
import(){
|
|
|
|
if [[ -r $1 ]];then
|
|
|
|
source $1
|
|
|
|
else
|
2017-02-18 14:11:43 +00:00
|
|
|
echo "Could not import $1"
|
2017-02-18 00:56:48 +00:00
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-02-18 02:54:28 +00:00
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
DIALOG() {
|
|
|
|
dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --column-separator "|" --title "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# progress through menu entries until number $1 is reached
|
|
|
|
submenu() {
|
|
|
|
if [[ $SUB_MENU != "$PARENT" ]]; then
|
|
|
|
SUB_MENU="$PARENT"
|
|
|
|
HIGHLIGHT_SUB=1
|
|
|
|
elif [[ $HIGHLIGHT_SUB != "$1" ]]; then
|
|
|
|
HIGHLIGHT_SUB=$(( HIGHLIGHT_SUB + 1 ))
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Adapted from AIS. Checks if system is made by Apple, whether the system is BIOS or UEFI,
|
|
|
|
# and for LVM and/or LUKS.
|
|
|
|
id_system() {
|
|
|
|
# Apple System Detection
|
|
|
|
if [[ "$(cat /sys/class/dmi/id/sys_vendor)" == 'Apple Inc.' ]] || [[ "$(cat /sys/class/dmi/id/sys_vendor)" == 'Apple Computer, Inc.' ]]; then
|
|
|
|
modprobe -r -q efivars || true # if MAC
|
|
|
|
else
|
|
|
|
modprobe -q efivarfs # all others
|
|
|
|
fi
|
|
|
|
|
|
|
|
# BIOS or UEFI Detection
|
|
|
|
if [[ -d "/sys/firmware/efi/" ]]; then
|
|
|
|
# Mount efivarfs if it is not already mounted
|
|
|
|
if [[ -z $(mount | grep /sys/firmware/efi/efivars) ]]; then
|
|
|
|
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
|
|
|
fi
|
|
|
|
SYSTEM="UEFI"
|
|
|
|
else
|
2017-02-18 02:54:28 +00:00
|
|
|
SYSTEM="BIOS"
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# init system
|
|
|
|
if [ $(cat /proc/1/comm) == "systemd" ]; then
|
|
|
|
H_INIT="systemd"
|
|
|
|
else
|
|
|
|
H_INIT="openrc"
|
|
|
|
fi
|
|
|
|
|
|
|
|
## TODO: Test which nw-client is available, including if the service according to $H_INIT is running
|
|
|
|
[[ $H_INIT == "systemd" ]] && [[ $(systemctl is-active NetworkManager) == "active" ]] && NW_CMD=nmtui
|
|
|
|
}
|
|
|
|
|
2017-02-21 18:01:17 +00:00
|
|
|
LOG(){
|
|
|
|
echo "$(date +%D\ %T\ %Z) ##$1" >> $LOGFILE
|
|
|
|
}
|
|
|
|
|
|
|
|
# If there is an error, display it and go back to main menu. In any case, write to logfile.
|
2017-02-17 04:19:17 +00:00
|
|
|
check_for_error() {
|
2017-02-21 21:23:00 +00:00
|
|
|
local _msg="[$1]"
|
2017-02-21 18:01:17 +00:00
|
|
|
local _err="$2"
|
|
|
|
[[ -f "${ERR}" ]] && {
|
|
|
|
_msg="${_msg}: $(head -n1 ${ERR})"
|
|
|
|
rm "${ERR}"
|
|
|
|
}
|
|
|
|
if ((${_err}!=0)); then
|
|
|
|
_msg="ERROR: ${_msg}"
|
2017-02-21 07:07:12 +00:00
|
|
|
DIALOG " $_ErrTitle " --msgbox "\n$(cat ${ERR})\n" 0 0
|
2017-02-21 18:01:17 +00:00
|
|
|
# and function for varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")"
|
2017-02-17 04:19:17 +00:00
|
|
|
main_menu_online
|
2017-02-21 18:01:17 +00:00
|
|
|
else
|
|
|
|
_msg="##${_msg}"
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
2017-02-21 18:01:17 +00:00
|
|
|
echo -e "$(date +%D\ %T\ %Z) ${_msg}" >> "${LOGFILE}"
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Add locale on-the-fly and sets source translation file for installer
|
|
|
|
select_language() {
|
|
|
|
DIALOG "Select Language" --default-item '3' --menu "\n$_Lang" 0 0 11 \
|
|
|
|
"1" $"Danish|(da_DK)" \
|
|
|
|
"2" $"Dutch|(nl_NL)" \
|
|
|
|
"3" $"English|(en_**)" \
|
|
|
|
"4" $"French|(fr_FR)" \
|
|
|
|
"5" $"Hungarian|(hu_HU)" \
|
|
|
|
"6" $"Italian|(it_IT)" \
|
|
|
|
"7" $"Portuguese|(pt_PT)" \
|
|
|
|
"8" $"Portuguese [Brasil]|(pt_BR)" \
|
|
|
|
"9" $"Russian|(ru_RU)" \
|
|
|
|
"10" $"Spanish|(es_ES)" 2>${ANSWER}
|
|
|
|
|
|
|
|
# "5" $"German|(de_DE)" \
|
|
|
|
|
|
|
|
case $(cat ${ANSWER}) in
|
2017-02-18 02:12:24 +00:00
|
|
|
"1") source $DATADIR/translations/danish.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="da_DK.UTF-8"
|
2017-02-18 14:35:07 +00:00
|
|
|
FONT="cp865-8x16.psfu"
|
2017-02-17 04:19:17 +00:00
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"2") source $DATADIR/translations/dutch.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="nl_NL.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"3") source $DATADIR/translations/english.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="en_US.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"4") source $DATADIR/translations/french.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="fr_FR.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
# "5") source $DATADIR/translations/german.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
# CURR_LOCALE="de_DE.UTF-8"
|
|
|
|
# ;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"5") source $DATADIR/translations/hungarian.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="hu_HU.UTF-8"
|
|
|
|
FONT="lat2-16.psfu"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"6") source $DATADIR/translations/italian.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="it_IT.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"7") source $DATADIR/translations/portuguese.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="pt_PT.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"8") source $DATADIR/translations/portuguese_brasil.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="pt_BR.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"9") source $DATADIR/translations/russian.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="ru_RU.UTF-8"
|
|
|
|
FONT="LatKaCyrHeb-14.psfu"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
"10") source $DATADIR/translations/spanish.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
CURR_LOCALE="es_ES.UTF-8"
|
|
|
|
;;
|
2017-02-18 02:12:24 +00:00
|
|
|
# "") source $DATADIR/translations/turkish.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
# CURR_LOCALE="tr_TR.UTF-8"
|
|
|
|
# FONT="LatKaCyrHeb-14.psfu"
|
|
|
|
# ;;
|
2017-02-18 02:12:24 +00:00
|
|
|
# "") source $DATADIR/translations/greek.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
# CURR_LOCALE="el_GR.UTF-8"
|
|
|
|
# FONT="iso07u-16.psfu"
|
|
|
|
# ;;
|
2017-02-18 02:12:24 +00:00
|
|
|
# "") source $DATADIR/translations/polish.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
# CURR_LOCALE="pl_PL.UTF-8"
|
|
|
|
# FONT="latarcyrheb-sun16"
|
|
|
|
# ;;
|
|
|
|
*) clear && exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Generate the chosen locale and set the language
|
|
|
|
DIALOG "$_Config" --infobox "$_ApplySet" 0 0
|
|
|
|
sleep 2
|
|
|
|
sed -i "s/#${CURR_LOCALE}/${CURR_LOCALE}/" /etc/locale.gen
|
|
|
|
locale-gen >/dev/null 2>&1
|
|
|
|
export LANG=${CURR_LOCALE}
|
|
|
|
[[ $FONT != "" ]] && setfont $FONT
|
|
|
|
}
|
|
|
|
|
|
|
|
mk_connection() {
|
|
|
|
if [[ ! $(ping -c 2 google.com) ]]; then
|
|
|
|
DIALOG "$_NoCon" --yesno "\n$_EstCon" 0 0 && $NW_CMD || clear && exit 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check user is root, and that there is an active internet connection
|
|
|
|
# Seperated the checks into seperate "if" statements for readability.
|
|
|
|
check_requirements() {
|
|
|
|
DIALOG " $_ChkTitle " --infobox "$_ChkBody" 0 0
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
if [[ `whoami` != "root" ]]; then
|
|
|
|
DIALOG " $_Erritle " --infobox "$_RtFailBody" 0 0
|
|
|
|
sleep 2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $(ping -c 1 google.com) ]]; then
|
|
|
|
DIALOG " $_ErrTitle " --infobox "$_ConFailBody" 0 0
|
|
|
|
sleep 2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# This will only be executed where neither of the above checks are true.
|
|
|
|
# The error log is also cleared, just in case something is there from a previous use of the installer.
|
|
|
|
DIALOG " $_ReqMetTitle " --infobox "$_ReqMetBody" 0 0
|
|
|
|
sleep 2
|
|
|
|
clear
|
2017-02-18 17:30:47 +00:00
|
|
|
echo "" > $ERR
|
2017-02-17 04:19:17 +00:00
|
|
|
pacman -Syy
|
|
|
|
}
|
|
|
|
|
|
|
|
# Greet the user when first starting the installer
|
|
|
|
greeting() {
|
|
|
|
DIALOG " $_WelTitle $VERSION " --msgbox "$_WelBody" 0 0
|
|
|
|
}
|
|
|
|
|
2017-02-18 12:54:09 +00:00
|
|
|
rank_mirrors() {
|
|
|
|
#Choose the branch for mirrorlist
|
|
|
|
BRANCH="/tmp/.branch"
|
2017-02-19 19:04:27 +00:00
|
|
|
DIALOG "$_MirrorBranch" --radiolist "\n\n$_UseSpaceBar" 0 0 3 \
|
2017-02-18 13:25:59 +00:00
|
|
|
"stable" "-" off \
|
2017-02-18 12:54:09 +00:00
|
|
|
"testing" "-" off \
|
|
|
|
"unstable" "-" off 2>${BRANCH}
|
2017-02-18 19:43:21 +00:00
|
|
|
clear
|
2017-02-18 14:00:32 +00:00
|
|
|
[[ ! -z "$(cat ${BRANCH})" ]] && pacman-mirrors -gib "$(cat ${BRANCH})" && \
|
2017-02-18 13:25:59 +00:00
|
|
|
LOG "branch selected: $(cat ${BRANCH})"
|
2017-02-18 12:54:09 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# Originally adapted from AIS. Added option to allow users to edit the mirrorlist.
|
|
|
|
configure_mirrorlist() {
|
|
|
|
DIALOG " $_MirrorlistTitle " \
|
|
|
|
--menu "$_MirrorlistBody" 0 0 4 \
|
|
|
|
"1" "$_MirrorRankTitle" \
|
|
|
|
"2" "$_MirrorConfig" \
|
|
|
|
"3" "$_MirrorPacman" \
|
|
|
|
"4" "$_Back" 2>${ANSWER}
|
|
|
|
|
|
|
|
case $(cat ${ANSWER}) in
|
|
|
|
"1") rank_mirrors
|
2017-02-18 13:25:59 +00:00
|
|
|
LOG "rank mirrors"
|
|
|
|
;;
|
2017-02-17 04:19:17 +00:00
|
|
|
"2") nano /etc/pacman-mirrors.conf
|
2017-02-18 13:25:59 +00:00
|
|
|
LOG "edit pacman-mirrors.conf"
|
|
|
|
;;
|
2017-02-17 04:19:17 +00:00
|
|
|
"3") nano /etc/pacman.conf
|
2017-02-18 13:25:59 +00:00
|
|
|
DIALOG " $_MirrorPacman " --yesno "$_MIrrorPacQ" 0 0 \
|
|
|
|
&& LOG "edit pacman.conf" && COPY_PACCONF=1 || COPY_PACCONF=0
|
2017-02-17 04:19:17 +00:00
|
|
|
pacman -Syy
|
|
|
|
;;
|
|
|
|
*) install_base_menu
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
configure_mirrorlist
|
|
|
|
}
|
|
|
|
|
|
|
|
# Simple code to show devices / partitions.
|
|
|
|
show_devices() {
|
|
|
|
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | grep "disk\|part\|lvm\|crypt\|NAME\|MODEL\|TYPE\|FSTYPE\|SIZE\|MOUNTPOINT" > /tmp/.devlist
|
|
|
|
DIALOG " $_DevShowOpt " --textbox /tmp/.devlist 0 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Adapted from AIS. An excellent bit of code!
|
|
|
|
arch_chroot() {
|
|
|
|
manjaro-chroot $MOUNTPOINT "${1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ensure that a partition is mounted
|
|
|
|
check_mount() {
|
|
|
|
if [[ $(lsblk -o MOUNTPOINT | grep ${MOUNTPOINT}) == "" ]]; then
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "$_ErrNoMount" 0 0
|
|
|
|
main_menu_online
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ensure that Manjaro has been installed
|
|
|
|
check_base() {
|
|
|
|
if [[ ! -e ${MOUNTPOINT}/etc ]]; then
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "$_ErrNoBase" 0 0
|
|
|
|
main_menu_online
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-19 11:01:19 +00:00
|
|
|
# install a pkg in the live session if not installed
|
2017-02-17 04:19:17 +00:00
|
|
|
inst_needed() {
|
|
|
|
[[ ! $(pacman -Q $1 2>/dev/null) ]] && pacman -Sy --noconfirm $1
|
2017-02-19 11:14:44 +00:00
|
|
|
LOG "Install needed pkg $1."
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
2017-02-19 11:01:19 +00:00
|
|
|
|
|
|
|
# install a pkg in the chroot if not installed
|
|
|
|
check_pkg() {
|
|
|
|
arch_chroot "[[ ! $(pacman -Q $1 2>/dev/null) ]] && pacman -Sy --noconfirm $1" 2>$ERR
|
2017-02-19 11:14:44 +00:00
|
|
|
LOG "Install missing pkg $1 to target."
|
2017-02-19 11:01:19 +00:00
|
|
|
}
|