2017-02-18 02:54:28 +00:00
|
|
|
# !/bin/bash
|
|
|
|
#
|
2017-03-02 03:04:01 +00:00
|
|
|
# Architect Installation Framework (2016-2017)
|
2017-02-18 02:54:28 +00:00
|
|
|
#
|
2017-03-02 03:04:01 +00:00
|
|
|
# Written by Carl Duff and @mandog for Archlinux
|
|
|
|
# Heavily modified and re-written by @Chrysostomus to install Manjaro instead
|
|
|
|
# Contributors: @papajoker, @oberon and the Manjaro-Community.
|
2017-02-18 02:54:28 +00:00
|
|
|
#
|
|
|
|
# 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
|
2017-03-20 10:21:10 +00:00
|
|
|
ARCHI=$(uname -m) # Display whether 32 or 64 bit system
|
2017-02-17 04:19:17 +00:00
|
|
|
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-03-20 10:21:10 +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-03-14 01:16:42 +00:00
|
|
|
BRANCH="/tmp/.branch"
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-02-18 02:54:28 +00:00
|
|
|
# Installer-Log
|
2017-03-01 22:00:20 +00:00
|
|
|
LOGFILE="/var/log/m-a.log" # path for the installer log in the live environment
|
2017-02-18 13:56:20 +00:00
|
|
|
[[ ! -e $LOGFILE ]] && touch $LOGFILE
|
2017-03-01 22:00:20 +00:00
|
|
|
TARGLOG="/mnt/.m-a.log" # path to copy the installer log to target install
|
2017-03-13 05:36:40 +00:00
|
|
|
INIFILE="/tmp/manjaro-architect.ini"
|
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?
|
2017-02-22 17:39:22 +00:00
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# Mounting
|
2017-03-20 10:21:10 +00:00
|
|
|
MOUNT="" # Installation: All other mounts branching
|
2017-02-17 04:19:17 +00:00
|
|
|
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?
|
|
|
|
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-21 22:40:40 +00:00
|
|
|
}
|
2017-02-18 02:54:28 +00:00
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
DIALOG() {
|
2017-03-10 14:38:30 +00:00
|
|
|
dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --column-separator "|" --exit-label "$_Back" --title "$@"
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-13 05:36:40 +00:00
|
|
|
# store datas in ini file
|
2017-03-20 10:21:10 +00:00
|
|
|
# read: value=$(ini system.init)
|
|
|
|
# set: ini system.init "openrc"
|
2017-03-13 05:36:40 +00:00
|
|
|
ini() {
|
|
|
|
local section="$1" value="$2"
|
|
|
|
[[ ! -f "$INIFILE" ]] && echo "">"$INIFILE"
|
|
|
|
if [[ ! "$section" =~ \. ]]; then
|
|
|
|
section="manjaro-architect.${section}"
|
|
|
|
fi
|
2017-03-13 06:53:21 +00:00
|
|
|
ini_val "$INIFILE" "$section" "$value" 2>/dev/null
|
2017-03-13 05:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function finishini {
|
|
|
|
[[ -f "$INIFILE" ]] && mv "$INIFILE" "/var/log/m-a.ini" &>/dev/null
|
|
|
|
((debug)) && cat "/var/log/m-a.ini"
|
|
|
|
}
|
|
|
|
trap finishini EXIT
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# progress through menu entries until number $1 is reached
|
|
|
|
submenu() {
|
|
|
|
if [[ $SUB_MENU != "$PARENT" ]]; then
|
|
|
|
SUB_MENU="$PARENT"
|
|
|
|
HIGHLIGHT_SUB=1
|
2017-03-01 02:32:28 +00:00
|
|
|
elif [[ $HIGHLIGHT_SUB != "$1" ]]; then
|
2017-02-17 04:19:17 +00:00
|
|
|
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() {
|
2017-03-01 00:16:58 +00:00
|
|
|
printf "\n :: $(pacman -Q manjaro-architect) ::\n\n" >> ${LOGFILE}
|
2017-02-27 10:21:55 +00:00
|
|
|
|
2017-03-13 05:36:40 +00:00
|
|
|
echo "">"$INIFILE"
|
|
|
|
ini version "$version"
|
|
|
|
ini date "$(date +%D\ %T)"
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# 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
|
2017-02-22 17:39:22 +00:00
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# 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
|
2017-03-13 05:36:40 +00:00
|
|
|
ini system.bios "$SYSTEM"
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
# init system
|
|
|
|
if [ $(cat /proc/1/comm) == "systemd" ]; then
|
|
|
|
H_INIT="systemd"
|
|
|
|
else
|
|
|
|
H_INIT="openrc"
|
|
|
|
fi
|
2017-03-13 05:36:40 +00:00
|
|
|
ini system.init "$H_INIT"
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
## TODO: Test which nw-client is available, including if the service according to $H_INIT is running
|
2017-02-24 01:22:57 +00:00
|
|
|
[[ $H_INIT == "systemd" ]] && [[ $(systemctl is-active NetworkManager) == "active" ]] && NW_CMD=nmtui 2>$ERR
|
|
|
|
|
|
|
|
check_for_error "system: $SYSTEM, init: $H_INIT nw-client: $NW_CMD"
|
2017-03-13 23:38:00 +00:00
|
|
|
|
|
|
|
# evaluate host branch
|
|
|
|
ini system.branch "$(grep -oE -m 1 "unstable|stable|testing" /etc/pacman.d/mirrorlist)"
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
2017-02-21 18:01:17 +00:00
|
|
|
# If there is an error, display it and go back to main menu. In any case, write to logfile.
|
2017-02-22 09:21:08 +00:00
|
|
|
# param 2 : error code is optional
|
2017-02-22 17:39:22 +00:00
|
|
|
# param 3 : return menu function , optional, default: main_menu_online
|
2017-02-17 04:19:17 +00:00
|
|
|
check_for_error() {
|
2017-02-22 09:21:08 +00:00
|
|
|
local _msg="$1"
|
|
|
|
local _err="${2:-0}"
|
2017-02-28 22:53:26 +00:00
|
|
|
local _function_menu="${3:-main_menu}"
|
2017-02-22 09:21:08 +00:00
|
|
|
((${_err}!=0)) && _msg="[${_msg}][${_err}]"
|
2017-02-21 22:40:40 +00:00
|
|
|
[[ -f "${ERR}" ]] && {
|
2017-02-22 09:21:08 +00:00
|
|
|
_msg="${_msg} $(head -n1 ${ERR})"
|
2017-02-21 18:01:17 +00:00
|
|
|
rm "${ERR}"
|
|
|
|
}
|
2017-02-23 22:57:40 +00:00
|
|
|
if ((${_err}!=0)) ; then
|
|
|
|
# and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")"
|
|
|
|
local _fpath="${FUNCNAME[*]:1:2}()"
|
2017-02-23 19:25:32 +00:00
|
|
|
_fpath=" --${_fpath// /()<-}"
|
2017-03-05 23:26:55 +00:00
|
|
|
! ((debug)) && _fpath=""
|
|
|
|
echo -e "$(date +%D\ %T) ERROR ${_msg}${_fpath}" >> "${LOGFILE}"
|
2017-02-27 17:53:30 +00:00
|
|
|
if [[ "${_function_menu}" != "SKIP" ]]; then
|
2017-02-28 22:53:26 +00:00
|
|
|
DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0
|
2017-03-02 01:47:02 +00:00
|
|
|
# return error for return to parent menu
|
|
|
|
return $_err
|
2017-03-05 23:26:55 +00:00
|
|
|
fi
|
2017-02-21 18:01:17 +00:00
|
|
|
else
|
2017-03-02 01:47:02 +00:00
|
|
|
# add $FUNCNAME limit to 20 max for control if recursive
|
2017-03-05 23:26:55 +00:00
|
|
|
((debug)) && _msg="${_msg} --${FUNCNAME[*]:1:20}"
|
|
|
|
echo -e "$(date +%D\ %T) ${_msg}" >> "${LOGFILE}"
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-21 11:57:56 +00:00
|
|
|
set_language() {
|
|
|
|
if [[ ! $(grep font /var/log/m-a.ini 2>/dev/null) ]]; then
|
|
|
|
select_language
|
2017-03-20 16:13:23 +00:00
|
|
|
else
|
|
|
|
CURR_LOCALE="$(grep lang /var/log/m-a.ini | cut -d' ' -f3)"
|
2017-03-21 11:57:56 +00:00
|
|
|
KEYMAP="$(grep keymap /var/log/m-a.ini | cut -d' ' -f3)"
|
|
|
|
FONT="$(grep font /var/log/m-a.ini | cut -d' ' -f3)"
|
|
|
|
TRANS="$(grep translation /var/log/m-a.ini | cut -d' ' -f3)"
|
|
|
|
import $DATADIR/translations/$TRANS.trans
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-21 11:57:56 +00:00
|
|
|
# does user want to change the old settings?
|
|
|
|
DIALOG " $_SelLang " --yesno "\nLanguage: [ ${TRANS} ]\n Keymap: [ ${KEYMAP} ].\n\n${_Change}?\n " 0 0 && select_language
|
|
|
|
fi
|
2017-03-13 14:56:23 +00:00
|
|
|
|
2017-03-21 11:57:56 +00:00
|
|
|
# Generate locale and set language
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_Config " --infobox "\n$_ApplySet\n " 0 0
|
2017-03-12 23:23:52 +00:00
|
|
|
sed -i "s/#${CURR_LOCALE}/${CURR_LOCALE}/" /etc/locale.gen
|
|
|
|
locale-gen >/dev/null 2>$ERR
|
|
|
|
export LANG=${CURR_LOCALE}
|
2017-02-24 01:22:57 +00:00
|
|
|
|
2017-03-12 23:23:52 +00:00
|
|
|
check_for_error "set LANG=${CURR_LOCALE}" $?
|
2017-03-13 05:36:40 +00:00
|
|
|
ini system.lang "$CURR_LOCALE"
|
2017-03-13 14:56:23 +00:00
|
|
|
|
|
|
|
loadkeys $KEYMAP 2>$ERR
|
|
|
|
check_for_error "loadkeys $KEYMAP" "$?"
|
|
|
|
ini linux.keymap "$KEYMAP"
|
2017-03-19 22:47:40 +00:00
|
|
|
|
2017-03-21 11:57:56 +00:00
|
|
|
setfont $FONT 2>$ERR
|
|
|
|
check_for_error "set font $FONT" $?
|
|
|
|
ini system.font "$FONT"
|
|
|
|
|
|
|
|
# store settings for re-use in target install ## to be accomplished via ini in the future
|
|
|
|
echo -e "KEYMAP=${KEYMAP}\nFONT=${FONT}" > /tmp/vconsole.conf
|
|
|
|
echo -e "consolefont=\"${FONT}\"" > /tmp/consolefont
|
|
|
|
echo -e "keymap=\"$KEYMAP\"" > /tmp/keymap
|
|
|
|
}
|
2017-03-19 22:47:40 +00:00
|
|
|
|
2017-03-21 11:57:56 +00:00
|
|
|
# set locale, keymap and font and source translation file for installer
|
|
|
|
select_language() {
|
|
|
|
fl="1" # terminus-font variation supporting most languages, to be processed in set_keymap()
|
|
|
|
DIALOG " Select Language " --default-item '3' --menu "\n " 0 0 11 \
|
|
|
|
"1" $"Danish|(da_DK)" \
|
|
|
|
"2" $"Dutch|(nl_NL)" \
|
|
|
|
"3" $"English|(en_**)" \
|
|
|
|
"4" $"French|(fr_FR)" \
|
|
|
|
"5" $"German|(de_DE)" \
|
|
|
|
"6" $"Hungarian|(hu_HU)" \
|
|
|
|
"7" $"Italian|(it_IT)" \
|
|
|
|
"8" $"Portuguese|(pt_PT)" \
|
|
|
|
"9" $"Portuguese [Brasil]|(pt_BR)" \
|
|
|
|
"10" $"Russian|(ru_RU)" \
|
|
|
|
"11" $"Spanish|(es_ES)" 2>${ANSWER}
|
|
|
|
|
|
|
|
case $(cat ${ANSWER}) in
|
|
|
|
"1") TRANS="danish"
|
|
|
|
CURR_LOCALE="da_DK.UTF-8"
|
|
|
|
KEYMAP="dk"
|
|
|
|
;;
|
|
|
|
"2") TRANS="dutch"
|
|
|
|
CURR_LOCALE="nl_NL.UTF-8"
|
|
|
|
KEYMAP="nl"
|
|
|
|
;;
|
|
|
|
"3") TRANS="english"
|
|
|
|
CURR_LOCALE="en_US.UTF-8"
|
|
|
|
KEYMAP="us"
|
|
|
|
;;
|
|
|
|
"4") TRANS="french"
|
|
|
|
CURR_LOCALE="fr_FR.UTF-8"
|
|
|
|
KEYMAP="fr"
|
|
|
|
;;
|
|
|
|
"5") TRANS="german"
|
|
|
|
CURR_LOCALE="de_DE.UTF-8"
|
|
|
|
KEYMAP="de"
|
|
|
|
;;
|
|
|
|
"6") TRANS="hungarian"
|
|
|
|
CURR_LOCALE="hu_HU.UTF-8"
|
|
|
|
KEYMAP="hu"
|
|
|
|
fl="2"
|
|
|
|
;;
|
|
|
|
"7") TRANS="italian"
|
|
|
|
CURR_LOCALE="it_IT.UTF-8"
|
|
|
|
KEYMAP="it"
|
|
|
|
;;
|
|
|
|
"8") TRANS="portuguese"
|
|
|
|
CURR_LOCALE="pt_PT.UTF-8"
|
|
|
|
KEYMAP="pt-latin1"
|
|
|
|
;;
|
|
|
|
"9") TRANS="portuguese_brasil"
|
|
|
|
CURR_LOCALE="pt_BR.UTF-8"
|
|
|
|
KEYMAP="pt-latin1"
|
|
|
|
;;
|
|
|
|
"10") TRANS="russian"
|
|
|
|
CURR_LOCALE="ru_RU.UTF-8"
|
|
|
|
KEYMAP="ru"
|
|
|
|
fl="u"
|
|
|
|
;;
|
|
|
|
"11") TRANS="spanish"
|
|
|
|
CURR_LOCALE="es_ES.UTF-8"
|
|
|
|
KEYMAP="es"
|
|
|
|
;;
|
|
|
|
*) clear && exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# source translation file
|
|
|
|
import $DATADIR/translations/$TRANS.trans
|
|
|
|
ini translation "$TRANS"
|
|
|
|
|
|
|
|
# adjust terminus font size depending on resolution
|
|
|
|
biggest_resolution=$(head -n 1 /sys/class/drm/card*/*/modes | awk -F'[^0-9]*' '{print $1}' | awk 'BEGIN{a= 0}{if ($1>a) a=$1 fi} END{print a}')
|
2017-03-13 14:56:23 +00:00
|
|
|
if [[ $biggest_resolution -gt 1920 ]]; then
|
|
|
|
fs="24"
|
|
|
|
elif [[ $biggest_resolution -eq 1920 ]]; then
|
|
|
|
fs="18"
|
|
|
|
else
|
|
|
|
fs="16"
|
|
|
|
fi
|
2017-03-19 22:47:40 +00:00
|
|
|
|
2017-03-13 14:56:23 +00:00
|
|
|
FONT="ter-${fl}${fs}n"
|
|
|
|
ini linux.font "$FONT"
|
2017-02-24 01:22:57 +00:00
|
|
|
|
2017-03-21 11:57:56 +00:00
|
|
|
# does user want to change the default keymap?
|
|
|
|
DIALOG " $_VCKeymapTitle " --yesno "\n$_DefKeymap [ ${KEYMAP} ].\n\n${_Change}?\n " 0 0 && select_keymap
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-19 22:47:40 +00:00
|
|
|
select_keymap() {
|
|
|
|
KEYMAPS=""
|
|
|
|
for i in $(ls -R /usr/share/kbd/keymaps | grep "map.gz" | sed 's/\.map\.gz//g' | sort); do
|
|
|
|
KEYMAPS="${KEYMAPS} ${i} -"
|
|
|
|
done
|
|
|
|
|
|
|
|
DIALOG " $_VCKeymapTitle " --menu "\n$_VCKeymapBody\n " 20 40 20 ${KEYMAPS} 2>${ANSWER} || return 0
|
|
|
|
KEYMAP=$(cat ${ANSWER})
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
mk_connection() {
|
|
|
|
if [[ ! $(ping -c 2 google.com) ]]; then
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_NoCon " --yesno "\n$_EstCon\n " 0 0 && $NW_CMD && return 0 || clear && exit 0
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check user is root, and that there is an active internet connection
|
|
|
|
# Seperated the checks into seperate "if" statements for readability.
|
|
|
|
check_requirements() {
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_ChkTitle " --infobox "\n$_ChkBody\n " 0 0
|
2017-02-17 04:19:17 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
if [[ `whoami` != "root" ]]; then
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_Erritle " --infobox "\n$_RtFailBody\n " 0 0
|
2017-02-17 04:19:17 +00:00
|
|
|
sleep 2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $(ping -c 1 google.com) ]]; then
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_ErrTitle " --infobox "\n$_ConFailBody\n " 0 0
|
2017-02-17 04:19:17 +00:00
|
|
|
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.
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_ReqMetTitle " --infobox "\n$_ReqMetBody\n\n$_UpdDb\n " 0 0
|
2017-02-17 04:19:17 +00:00
|
|
|
sleep 2
|
|
|
|
clear
|
2017-02-18 17:30:47 +00:00
|
|
|
echo "" > $ERR
|
2017-02-28 22:53:26 +00:00
|
|
|
pacman -Syy 2>$ERR
|
2017-03-05 22:49:09 +00:00
|
|
|
check_for_error "refresh database" $? SKIP
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Greet the user when first starting the installer
|
|
|
|
greeting() {
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_WelTitle $VERSION " --msgbox "\n$_WelBody\n " 0 0
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 22:53:26 +00:00
|
|
|
# Originally adapted from AIS. Added option to allow users to edit the mirrorlist.
|
|
|
|
configure_mirrorlist() {
|
2017-03-13 03:28:43 +00:00
|
|
|
HIGHLIGHT_SUB=1
|
|
|
|
declare -i loopmenu=1
|
|
|
|
while ((loopmenu)); do
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_MirrorlistTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n$_MirrorlistBody\n " 0 0 4 \
|
2017-03-13 03:28:43 +00:00
|
|
|
"1" "$_MirrorPacman" \
|
2017-02-28 22:53:26 +00:00
|
|
|
"2" "$_MirrorConfig" \
|
2017-03-13 03:28:43 +00:00
|
|
|
"3" "$_MirrorRankTitle" \
|
2017-02-28 22:53:26 +00:00
|
|
|
"4" "$_Back" 2>${ANSWER}
|
|
|
|
|
|
|
|
case $(cat ${ANSWER}) in
|
2017-03-13 03:28:43 +00:00
|
|
|
"1") nano /etc/pacman.conf
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_MirrorPacman " --yesno "\n$_MIrrorPacQ\n " 0 0 && COPY_PACCONF=1 || COPY_PACCONF=0
|
2017-02-28 22:53:26 +00:00
|
|
|
check_for_error "edit pacman.conf $COPY_PACCONF"
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG "" --infobox "\n$_UpdDb\n " 0 0
|
2017-02-28 22:53:26 +00:00
|
|
|
pacman -Syy
|
2017-03-13 03:28:43 +00:00
|
|
|
HIGHLIGHT_SUB=2
|
|
|
|
;;
|
|
|
|
"2") nano /etc/pacman-mirrors.conf
|
|
|
|
check_for_error "edit pacman-mirrors.conf"
|
|
|
|
HIGHLIGHT_SUB=3
|
|
|
|
;;
|
|
|
|
"3") rank_mirrors
|
|
|
|
HIGHLIGHT_SUB=4
|
|
|
|
;;
|
|
|
|
|
2017-03-13 03:55:49 +00:00
|
|
|
*) HIGHLIGHT_SUB=1
|
2017-03-13 03:28:43 +00:00
|
|
|
loopmeu=0
|
|
|
|
return 0
|
|
|
|
;;
|
2017-02-28 22:53:26 +00:00
|
|
|
esac
|
2017-03-13 03:28:43 +00:00
|
|
|
done
|
2017-02-28 22:53:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-18 12:54:09 +00:00
|
|
|
rank_mirrors() {
|
2017-02-22 17:39:22 +00:00
|
|
|
#Choose the branch for mirrorlist
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_MirrorBranch " --radiolist "\n$_UseSpaceBar\n " 0 0 3 \
|
2017-03-05 11:56:46 +00:00
|
|
|
"stable" "-" on \
|
2017-02-18 12:54:09 +00:00
|
|
|
"testing" "-" off \
|
2017-03-13 23:38:00 +00:00
|
|
|
"unstable" "-" off 2>${ANSWER}
|
2017-03-19 21:48:59 +00:00
|
|
|
local branch="$(<${ANSWER})"
|
2017-02-18 19:43:21 +00:00
|
|
|
clear
|
2017-03-13 23:38:00 +00:00
|
|
|
if [[ ! -z ${branch} ]]; then
|
|
|
|
pacman-mirrors -gib "${branch}"
|
|
|
|
ini branch "${branch}"
|
2017-03-03 00:12:01 +00:00
|
|
|
fi
|
2017-02-18 12:54:09 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# Simple code to show devices / partitions.
|
|
|
|
show_devices() {
|
2017-02-27 18:34:03 +00:00
|
|
|
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
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_ErrTitle " --msgbox "\n$_ErrNoMount\n " 0 0
|
2017-03-05 22:17:28 +00:00
|
|
|
ANSWER=0
|
2017-03-02 03:59:18 +00:00
|
|
|
HIGHLIGHT=0
|
2017-03-01 15:17:22 +00:00
|
|
|
return 1
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ensure that Manjaro has been installed
|
|
|
|
check_base() {
|
2017-03-05 22:17:28 +00:00
|
|
|
check_mount
|
|
|
|
if [[ $? -eq 0 ]]; then
|
2017-03-05 02:08:10 +00:00
|
|
|
if [[ ! -e /mnt/.base_installed ]]; then
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_ErrTitle " --msgbox "\n$_ErrNoBase\n " 0 0
|
2017-03-05 22:17:28 +00:00
|
|
|
ANSWER=1
|
2017-03-05 02:08:10 +00:00
|
|
|
HIGHLIGHT=1
|
2017-03-10 18:48:26 +00:00
|
|
|
HIGHLIGHT_SUB=2
|
2017-03-05 02:08:10 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2017-03-05 22:17:28 +00:00
|
|
|
else
|
|
|
|
return 1
|
2017-02-17 04:19:17 +00:00
|
|
|
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() {
|
2017-02-28 00:36:51 +00:00
|
|
|
if [[ ! $(pacman -Q $1) ]]; then
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_InstPkg " --infobox "\n$_InstPkg '${1}'\n " 0 0
|
2017-03-02 23:13:05 +00:00
|
|
|
sleep 2
|
2017-03-03 02:27:56 +00:00
|
|
|
clear
|
2017-03-02 23:13:05 +00:00
|
|
|
pacman -Sy --noconfirm $1 2>$ERR
|
2017-02-24 15:15:57 +00:00
|
|
|
check_for_error "Install needed pkg $1." $?
|
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
2017-02-19 11:01:19 +00:00
|
|
|
|
2017-02-26 17:07:09 +00:00
|
|
|
# return list of profiles not containing >openrc flag in Packages-Desktop
|
|
|
|
evaluate_profiles() {
|
2017-02-27 18:34:03 +00:00
|
|
|
echo "" > /tmp/.systemd_only
|
|
|
|
for p in $(find $PROFILES/{manjaro,community} -mindepth 1 -maxdepth 1 -type d ! -name 'netinstall' ! -name 'architect'); do
|
|
|
|
[[ ! $(grep ">openrc" $p/Packages-Desktop) ]] && echo $p | cut -f7 -d'/' >> /tmp/.systemd_only
|
|
|
|
done
|
|
|
|
echo $(cat /tmp/.systemd_only)
|
2017-02-26 17:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# verify if profile is available for openrc
|
|
|
|
evaluate_openrc() {
|
2017-02-27 18:34:03 +00:00
|
|
|
if [[ ! $(grep ">openrc" $PROFILES/*/$(cat /tmp/.desktop)/Packages-Desktop) ]]; then
|
2017-03-13 17:09:20 +00:00
|
|
|
DIALOG " $_ErrInit " --menu "\n[Manjaro-$(cat /tmp/.desktop)] $_WarnInit\n " 0 0 2 \
|
2017-02-27 18:34:03 +00:00
|
|
|
"1" "$_DiffPro" \
|
|
|
|
"2" "$_InstSystd" 2>${ANSWER}
|
|
|
|
check_for_error "selected systemd-only profile [$(cat /tmp/.desktop)] with openrc base. -> $(cat ${ANSWER})"
|
|
|
|
case $(cat ${ANSWER}) in
|
|
|
|
"1") install_desktop_menu
|
|
|
|
;;
|
|
|
|
"2") install_base
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2017-03-15 20:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
grub_mkconfig() {
|
|
|
|
arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>$ERR
|
|
|
|
check_for_error "grub-mkconfig" $?
|
|
|
|
}
|
2017-02-27 17:23:39 +00:00
|
|
|
|
2017-02-27 18:34:03 +00:00
|
|
|
final_check() {
|
2017-02-27 17:23:39 +00:00
|
|
|
CHECKLIST=/tmp/.final_check
|
|
|
|
# Empty the list
|
|
|
|
echo "" > ${CHECKLIST}
|
2017-03-05 20:35:09 +00:00
|
|
|
|
2017-02-27 17:23:39 +00:00
|
|
|
# Check if base is installed
|
2017-03-05 20:35:09 +00:00
|
|
|
if [[ ! -e /mnt/.base_installed ]]; then
|
2017-03-11 18:48:15 +00:00
|
|
|
echo "- $_BaseCheck" >> ${CHECKLIST}
|
2017-02-27 17:23:39 +00:00
|
|
|
else
|
2017-03-05 20:35:09 +00:00
|
|
|
# Check if bootloader is installed
|
|
|
|
if [[ $SYSTEM == "BIOS" ]]; then
|
2017-03-11 18:48:15 +00:00
|
|
|
arch_chroot "pacman -Qq grub" &> /dev/null || echo "- $_BootlCheck" >> ${CHECKLIST}
|
2017-03-05 20:35:09 +00:00
|
|
|
else
|
2017-03-11 18:48:15 +00:00
|
|
|
[[ -e /mnt/boot/efi/EFI/manjaro_grub/grubx64.efi ]] || [[ -e /mnt/boot/EFI/manjaro_grub/grubx64.efi ]] || echo "- $_BootlCheck" >> ${CHECKLIST}
|
2017-03-05 20:35:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if fstab is generated
|
2017-03-11 18:48:15 +00:00
|
|
|
$(grep -qv '^#' /mnt/etc/fstab 2>/dev/null) || echo "- $_FstabCheck" >> ${CHECKLIST}
|
2017-03-05 20:35:09 +00:00
|
|
|
|
2017-03-11 18:18:25 +00:00
|
|
|
# Check if video-driver has been installed
|
2017-03-15 01:04:34 +00:00
|
|
|
[[ ! -e /mnt/.video_installed ]] && echo "- $_GCCheck" >> ${CHECKLIST}
|
2017-03-11 18:18:25 +00:00
|
|
|
|
2017-03-05 20:35:09 +00:00
|
|
|
# Check if locales have been generated
|
2017-03-11 18:48:15 +00:00
|
|
|
[[ $(manjaro-chroot /mnt 'locale -a' | wc -l) -ge '3' ]] || echo "- $_LocaleCheck" >> ${CHECKLIST}
|
2017-03-05 20:35:09 +00:00
|
|
|
|
|
|
|
# Check if root password has been set
|
2017-03-11 18:48:15 +00:00
|
|
|
manjaro-chroot /mnt 'passwd --status root' | cut -d' ' -f2 | grep -q 'NP' && echo "- $_RootCheck" >> ${CHECKLIST}
|
2017-03-05 20:35:09 +00:00
|
|
|
|
|
|
|
# check if user account has been generated
|
2017-03-11 18:48:15 +00:00
|
|
|
[[ $(ls /mnt/home 2>/dev/null) == "" ]] && echo "- $_UserCheck" >> ${CHECKLIST}
|
2017-02-27 17:23:39 +00:00
|
|
|
fi
|
2017-02-27 18:34:03 +00:00
|
|
|
}
|
2017-02-28 23:05:31 +00:00
|
|
|
|
|
|
|
exit_done() {
|
2017-03-05 20:33:35 +00:00
|
|
|
if [[ $(lsblk -o MOUNTPOINT | grep ${MOUNTPOINT} 2>/dev/null) != "" ]]; then
|
2017-02-28 23:05:31 +00:00
|
|
|
final_check
|
2017-03-13 22:35:14 +00:00
|
|
|
dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --yesno "$(printf "\n$_CloseInstBody\n$(cat ${CHECKLIST})\n ")" 0 0
|
2017-02-28 23:05:31 +00:00
|
|
|
if [[ $? -eq 0 ]]; then
|
2017-03-01 22:00:20 +00:00
|
|
|
check_for_error "exit installer."
|
2017-03-13 17:09:20 +00:00
|
|
|
dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --yesno "\n$_LogInfo ${TARGLOG}\n " 0 0
|
2017-02-28 23:05:31 +00:00
|
|
|
if [[ $? -eq 0 ]]; then
|
2017-03-01 22:13:02 +00:00
|
|
|
[[ -e ${TARGLOG} ]] && cat ${LOGFILE} >> ${TARGLOG} || cp ${LOGFILE} ${TARGLOG}
|
2017-02-28 23:05:31 +00:00
|
|
|
fi
|
2017-03-01 22:13:02 +00:00
|
|
|
umount_partitions
|
2017-02-28 23:05:31 +00:00
|
|
|
clear
|
2017-03-01 04:06:23 +00:00
|
|
|
exit 0
|
2017-03-02 03:49:48 +00:00
|
|
|
else
|
|
|
|
[[ menu_opt == "advanced" ]] && main_menu_full || main_menu
|
2017-02-28 23:05:31 +00:00
|
|
|
fi
|
|
|
|
else
|
2017-03-13 17:09:20 +00:00
|
|
|
dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --yesno "\n$_CloseInstBody\n " 0 0
|
2017-02-28 23:05:31 +00:00
|
|
|
if [[ $? -eq 0 ]]; then
|
2017-03-01 22:13:02 +00:00
|
|
|
umount_partitions
|
2017-02-28 23:05:31 +00:00
|
|
|
clear
|
2017-03-01 04:06:23 +00:00
|
|
|
exit 0
|
2017-03-02 03:49:48 +00:00
|
|
|
else
|
|
|
|
[[ menu_opt == "advanced" ]] && main_menu_full || main_menu
|
2017-02-28 23:05:31 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|