2017-03-02 03:04:01 +00:00
|
|
|
# !/bin/bash
|
|
|
|
#
|
|
|
|
# Architect Installation Framework (2016-2017)
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# 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-03-07 18:32:01 +00:00
|
|
|
setup_profiles() {
|
|
|
|
# setup profiles with either git or package
|
|
|
|
if [[ -e /tmp/.git_profiles ]]; then
|
|
|
|
PROFILES="$DATADIR/profiles"
|
|
|
|
clear
|
|
|
|
# install git if not already installed
|
|
|
|
inst_needed git
|
|
|
|
# download manjaro-tools.-isoprofiles git repo
|
|
|
|
if [[ -e $PROFILES ]]; then
|
|
|
|
git -C $PROFILES pull 2>$ERR
|
|
|
|
check_for_error "pull profiles repo" $?
|
|
|
|
else
|
|
|
|
git clone --depth 1 https://github.com/manjaro/iso-profiles.git $PROFILES 2>$ERR
|
|
|
|
check_for_error "clone profiles repo" $?
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
PROFILES="/usr/share/manjaro-tools/iso-profiles"
|
|
|
|
# Only show this information box once
|
|
|
|
clear
|
|
|
|
pacman -Sy --noconfirm $p manjaro-iso-profiles-{base,official,community} 2>$ERR
|
|
|
|
check_for_error "update profiles pkgs" $?
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
enable_services() {
|
|
|
|
# Enable services in the chosen profile
|
|
|
|
echo "Enabling services"
|
|
|
|
if [[ -e /mnt/.openrc ]]; then
|
|
|
|
eval $(grep -e "enable_openrc=" $profile | sed 's/# //g')
|
|
|
|
echo "${enable_openrc[@]}" | xargs -n1 > /tmp/.services
|
|
|
|
echo /mnt/etc/init.d/* | xargs -n1 | cut -d/ -f5 > /tmp/.available_services
|
|
|
|
grep -f /tmp/.available_services /tmp/.services > /tmp/.fix && mv /tmp/.fix /tmp/.services
|
|
|
|
for service in $(cat /tmp/.services) ; do
|
|
|
|
arch_chroot "rc-update add $service default" 2>$ERR
|
|
|
|
check_for_error "enable $service" $?
|
|
|
|
done
|
|
|
|
|
|
|
|
# enable display manager for openrc
|
|
|
|
if [[ "$(cat /tmp/.display-manager)" == sddm ]]; then
|
|
|
|
sed -i "s/$(grep "DISPLAYMANAGER=" /mnt/etc/conf.d/xdm)/DISPLAYMANAGER=\"sddm\"/g" /mnt/etc/conf.d/xdm
|
|
|
|
arch_chroot "rc-update add xdm default" 2>$ERR
|
|
|
|
check_for_error "add xdm default: sddm" "$?"
|
|
|
|
set_sddm_ck
|
|
|
|
elif [[ "$(cat /tmp/.display-manager)" == lightdm ]]; then
|
|
|
|
set_lightdm_greeter
|
|
|
|
sed -i "s/$(grep "DISPLAYMANAGER=" /mnt/etc/conf.d/xdm)/DISPLAYMANAGER=\"lightdm\"/g" /mnt/etc/conf.d/xdm
|
|
|
|
arch_chroot "rc-update add xdm default" 2>$ERR
|
|
|
|
check_for_error "add xdm default: lightdm" "$?"
|
|
|
|
|
|
|
|
else
|
|
|
|
check_for_error "no DM installed."
|
|
|
|
echo "no display manager was installed."
|
|
|
|
sleep 2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
eval $(grep -e "enable_systemd=" $profile | sed 's/# //g')
|
|
|
|
echo "${enable_systemd[@]}" | xargs -n1 > /tmp/.services
|
|
|
|
echo /mnt/usr/lib/systemd/system/* | xargs -n1 | cut -d/ -f7 | sed 's/.service//g' > /tmp/.available_services
|
|
|
|
grep -f /tmp/.available_services /tmp/.services > /tmp/.fix && mv /tmp/.fix /tmp/.services
|
|
|
|
arch_chroot "systemctl enable $(cat /tmp/.services)" 2>$ERR
|
|
|
|
check_for_error "enable $(cat /tmp/.services)" $?
|
|
|
|
arch_chroot "systemctl disable pacman-init" 2>$ERR
|
|
|
|
check_for_error "disable pacman-init" $?
|
|
|
|
|
|
|
|
# enable display manager for systemd
|
|
|
|
if [[ "$(cat /tmp/.display-manager)" == lightdm ]]; then
|
|
|
|
set_lightdm_greeter
|
|
|
|
arch_chroot "systemctl enable lightdm" 2>$ERR
|
|
|
|
check_for_error "enable lightdm" "$?"
|
|
|
|
elif [[ "$(cat /tmp/.display-manager)" == sddm ]]; then
|
|
|
|
arch_chroot "systemctl enable sddm" 2>$ERR
|
|
|
|
check_for_error "enable sddm" "$?"
|
|
|
|
elif [[ "$(cat /tmp/.display-manager)" == gdm ]]; then
|
|
|
|
arch_chroot "systemctl enable gdm" 2>$ERR
|
|
|
|
check_for_error "enable gdm" "$?"
|
|
|
|
else
|
|
|
|
check_for_error "no DM installed."
|
|
|
|
echo "no display manager was installed"
|
|
|
|
sleep 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_extra() {
|
|
|
|
|
|
|
|
# Offer to install various "common" packages.
|
|
|
|
DIALOG " $_InstComTitle " --checklist "\n$_InstComBody\n\n$_UseSpaceBar" 0 50 20 \
|
|
|
|
"manjaro-settings-manager" "-" off \
|
|
|
|
"pamac" "-" off \
|
|
|
|
"octopi" "-" off \
|
|
|
|
"pacli" "-" off \
|
|
|
|
"pacui" "-" off \
|
|
|
|
"fish" "-" off \
|
|
|
|
"fisherman" "-" off \
|
|
|
|
"zsh" "-" on \
|
|
|
|
"zsh-completions" "-" on \
|
|
|
|
"manjaro-zsh-config" "-" on \
|
|
|
|
"grml-zsh-config" "-" off \
|
|
|
|
"mhwd-chroot" "-" off \
|
|
|
|
"bmenu" "-" on \
|
|
|
|
"clonezilla" "-" off \
|
|
|
|
"snapper" "-" off \
|
|
|
|
"snap-pac" "-" off \
|
|
|
|
"manjaro-tools-iso" "-" off \
|
|
|
|
"manjaro-tools-base" "-" off \
|
|
|
|
"manjaro-tools-pkg" "-" off 2>${PACKAGES}
|
|
|
|
|
|
|
|
# If at least one package, install.
|
|
|
|
if [[ $(cat ${PACKAGES}) != "" ]]; then
|
|
|
|
clear
|
|
|
|
basestrap -i ${MOUNTPOINT} $(cat ${PACKAGES}) 2>$ERR
|
|
|
|
check_for_error "basestrap -i ${MOUNTPOINT} $(cat ${PACKAGES})" "$?"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
filter_packages() {
|
|
|
|
# Parse package list based on user input and remove parts that don't belong to pacman
|
2017-03-08 03:30:13 +00:00
|
|
|
cat $PROFILES/shared/Packages-Root "$target_desktop" >> /mnt/.base 2>$ERR
|
2017-03-07 18:32:01 +00:00
|
|
|
echo "nilfs-utils" >> /mnt/.base
|
|
|
|
if [[ -e /mnt/.openrc ]]; then
|
|
|
|
evaluate_openrc
|
|
|
|
# Remove any packages tagged with >systemd and remove >openrc tags
|
|
|
|
sed -i '/>systemd/d' /mnt/.base
|
|
|
|
sed -i 's/>openrc //g' /mnt/.base
|
|
|
|
else
|
|
|
|
# Remove any packages tagged with >openrc and remove >systemd tags
|
|
|
|
sed -i '/>openrc/d' /mnt/.base
|
|
|
|
sed -i 's/>systemd //g' /mnt/.base
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$(uname -m)" == "x86_64" ]]; then
|
|
|
|
# Remove any packages tagged with >i686 and remove >x86_64 tags
|
|
|
|
sed -i '/>i686/d' /mnt/.base
|
|
|
|
sed -i '/>nonfree_i686/d' /mnt/.base
|
|
|
|
sed -i 's/>x86_64 //g' /mnt/.base
|
|
|
|
else
|
|
|
|
# Remove any packages tagged with >x86_64 and remove >i686 tags
|
|
|
|
sed -i '/>x86_64/d' /mnt/.base
|
|
|
|
sed -i '/>nonfree_x86_64/d' /mnt/.base
|
|
|
|
sed -i 's/>i686 //g' /mnt/.base
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If multilib repo is enabled, install multilib packages
|
|
|
|
if grep -q "^[multilib]" /etc/pacman.conf ; then
|
|
|
|
# Remove >multilib tags
|
|
|
|
sed -i 's/>multilib //g' /mnt/.base
|
|
|
|
sed -i 's/>nonfree_multilib //g' /mnt/.base
|
|
|
|
else
|
|
|
|
# Remove lines with >multilib tag
|
|
|
|
sed -i '/>multilib/d' /mnt/.base
|
|
|
|
sed -i '/>nonfree_multilib/d' /mnt/.base
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q ">extra" /mnt/.base;then
|
|
|
|
# User to select base|extra profile
|
|
|
|
DIALOG "$_ExtraTitle" --no-cancel --menu "\n$_ExtraBody" 0 0 2 \
|
|
|
|
"1" "full" \
|
|
|
|
"2" "minimal" 2>/tmp/.version
|
|
|
|
|
|
|
|
if [[ $(cat /tmp/.version) -eq 2 ]]; then
|
|
|
|
check_for_error "selected 'minimal' profile"
|
|
|
|
touch /tmp/.minimal
|
|
|
|
else
|
|
|
|
check_for_error "selected 'full' profile"
|
|
|
|
[[ -e /tmp/.minimal ]] && rm /tmp/.minimal
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e /tmp/.minimal ]]; then
|
|
|
|
# Remove >extra tags
|
|
|
|
sed -i 's/>basic //g' /mnt/.base
|
|
|
|
sed -i '/>extra/d' /mnt/.base
|
|
|
|
else
|
|
|
|
# Remove >basic tags
|
|
|
|
sed -i 's/>extra //g' /mnt/.base
|
|
|
|
sed -i '/>basic/d' /mnt/.base
|
|
|
|
fi
|
|
|
|
# remove >manjaro flags and >sonar flags+pkgs until we support it properly
|
|
|
|
sed -i '/>sonar/d' /mnt/.base
|
|
|
|
sed -i 's/>manjaro //g' /mnt/.base
|
|
|
|
# Remove commented lines
|
|
|
|
# remove everything except the first word of every lines
|
|
|
|
sed -i 's/\s.*$//' /mnt/.base
|
|
|
|
# Remove lines with #
|
|
|
|
sed -i '/#/d' /mnt/.base
|
|
|
|
# remove KERNEL variable
|
|
|
|
sed -i '/KERNEL/d' /mnt/.base
|
|
|
|
# Remove empty lines
|
|
|
|
sed -i '/^\s*$/d' /mnt/.base
|
|
|
|
# remove zsh
|
|
|
|
sed -i '/^zsh$/d' /mnt/.base
|
|
|
|
|
|
|
|
# Remove packages that have been dropped from repos
|
|
|
|
pacman -Ssq > /tmp/.available_packages
|
|
|
|
grep -f /tmp/.available_packages /mnt/.base > /tmp/.tmp
|
|
|
|
mv /tmp/.tmp /mnt/.base
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
install_base() {
|
2017-03-10 17:51:37 +00:00
|
|
|
if [[ -e /mnt/.base_installed ]]; then
|
2017-03-10 19:47:08 +00:00
|
|
|
DIALOG " $_InstBseTitle " --yesno "\n$_WarnInstBase\n\n" 0 0 && rm /mnt/.base_installed || return 0
|
2017-03-10 17:51:37 +00:00
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
# Prep variables
|
2017-03-07 18:32:01 +00:00
|
|
|
setup_profiles
|
2017-02-17 04:19:17 +00:00
|
|
|
echo "" > ${PACKAGES}
|
|
|
|
echo "" > ${ANSWER}
|
|
|
|
BTRF_CHECK=$(echo "btrfs-progs" "-" off)
|
|
|
|
F2FS_CHECK=$(echo "f2fs-tools" "-" off)
|
|
|
|
KERNEL="n"
|
|
|
|
mhwd-kernel -l | awk '/linux/ {print $2}' > /tmp/.available_kernels
|
|
|
|
kernels=$(cat /tmp/.available_kernels)
|
|
|
|
|
|
|
|
# User to select initsystem
|
2017-02-28 02:22:55 +00:00
|
|
|
DIALOG " $_ChsInit " --menu "\n$_WarnOrc\n" 0 0 2 \
|
2017-02-17 04:19:17 +00:00
|
|
|
"1" "systemd" \
|
|
|
|
"2" "openrc" 2>${INIT}
|
2017-03-01 20:46:40 +00:00
|
|
|
|
|
|
|
if [[ $(cat ${INIT}) != "" ]]; then
|
|
|
|
if [[ $(cat ${INIT}) -eq 2 ]]; then
|
|
|
|
check_for_error "init openrc"
|
|
|
|
touch /mnt/.openrc
|
|
|
|
else
|
|
|
|
check_for_error "init systemd"
|
|
|
|
[[ -e /mnt/.openrc ]] && rm /mnt/.openrc
|
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
else
|
2017-03-01 20:46:40 +00:00
|
|
|
return 0
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
2017-03-07 18:32:01 +00:00
|
|
|
# Create the base list of packages
|
|
|
|
touch /mnt/.base
|
2017-02-17 04:19:17 +00:00
|
|
|
# Choose kernel and possibly base-devel
|
2017-02-20 22:05:16 +00:00
|
|
|
DIALOG " $_InstBseTitle " --checklist "$_InstStandBseBody$_UseSpaceBar" 0 0 12 \
|
2017-02-17 04:19:17 +00:00
|
|
|
$(cat /tmp/.available_kernels |awk '$0=$0" - off"') \
|
2017-03-01 18:47:53 +00:00
|
|
|
"base-devel" "-" off 2>${PACKAGES} || return 0
|
2017-02-28 00:59:51 +00:00
|
|
|
cat ${PACKAGES} >> /mnt/.base
|
2017-03-01 20:46:40 +00:00
|
|
|
|
2017-03-05 02:47:18 +00:00
|
|
|
if [[ $(cat ${PACKAGES}) == "" ]]; then
|
2017-02-17 04:19:17 +00:00
|
|
|
# Check to see if a kernel is already installed
|
|
|
|
ls ${MOUNTPOINT}/boot/*.img >/dev/null 2>&1
|
|
|
|
if [[ $? == 0 ]]; then
|
2017-02-27 01:06:38 +00:00
|
|
|
check_for_error "linux-$(ls ${MOUNTPOINT}/boot/*.img | cut -d'-' -f2) is already installed"
|
2017-02-17 04:19:17 +00:00
|
|
|
KERNEL="y"
|
|
|
|
else
|
|
|
|
for i in $(cat /tmp/.available_kernels); do
|
|
|
|
[[ $(cat ${PACKAGES} | grep ${i}) != "" ]] && KERNEL="y" && break;
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
# If no kernel selected, warn and restart
|
|
|
|
if [[ $KERNEL == "n" ]]; then
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "$_ErrNoKernel" 0 0
|
2017-03-05 02:47:18 +00:00
|
|
|
check_for_error "no kernel installed."
|
2017-03-01 20:46:40 +00:00
|
|
|
return 0
|
2017-03-05 02:47:18 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
check_for_error "selected: $(cat ${PACKAGES})"
|
|
|
|
|
|
|
|
# Choose wanted kernel modules
|
2017-03-05 16:58:10 +00:00
|
|
|
DIALOG " $_ChsAddPkgs " --checklist "\n\n$_UseSpaceBar" 0 0 12 \
|
2017-03-05 02:47:18 +00:00
|
|
|
"KERNEL-headers" "-" off \
|
|
|
|
"KERNEL-acpi_call" "-" on \
|
|
|
|
"KERNEL-ndiswrapper" "-" on \
|
|
|
|
"KERNEL-broadcom-wl" "-" off \
|
|
|
|
"KERNEL-r8168" "-" off \
|
|
|
|
"KERNEL-rt3562sta" "-" off \
|
|
|
|
"KERNEL-tp_smapi" "-" off \
|
|
|
|
"KERNEL-vhba-module" "-" off \
|
|
|
|
"KERNEL-virtualbox-guest-modules" "-" off \
|
|
|
|
"KERNEL-virtualbox-host-modules" "-" off \
|
|
|
|
"KERNEL-spl" "-" off \
|
|
|
|
"KERNEL-zfs" "-" off 2>/tmp/.modules
|
|
|
|
[[ $(cat /tmp/.modules) == "" ]] && return 0
|
|
|
|
|
|
|
|
check_for_error "modules: $(cat /tmp/.modules)"
|
|
|
|
for kernel in $(cat ${PACKAGES} | grep -v "base-devel") ; do
|
|
|
|
cat /tmp/.modules | sed "s/KERNEL/\ $kernel/g" >> /mnt/.base
|
|
|
|
done
|
|
|
|
|
|
|
|
# If a selection made, act
|
|
|
|
if [[ $(cat ${PACKAGES}) != "" ]]; then
|
|
|
|
clear
|
2017-03-09 17:01:15 +00:00
|
|
|
echo "" > /tmp/.desktop
|
2017-03-07 18:32:01 +00:00
|
|
|
filter_packages
|
2017-02-28 00:59:51 +00:00
|
|
|
check_for_error "packages to install: $(cat /mnt/.base | tr '\n' ' ')"
|
2017-02-17 04:19:17 +00:00
|
|
|
# If at least one kernel selected, proceed with installation.
|
2017-02-28 00:59:51 +00:00
|
|
|
basestrap ${MOUNTPOINT} $(cat /mnt/.base) 2>$ERR
|
2017-03-01 20:46:40 +00:00
|
|
|
check_for_error "install basepkgs" $?
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
# If root is on btrfs volume, amend mkinitcpio.conf
|
2017-02-27 01:06:38 +00:00
|
|
|
[[ $(lsblk -lno FSTYPE,MOUNTPOINT | awk '/ \/mnt$/ {print $1}') == btrfs ]] && sed -e '/^HOOKS=/s/\ fsck//g' -i ${MOUNTPOINT}/etc/mkinitcpio.conf && \
|
|
|
|
check_for_error "root on btrfs volume. amend mkinitcpio."
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
# If root is on nilfs2 volume, amend mkinitcpio.conf
|
2017-02-27 01:06:38 +00:00
|
|
|
[[ $(lsblk -lno FSTYPE,MOUNTPOINT | awk '/ \/mnt$/ {print $1}') == nilfs2 ]] && sed -e '/^HOOKS=/s/\ fsck//g' -i ${MOUNTPOINT}/etc/mkinitcpio.conf && \
|
|
|
|
check_for_error "root on nilfs2 volume. amend mkinitcpio."
|
2017-02-26 14:06:45 +00:00
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# Use mhwd to install selected kernels with right kernel modules
|
|
|
|
# This is as of yet untested
|
2017-02-23 00:36:28 +00:00
|
|
|
# arch_chroot "mhwd-kernel -i $(cat ${PACKAGES} | xargs -n1 | grep -f /tmp/.available_kernels | xargs)"
|
|
|
|
|
2017-02-17 04:19:17 +00:00
|
|
|
# If the virtual console has been set, then copy config file to installation
|
2017-02-24 15:15:57 +00:00
|
|
|
if [[ -e /tmp/vconsole.conf ]]; then
|
2017-03-09 16:19:01 +00:00
|
|
|
if [[ -e /mnt/.openrc ]]; then
|
2017-03-09 17:01:15 +00:00
|
|
|
cp -f /tmp/keymap ${MOUNTPOINT}/etc/conf.d/keymaps
|
2017-03-09 16:19:01 +00:00
|
|
|
arch_chroot "rc-update add keymaps boot"
|
|
|
|
cp -f /tmp/consolefont ${MOUNTPOINT}/etc/conf.d/consolefont
|
|
|
|
arch_chroot "rc-update add consolefont boot"
|
|
|
|
else
|
|
|
|
cp -f /tmp/vconsole.conf ${MOUNTPOINT}/etc/vconsole.conf
|
|
|
|
check_for_error "copy vconsole.conf" $?
|
|
|
|
fi
|
2017-02-24 15:15:57 +00:00
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
# If specified, copy over the pacman.conf file to the installation
|
2017-02-24 15:15:57 +00:00
|
|
|
if [[ $COPY_PACCONF -eq 1 ]]; then
|
|
|
|
cp -f /etc/pacman.conf ${MOUNTPOINT}/etc/pacman.conf
|
2017-03-01 20:46:40 +00:00
|
|
|
check_for_error "copy pacman.conf" $?
|
2017-02-24 15:15:57 +00:00
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
|
|
|
|
# if branch was chosen, use that also in installed system. If not, use the system setting
|
|
|
|
if [[ -e ${BRANCH} ]]; then
|
2017-02-23 00:36:28 +00:00
|
|
|
sed -i "/Branch =/c\Branch = $(cat ${BRANCH})/" ${MOUNTPOINT}/etc/pacman-mirrors.conf 2>$ERR
|
2017-03-01 20:46:40 +00:00
|
|
|
check_for_error "set target branch $(cat ${BRANCH})" $?
|
2017-02-17 04:19:17 +00:00
|
|
|
else
|
2017-02-23 00:36:28 +00:00
|
|
|
sed -i "/Branch =/c$(grep "Branch =" /etc/pacman-mirrors.conf)" ${MOUNTPOINT}/etc/pacman-mirrors.conf 2>$ERR
|
2017-03-01 20:46:40 +00:00
|
|
|
check_for_error "use host branch \($(grep "Branch =" /etc/pacman-mirrors.conf)\)" $?
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
2017-02-26 18:28:48 +00:00
|
|
|
touch /mnt/.base_installed
|
2017-02-27 01:06:38 +00:00
|
|
|
check_for_error "base installed succesfully."
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
install_bootloader() {
|
2017-03-06 04:26:22 +00:00
|
|
|
check_base
|
|
|
|
if [[ $? -eq 0 ]]; then
|
2017-03-02 05:02:09 +00:00
|
|
|
if [[ $SYSTEM == "BIOS" ]]; then
|
|
|
|
bios_bootloader
|
|
|
|
else
|
|
|
|
uefi_bootloader
|
|
|
|
fi
|
2017-03-05 02:08:10 +00:00
|
|
|
else
|
|
|
|
HIGHLIGHT_SUB=2
|
2017-03-05 12:32:14 +00:00
|
|
|
fi
|
2017-03-02 05:02:09 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 18:40:47 +00:00
|
|
|
uefi_bootloader() {
|
|
|
|
#Ensure again that efivarfs is mounted
|
|
|
|
[[ -z $(mount | grep /sys/firmware/efi/efivars) ]] && mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-01 20:46:40 +00:00
|
|
|
DIALOG " $_InstUefiBtTitle " --yesno "\n\n$_InstUefiBtBody\n" 0 0 || return 0
|
|
|
|
clear
|
|
|
|
basestrap ${MOUNTPOINT} grub efibootmgr dosfstools 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME grub" $?
|
|
|
|
|
2017-03-08 02:29:33 +00:00
|
|
|
DIALOG " $_InstGrub " --infobox "$_PlsWaitBody" 0 0
|
2017-03-01 20:46:40 +00:00
|
|
|
# if root is encrypted, amend /etc/default/grub
|
|
|
|
boot_encrypted_setting
|
|
|
|
#install grub
|
|
|
|
arch_chroot "grub-install --target=x86_64-efi --efi-directory=${UEFI_MOUNT} --bootloader-id=manjaro_grub --recheck" 2>$ERR
|
|
|
|
check_for_error "grub-install --target=x86_64-efi" $?
|
|
|
|
|
|
|
|
# If encryption used amend grub
|
|
|
|
[[ $LUKS_DEV != "" ]] && sed -i "s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"$LUKS_DEV\"~g" ${MOUNTPOINT}/etc/default/grub
|
|
|
|
|
|
|
|
# If root is on btrfs volume, amend grub
|
|
|
|
[[ $(lsblk -lno FSTYPE,MOUNTPOINT | awk '/ \/mnt$/ {print $1}') == btrfs ]] && \
|
|
|
|
sed -e '/GRUB_SAVEDEFAULT/ s/^#*/#/' -i ${MOUNTPOINT}/etc/default/grub
|
|
|
|
|
|
|
|
# Generate config file
|
|
|
|
arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>$ERR
|
|
|
|
check_for_error "grub-mkconfig" $?
|
|
|
|
|
|
|
|
# Ask if user wishes to set Grub as the default bootloader and act accordingly
|
|
|
|
DIALOG " $_InstUefiBtTitle " --yesno "$_SetBootDefBody ${UEFI_MOUNT}/EFI/boot $_SetBootDefBody2" 0 0
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
arch_chroot "mkdir ${UEFI_MOUNT}/EFI/boot" 2>$ERR
|
|
|
|
arch_chroot "cp -r ${UEFI_MOUNT}/EFI/manjaro_grub/grubx64.efi ${UEFI_MOUNT}/EFI/boot/bootx64.efi" 2>$ERR
|
|
|
|
check_for_error "Install GRUB" $?
|
|
|
|
DIALOG " $_InstUefiBtTitle " --infobox "\nGrub $_SetDefDoneBody" 0 0
|
|
|
|
sleep 2
|
2017-02-19 18:40:47 +00:00
|
|
|
fi
|
2017-03-01 02:32:28 +00:00
|
|
|
|
2017-03-01 20:46:40 +00:00
|
|
|
<<DISABLED_FOR_NOW
|
|
|
|
"systemd-boot")
|
|
|
|
arch_chroot "bootctl --path=${UEFI_MOUNT} install" 2>$ERR
|
|
|
|
check_for_error "systemd-boot" $?
|
|
|
|
|
|
|
|
# Deal with LVM Root
|
|
|
|
[[ $(echo $ROOT_PART | grep "/dev/mapper/") != "" ]] && bl_root=$ROOT_PART \
|
|
|
|
|| bl_root=$"PARTUUID="$(blkid -s PARTUUID ${ROOT_PART} | sed 's/.*=//g' | sed 's/"//g')
|
|
|
|
|
|
|
|
# Create default config files. First the loader
|
|
|
|
echo -e "default arch\ntimeout 10" > ${MOUNTPOINT}${UEFI_MOUNT}/loader/loader.conf 2>$ERR
|
|
|
|
|
|
|
|
# Second, the kernel conf files
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux.img ]] && \
|
|
|
|
echo -e "title\tManjaro Linux\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\noptions\troot=${bl_root} rw" \
|
|
|
|
> ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/arch.conf
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-lts.img ]] && \
|
|
|
|
echo -e "title\tManjaro Linux LTS\nlinux\t/vmlinuz-linux-lts\ninitrd\t/initramfs-linux-lts.img\noptions\troot=${bl_root} rw" \
|
|
|
|
> ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/arch-lts.conf
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-grsec.img ]] && \
|
|
|
|
echo -e "title\tManjaro Linux Grsec\nlinux\t/vmlinuz-linux-grsec\ninitrd\t/initramfs-linux-grsec.img\noptions\troot=${bl_root} rw" \
|
|
|
|
> ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/arch-grsec.conf
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-zen.img ]] && \
|
|
|
|
echo -e "title\tManjaro Linux Zen\nlinux\t/vmlinuz-linux-zen\ninitrd\t/initramfs-linux-zen.img\noptions\troot=${bl_root} rw" \
|
|
|
|
> ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/arch-zen.conf
|
|
|
|
|
|
|
|
# Finally, amend kernel conf files for LUKS and BTRFS
|
|
|
|
sysdconf=$(ls ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/arch*.conf)
|
|
|
|
for i in ${sysdconf}; do
|
|
|
|
[[ $LUKS_DEV != "" ]] && sed -i "s~rw~$LUKS_DEV rw~g" ${i}
|
|
|
|
done
|
|
|
|
DISABLED_FOR_NOW
|
2017-02-19 18:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Grub auto-detects installed kernels, etc. Syslinux does not, hence the extra code for it.
|
|
|
|
bios_bootloader() {
|
|
|
|
DIALOG " $_InstBiosBtTitle " --menu "$_InstBiosBtBody" 0 0 2 \
|
|
|
|
"grub" "-" \
|
2017-03-06 04:26:22 +00:00
|
|
|
"grub + os-prober" "-" 2>${PACKAGES} || return 0
|
2017-02-19 18:40:47 +00:00
|
|
|
clear
|
|
|
|
|
|
|
|
# If something has been selected, act
|
|
|
|
if [[ $(cat ${PACKAGES}) != "" ]]; then
|
|
|
|
sed -i 's/+\|\"//g' ${PACKAGES}
|
2017-02-20 03:55:39 +00:00
|
|
|
basestrap ${MOUNTPOINT} $(cat ${PACKAGES}) 2>$ERR
|
2017-02-24 15:15:57 +00:00
|
|
|
check_for_error "$FUNCNAME" $?
|
2017-02-19 18:40:47 +00:00
|
|
|
|
|
|
|
# If Grub, select device
|
|
|
|
if [[ $(cat ${PACKAGES} | grep "grub") != "" ]]; then
|
|
|
|
select_device
|
2017-02-26 14:06:45 +00:00
|
|
|
# if root is encrypted, amend /etc/default/grub
|
|
|
|
boot_encrypted_setting
|
2017-02-19 18:40:47 +00:00
|
|
|
# If a device has been selected, configure
|
|
|
|
if [[ $DEVICE != "" ]]; then
|
2017-03-08 02:29:33 +00:00
|
|
|
DIALOG " $_InstGrub " --infobox "$_PlsWaitBody" 0 0
|
2017-02-20 03:55:39 +00:00
|
|
|
arch_chroot "grub-install --target=i386-pc --recheck $DEVICE" 2>$ERR
|
2017-03-01 20:46:40 +00:00
|
|
|
check_for_error "grub-install --target=i386-pc" $?
|
2017-02-19 18:40:47 +00:00
|
|
|
|
|
|
|
# if /boot is LVM (whether using a seperate /boot mount or not), amend grub
|
|
|
|
if ( [[ $LVM -eq 1 ]] && [[ $LVM_SEP_BOOT -eq 0 ]] ) || [[ $LVM_SEP_BOOT -eq 2 ]]; then
|
|
|
|
sed -i "s/GRUB_PRELOAD_MODULES=\"\"/GRUB_PRELOAD_MODULES=\"lvm\"/g" ${MOUNTPOINT}/etc/default/grub
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If encryption used amend grub
|
|
|
|
[[ $LUKS_DEV != "" ]] && sed -i "s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"$LUKS_DEV\"~g" ${MOUNTPOINT}/etc/default/grub
|
|
|
|
|
|
|
|
# If root is on btrfs volume, amend grub
|
|
|
|
[[ $(lsblk -lno FSTYPE,MOUNTPOINT | awk '/ \/mnt$/ {print $1}') == btrfs ]] && \
|
|
|
|
sed -e '/GRUB_SAVEDEFAULT/ s/^#*/#/' -i ${MOUNTPOINT}/etc/default/grub
|
|
|
|
|
2017-02-21 21:23:00 +00:00
|
|
|
arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>$ERR
|
2017-02-24 15:15:57 +00:00
|
|
|
check_for_error "grub-mkconfig" $?
|
2017-02-23 19:38:49 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Syslinux
|
|
|
|
DIALOG " $_InstSysTitle " --menu "$_InstSysBody" 0 0 2 \
|
|
|
|
"syslinux-install_update -iam" "[MBR]" "syslinux-install_update -i" "[/]" 2>${PACKAGES}
|
|
|
|
|
|
|
|
# If an installation method has been chosen, run it
|
|
|
|
if [[ $(cat ${PACKAGES}) != "" ]]; then
|
|
|
|
arch_chroot "$(cat ${PACKAGES})" 2>$ERR
|
2017-02-24 15:15:57 +00:00
|
|
|
check_for_error "syslinux-install" $?
|
2017-02-19 18:40:47 +00:00
|
|
|
|
|
|
|
# Amend configuration file. First remove all existing entries, then input new ones.
|
|
|
|
sed -i '/^LABEL.*$/,$d' ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
#echo -e "\n" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
|
|
|
|
# First the "main" entries
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux\n\tLINUX \
|
|
|
|
../vmlinuz-linux\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-lts.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux realtime LTS\n\tLINUX \
|
|
|
|
../vmlinuz-linux-lts\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-lts.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-grsec.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux realtime\n\tLINUX \
|
|
|
|
../vmlinuz-linux-grsec\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-grsec.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-zen.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux release candidate\n\tLINUX \
|
|
|
|
../vmlinuz-linux-zen\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-zen.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
|
|
|
|
# Second the "fallback" entries
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux Fallback\n\tLINUX \
|
|
|
|
../vmlinuz-linux\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-lts.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux Fallback realtime LTS\n\tLINUX \
|
|
|
|
../vmlinuz-linux-lts\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-lts-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-grsec.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux Fallback realtime\n\tLINUX \
|
|
|
|
../vmlinuz-linux-grsec\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-grsec-fallback.img" \
|
|
|
|
>> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
[[ -e ${MOUNTPOINT}/boot/initramfs-linux-zen.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL Manjaro Linux Fallbacl Zen\n\tLINUX \
|
|
|
|
../vmlinuz-linux-zen\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-zen-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
|
|
|
|
# Third, amend for LUKS
|
|
|
|
[[ $LUKS_DEV != "" ]] && sed -i "s~rw~$LUKS_DEV rw~g" ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
|
|
|
|
# Finally, re-add the "default" entries
|
|
|
|
echo -e "\n\nLABEL hdt\n\tMENU LABEL HDT (Hardware Detection Tool)\n\tCOM32 hdt.c32" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
echo -e "\n\nLABEL reboot\n\tMENU LABEL Reboot\n\tCOM32 reboot.c32" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
echo -e "\n\n#LABEL windows\n\t#MENU LABEL Windows\n\t#COM32 chain.c32\n\t#APPEND root=/dev/sda2 rw" \
|
|
|
|
>> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
echo -e "\n\nLABEL poweroff\n\tMENU LABEL Poweroff\n\tCOM32 poweroff.c32" ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
|
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
2017-02-19 18:40:47 +00:00
|
|
|
fi
|
|
|
|
}
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
boot_encrypted_setting() {
|
|
|
|
# Check if there is separate encrypted /boot partition
|
|
|
|
if $(lsblk | grep '/mnt/boot' | grep -q 'crypt' ); then
|
|
|
|
echo "GRUB_ENABLE_CRYPTODISK=y" >> /mnt/etc/default/grub
|
|
|
|
# Check if root is encrypted and there is no separate /boot
|
|
|
|
elif $(lsblk | grep "/mnt$" | grep -q 'crypt' ) && [[ $(lsblk | grep "/mnt/boot$") == "" ]]; then
|
|
|
|
echo "GRUB_ENABLE_CRYPTODISK=y" >> /mnt/etc/default/grub
|
|
|
|
else
|
|
|
|
true
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function will not allow incorrect UUID type for installed system.
|
|
|
|
generate_fstab() {
|
|
|
|
DIALOG " $_ConfBseFstab " --menu "$_FstabBody" 0 0 4 \
|
|
|
|
"fstabgen -p" "$_FstabDevName" \
|
|
|
|
"fstabgen -L -p" "$_FstabDevLabel" \
|
|
|
|
"fstabgen -U -p" "$_FstabDevUUID" \
|
|
|
|
"fstabgen -t PARTUUID -p" "$_FstabDevPtUUID" 2>${ANSWER}
|
|
|
|
|
|
|
|
if [[ $(cat ${ANSWER}) != "" ]]; then
|
|
|
|
if [[ $SYSTEM == "BIOS" ]] && [[ $(cat ${ANSWER}) == "fstabgen -t PARTUUID -p" ]]; then
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "$_FstabErr" 0 0
|
|
|
|
generate_fstab
|
2017-03-01 20:46:40 +00:00
|
|
|
else
|
2017-03-02 05:02:09 +00:00
|
|
|
$(cat ${ANSWER}) ${MOUNTPOINT} > ${MOUNTPOINT}/etc/fstab 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME" $?
|
|
|
|
[[ -f ${MOUNTPOINT}/swapfile ]] && sed -i "s/\\${MOUNTPOINT}//" ${MOUNTPOINT}/etc/fstab
|
2017-03-01 20:46:40 +00:00
|
|
|
fi
|
2017-03-02 05:02:09 +00:00
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
run_mkinitcpio() {
|
|
|
|
clear
|
|
|
|
KERNEL=""
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# If LVM and/or LUKS used, add the relevant hook(s)
|
|
|
|
([[ $LVM -eq 1 ]] && [[ $LUKS -eq 0 ]]) && { sed -i 's/block filesystems/block lvm2 filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>$ERR || check_for_error "lVM2 hooks" $?; }
|
|
|
|
([[ $LVM -eq 1 ]] && [[ $LUKS -eq 1 ]]) && { sed -i 's/block filesystems/block encrypt lvm2 filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>$ERR || check_for_error "lVM/LUKS hooks" $?; }
|
|
|
|
([[ $LVM -eq 0 ]] && [[ $LUKS -eq 1 ]]) && { sed -i 's/block filesystems/block encrypt filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>$ERR || check_for_error "LUKS hooks" $?; }
|
|
|
|
|
|
|
|
arch_chroot "mkinitcpio -P" 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME" "$?"
|
|
|
|
}
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# virtual console keymap
|
|
|
|
set_keymap() {
|
|
|
|
KEYMAPS=""
|
|
|
|
for i in $(ls -R /usr/share/kbd/keymaps | grep "map.gz" | sed 's/\.map\.gz//g' | sort); do
|
|
|
|
KEYMAPS="${KEYMAPS} ${i} -"
|
2017-02-19 18:40:47 +00:00
|
|
|
done
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
DIALOG " $_VCKeymapTitle " --menu "$_VCKeymapBody" 20 40 16 ${KEYMAPS} 2>${ANSWER} || return 0
|
|
|
|
KEYMAP=$(cat ${ANSWER})
|
2017-02-19 18:40:47 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
loadkeys $KEYMAP 2>$ERR
|
|
|
|
check_for_error "loadkeys $KEYMAP" "$?"
|
2017-03-09 16:19:01 +00:00
|
|
|
# set keymap for openrc too
|
|
|
|
echo "keymap=\"$KEYMAP\"" > /tmp/keymap
|
2017-03-02 05:02:09 +00:00
|
|
|
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}')
|
|
|
|
# Choose terminus font size depending on resolution
|
|
|
|
if [[ $biggest_resolution -gt 1920 ]]; then
|
|
|
|
FONT=ter-124n
|
|
|
|
elif [[ $biggest_resolution -eq 1920 ]]; then
|
|
|
|
FONT=ter-118n
|
|
|
|
else
|
|
|
|
FONT=ter-114n
|
2017-02-19 18:40:47 +00:00
|
|
|
fi
|
2017-03-02 05:02:09 +00:00
|
|
|
echo -e "KEYMAP=${KEYMAP}\nFONT=${FONT}" > /tmp/vconsole.conf
|
2017-03-09 16:19:01 +00:00
|
|
|
echo -e "consolefont=\"${FONT}\"" > /tmp/consolefont
|
2017-02-19 18:40:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# locale array generation code adapted from the Manjaro 0.8 installer
|
|
|
|
set_locale() {
|
|
|
|
LOCALES=""
|
|
|
|
for i in $(cat /etc/locale.gen | grep -v "# " | sed 's/#//g' | sed 's/ UTF-8//g' | grep .UTF-8); do
|
|
|
|
LOCALES="${LOCALES} ${i} -"
|
2017-03-01 18:47:53 +00:00
|
|
|
done
|
2017-03-02 05:02:09 +00:00
|
|
|
|
|
|
|
DIALOG " $_ConfBseSysLoc " --menu "$_localeBody" 0 0 12 ${LOCALES} 2>${ANSWER} || return 0
|
|
|
|
|
|
|
|
LOCALE=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
echo "LANG=\"${LOCALE}\"" > ${MOUNTPOINT}/etc/locale.conf
|
|
|
|
sed -i "s/#${LOCALE}/${LOCALE}/" ${MOUNTPOINT}/etc/locale.gen 2>$ERR
|
|
|
|
arch_chroot "locale-gen" >/dev/null 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME" "$?"
|
2017-03-09 17:01:15 +00:00
|
|
|
if [[ -e /mnt/.openrc ]]; then
|
|
|
|
mkdir ${MOUNTPOINT}/etc/env.d
|
|
|
|
echo "LANG=\"${LOCALE}\"" > ${MOUNTPOINT}/etc/env.d/02locale
|
|
|
|
fi
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# Set Zone and Sub-Zone
|
|
|
|
set_timezone() {
|
|
|
|
ZONE=""
|
|
|
|
for i in $(cat /usr/share/zoneinfo/zone.tab | awk '{print $3}' | grep "/" | sed "s/\/.*//g" | sort -ud); do
|
|
|
|
ZONE="$ZONE ${i} -"
|
|
|
|
done
|
2017-02-19 11:02:55 +00:00
|
|
|
|
2017-03-06 01:31:49 +00:00
|
|
|
DIALOG " $_ConfBseTimeHC " --menu "$_TimeZBody" 0 0 10 ${ZONE} 2>${ANSWER} || return 1
|
2017-03-02 05:02:09 +00:00
|
|
|
ZONE=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
SUBZONE=""
|
|
|
|
for i in $(cat /usr/share/zoneinfo/zone.tab | awk '{print $3}' | grep "${ZONE}/" | sed "s/${ZONE}\///g" | sort -ud); do
|
|
|
|
SUBZONE="$SUBZONE ${i} -"
|
|
|
|
done
|
|
|
|
|
2017-03-06 01:31:49 +00:00
|
|
|
DIALOG " $_ConfBseTimeHC " --menu "$_TimeSubZBody" 0 0 11 ${SUBZONE} 2>${ANSWER} || return 1
|
2017-03-02 05:02:09 +00:00
|
|
|
SUBZONE=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
DIALOG " $_ConfBseTimeHC " --yesno "\n$_TimeZQ ${ZONE}/${SUBZONE}?\n\n" 0 0
|
|
|
|
if (( $? == 0 )); then
|
|
|
|
arch_chroot "ln -sf /usr/share/zoneinfo/${ZONE}/${SUBZONE} /etc/localtime" 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME ${ZONE}/${SUBZONE}" $?
|
2017-03-06 01:31:49 +00:00
|
|
|
else
|
|
|
|
return 1
|
2017-02-19 11:02:55 +00:00
|
|
|
fi
|
2017-03-02 05:02:09 +00:00
|
|
|
}
|
2017-02-19 11:02:55 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
set_hw_clock() {
|
|
|
|
DIALOG " $_ConfBseTimeHC " --menu "$_HwCBody" 0 0 2 \
|
|
|
|
"utc" "-" \
|
|
|
|
"localtime" "-" 2>${ANSWER}
|
|
|
|
|
|
|
|
if [[ $(cat ${ANSWER}) != "" ]]; then
|
|
|
|
arch_chroot "hwclock --systohc --$(cat ${ANSWER})" 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME" "$?"
|
2017-02-19 11:02:55 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
set_hostname() {
|
|
|
|
DIALOG " $_ConfBseHost " --inputbox "$_HostNameBody" 0 0 "manjaro" 2>${ANSWER} || return 0
|
|
|
|
|
|
|
|
echo "$(cat ${ANSWER})" > ${MOUNTPOINT}/etc/hostname 2>$ERR
|
|
|
|
echo -e "#<ip-address>\t<hostname.domain.org>\t<hostname>\n127.0.0.1\tlocalhost.localdomain\tlocalhost\t$(cat \
|
|
|
|
${ANSWER})\n::1\tlocalhost.localdomain\tlocalhost\t$(cat ${ANSWER})" > ${MOUNTPOINT}/etc/hosts 2>$ERR
|
|
|
|
check_for_error "$FUNCNAME"
|
2017-02-19 11:02:55 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# Adapted and simplified from the Manjaro 0.8 and Antergos 2.0 installers
|
|
|
|
set_root_password() {
|
|
|
|
DIALOG " $_ConfUsrRoot " --clear --insecure --passwordbox "$_PassRtBody" 0 0 \
|
|
|
|
2> ${ANSWER} || return 0
|
|
|
|
PASSWD=$(cat ${ANSWER})
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
DIALOG " $_ConfUsrRoot " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 \
|
|
|
|
2> ${ANSWER} || return 0
|
|
|
|
PASSWD2=$(cat ${ANSWER})
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
if [[ $PASSWD == $PASSWD2 ]]; then
|
|
|
|
echo -e "${PASSWD}\n${PASSWD}" > /tmp/.passwd
|
|
|
|
arch_chroot "passwd root" < /tmp/.passwd >/dev/null 2>$ERR
|
2017-02-24 15:15:57 +00:00
|
|
|
check_for_error "$FUNCNAME" $?
|
2017-03-02 05:02:09 +00:00
|
|
|
rm /tmp/.passwd
|
|
|
|
else
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "$_PassErrBody" 0 0
|
|
|
|
set_root_password
|
2017-02-17 04:19:17 +00:00
|
|
|
fi
|
2017-03-02 05:02:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Originally adapted from the Antergos 2.0 installer
|
|
|
|
create_new_user() {
|
|
|
|
DIALOG " $_NUsrTitle " --inputbox "$_NUsrBody" 0 0 "" 2>${ANSWER} || return 0
|
|
|
|
USER=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
# Loop while user name is blank, has spaces, or has capital letters in it.
|
|
|
|
while [[ ${#USER} -eq 0 ]] || [[ $USER =~ \ |\' ]] || [[ $USER =~ [^a-z0-9\ ] ]]; do
|
|
|
|
DIALOG " $_NUsrTitle " --inputbox "$_NUsrErrBody" 0 0 "" 2>${ANSWER} || return 0
|
|
|
|
USER=$(cat ${ANSWER})
|
|
|
|
done
|
|
|
|
|
2017-03-05 21:30:32 +00:00
|
|
|
shell=""
|
2017-03-05 16:45:37 +00:00
|
|
|
DIALOG " _NUsrTitle " --radiolist "\n$_DefShell\n$_UseSpaceBar" 0 0 3 \
|
2017-03-02 23:13:05 +00:00
|
|
|
"zsh" "-" on \
|
|
|
|
"bash" "-" off \
|
|
|
|
"fish" "-" off 2>/tmp/.shell
|
2017-03-09 17:01:15 +00:00
|
|
|
shell_choice=$(cat /tmp/.shell)
|
2017-02-17 04:19:17 +00:00
|
|
|
|
2017-03-09 17:01:15 +00:00
|
|
|
case ${shell_choice} in
|
2017-03-05 21:30:32 +00:00
|
|
|
"zsh") [[ ! -e /mnt/etc/skel/.zshrc ]] && basestrap ${MOUNTPOINT} manjaro-zsh-config
|
2017-03-06 15:49:31 +00:00
|
|
|
shell=/usr/bin/zsh
|
2017-03-05 21:30:32 +00:00
|
|
|
;;
|
2017-03-06 15:49:31 +00:00
|
|
|
"fish") [[ ! -e /mnt/usr/bin/fish ]] && basestrap ${MOUNTPOINT} fish
|
|
|
|
shell=/usr/bin/fish
|
2017-03-05 21:30:32 +00:00
|
|
|
;;
|
2017-03-09 17:04:12 +00:00
|
|
|
"bash") shell=/bin/bash
|
2017-03-05 21:30:32 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
check_for_error "default shell: [${shell}]"
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# Enter password. This step will only be reached where the loop has been skipped or broken.
|
|
|
|
DIALOG " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassNUsrBody $USER\n\n" 0 0 \
|
|
|
|
2> ${ANSWER} || return 0
|
|
|
|
PASSWD=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
DIALOG " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 \
|
|
|
|
2> ${ANSWER} || return 0
|
|
|
|
PASSWD2=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
# loop while passwords entered do not match.
|
|
|
|
while [[ $PASSWD != $PASSWD2 ]]; do
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "$_PassErrBody" 0 0
|
|
|
|
|
|
|
|
DIALOG " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassNUsrBody $USER\n\n" 0 0 \
|
|
|
|
2> ${ANSWER} || return 0
|
|
|
|
PASSWD=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
DIALOG " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 \
|
|
|
|
2> ${ANSWER} || return 0
|
|
|
|
PASSWD2=$(cat ${ANSWER})
|
2017-02-17 04:19:17 +00:00
|
|
|
done
|
|
|
|
|
2017-03-02 05:02:09 +00:00
|
|
|
# create new user. This step will only be reached where the password loop has been skipped or broken.
|
|
|
|
DIALOG " $_ConfUsrNew " --infobox "$_NUsrSetBody" 0 0
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# Create the user, set password, then remove temporary password file
|
|
|
|
arch_chroot "groupadd ${USER}"
|
2017-03-06 15:49:31 +00:00
|
|
|
arch_chroot "useradd ${USER} -m -g ${USER} -G wheel,storage,power,network,video,audio,lp -s $shell" 2>$ERR
|
2017-03-02 05:02:09 +00:00
|
|
|
check_for_error "add user to groups" $?
|
|
|
|
echo -e "${PASSWD}\n${PASSWD}" > /tmp/.passwd
|
|
|
|
arch_chroot "passwd ${USER}" < /tmp/.passwd >/dev/null 2>$ERR
|
|
|
|
check_for_error "create user pwd" $?
|
|
|
|
rm /tmp/.passwd
|
|
|
|
|
|
|
|
# Set up basic configuration files and permissions for user
|
|
|
|
#arch_chroot "cp /etc/skel/.bashrc /home/${USER}"
|
|
|
|
arch_chroot "chown -R ${USER}:${USER} /home/${USER}"
|
|
|
|
[[ -e ${MOUNTPOINT}/etc/sudoers ]] && sed -i '/%wheel ALL=(ALL) ALL/s/^#//' ${MOUNTPOINT}/etc/sudoers
|
2017-02-17 04:19:17 +00:00
|
|
|
}
|