touch ./install-vars setvar () { grep -v "^$1=" ./install-vars > ./install-vars.new && mv ./install-vars.new ./install-vars echo "$1=$2" >> ./install-vars } getvar () { value=$(grep "^$1=" ./install-vars | tail -n 1 | sed "s/^$1=//") } detectTimezone () { if command_exists tzupdate ; then dialog --infobox "Please wait, detecting your timezone... " 5 50; detected=$(tzupdate -p | sed "s/Detected timezone is //" | sed "s/\.//") return fi detected="" } tzOptionsByRegion () { options=$(cd /usr/share/zoneinfo/$1 && find . | sed "s|^\./||" | sed "s/^\.//" | sed '/^$/d') } tzRegions () { regions=$(find /usr/share/zoneinfo/. -maxdepth 1 -type d | cut -d "/" -f6 | sed '/^$/d') } tzSelectionMenu () { detectTimezone if [[ -n "${detected// }" ]]; then if [ -f "/usr/share/zoneinfo/$detected" ]; then offset=$(TZ="$detected" date +%z | sed "s/00$/:00/g") dialog --title "Timezones" \ --backtitle "Happy Hacking Linux" \ --yes-label "Yes, correct" \ --no-label "No, I'll choose it" \ --yesno "Your timezone was detected as $detected ($offset). Is it correct?" 7 50 selected=$? if [ "$selected" = "0" ]; then tzupdate > /dev/null return fi fi fi tzRegions regionsArray=() while read name; do regionsArray+=($name "") done <<< "$regions" region=$(dialog --stdout \ --title "Timezones" \ --backtitle "$1" \ --ok-label "Next" \ --no-cancel \ --menu "Select a continent or ocean from the menu:" \ 20 30 30 \ "${regionsArray[@]}") tzOptionsByRegion $region optionsArray=() while read name; do offset=$(TZ="$region/$name" date +%z | sed "s/00$/:00/g") optionsArray+=($name "($offset)") done <<< "$options" tz=$(dialog --stdout \ --title "Timezones" \ --backtitle "$1" \ --ok-label "Next" \ --cancel-label "Back to Regions" \ --menu "Select your timezone in ${region}:" \ 20 40 30 \ "${optionsArray[@]}") if [[ -z "${tz// }" ]]; then tzSelectionMenu else selected="/usr/share/zoneinfo/$region/$tz" fi } command_exists () { type "$1" &> /dev/null ; } declare -A countries countries[1]="Australia" countries[2]="Austria" countries[3]="Bangladesh" countries[4]="Belarus" countries[5]="Belgium" countries[6]="Bosnia_and_Herzegovina" countries[7]="Brazil" countries[8]="Bulgaria" countries[9]="Canada" countries[10]="Chile" countries[11]="China" countries[12]="Colombia" countries[13]="Croatia" countries[14]="Czechia" countries[15]="Denmark" countries[16]="Ecuador" countries[17]="Finland" countries[18]="France" countries[19]="Georgia" countries[20]="Germany" countries[21]="Greece" countries[22]="Hong_Kong" countries[23]="Hungary" countries[24]="Iceland" countries[25]="India" countries[26]="Indonesia" countries[27]="Iran" countries[28]="Ireland" countries[29]="Israel" countries[30]="Italy" countries[31]="Japan" countries[32]="Kazakhstan" countries[33]="Kenya" countries[34]="Latvia" countries[35]="Lithuania" countries[36]="Luxembourg" countries[37]="Netherlands" countries[38]="New_Caledonia" countries[39]="New_Zealand" countries[40]="North_Macedonia" countries[41]="Norway" countries[42]="Paraguay" countries[43]="Philippines" countries[44]="Poland" countries[45]="Portugal" countries[46]="Romania" countries[47]="Russia" countries[48]="Serbia" countries[49]="Singapore" countries[50]="Slovakia" countries[51]="Slovenia" countries[52]="South_Africa" countries[53]="South_Korea" countries[54]="Spain" countries[55]="Sweden" countries[56]="Switzerland" countries[57]="Taiwan" countries[58]="Thailand" countries[59]="Turkey" countries[60]="Ukraine" countries[61]="United_Kingdom" countries[62]="United_States" countries[63]="Vietnam" declare -A country_codes country_codes[1]="AU" country_codes[2]="AT" country_codes[3]="BD" country_codes[4]="BY" country_codes[5]="BE" country_codes[6]="BA" country_codes[7]="BR" country_codes[8]="BG" country_codes[9]="CA" country_codes[10]="CL" country_codes[11]="CN" country_codes[12]="CO" country_codes[13]="HR" country_codes[14]="CZ" country_codes[15]="DK" country_codes[16]="EC" country_codes[17]="FI" country_codes[18]="FR" country_codes[19]="GE" country_codes[20]="DE" country_codes[21]="GR" country_codes[22]="HK" country_codes[23]="HU" country_codes[24]="IS" country_codes[25]="IN" country_codes[26]="ID" country_codes[27]="IR" country_codes[28]="IE" country_codes[29]="IL" country_codes[30]="IT" country_codes[31]="JP" country_codes[32]="KZ" country_codes[33]="KE" country_codes[34]="LV" country_codes[35]="LT" country_codes[36]="LU" country_codes[37]="NL" country_codes[38]="NC" country_codes[39]="NZ" country_codes[40]="MK" country_codes[41]="NO" country_codes[42]="PY" country_codes[43]="PH" country_codes[44]="PL" country_codes[45]="PT" country_codes[46]="RO" country_codes[47]="RU" country_codes[48]="RS" country_codes[49]="SG" country_codes[50]="SK" country_codes[51]="SI" country_codes[52]="ZA" country_codes[53]="KR" country_codes[54]="ES" country_codes[55]="SE" country_codes[56]="CH" country_codes[57]="TW" country_codes[58]="TH" country_codes[59]="TR" country_codes[60]="UA" country_codes[61]="GB" country_codes[62]="US" country_codes[63]="VN" selectMirrorRegions() { checklist="" for i in {1..63} do checklist="$checklist $i ${countries[$i]} off" done mirror_regions=$(dialog --stdout --checklist "Choose Mirror Regions:" 25 40 15 $checklist) if [[ -z "${mirror_regions// }" ]]; then selectMirrorRegions fi } createMirrorList() { selectMirrorRegions args="" for i in $mirror_regions do echo "$i" args="$args --country ${country_codes[$i]}" done cmd="reflector $args --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist" dialog --infobox "Searching the best mirror in given regions... " 5 50; eval $cmd } init () { timedetect1 set-ntp true } autoPartition () { parted $1 --script mklabel msdos \ mkpart primary ext4 3MiB 100% \ set 1 boot on 2> /tmp/err || errorDialog "Failed to create disk partitions" yes | mkfs.ext4 "${1}1" > /dev/null 2> /tmp/err || error "Failed to format the boot partition" yes | mkfs.ext4 "${1}2" > /dev/null 2> /tmp/err || error "Failed to format the root partition" mount "${1}1" /mnt setvar "system-partition" "${1}2" } installCoreSystem () { getvar "system-partition" systempt=$value getvar "disk" disk=$value dialog --infobox "Looking for faster and more up-to-date mirrors for rest of the installation..." 6 50; findBestMirrors pacstrap /mnt base linux linux-firmware genfstab -U /mnt >> /mnt/etc/fstab setvar "core-install-step" "done" mkdir -p /mnt/usr/local/installer cp install-vars /mnt/usr/local/installer/. cp autorun.sh /mnt/usr/local/installer/install cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist mkdir -p /mnt/etc/netctl cp /etc/netctl/* /mnt/etc/netctl/. arch-chroot /mnt < ./error-logs EOF if [ -f /mnt/tmp/reboot ]; then echo "Ciao!" reboot fi } installGRUB () { installPkg "grub" getvar "disk" grub-install --target=i386-pc --recheck $value > /dev/null 2> /tmp/err || errorDialog "Something got screwed and we failed to run grub-install" grub-mkconfig -o /boot/grub/grub.cfg > /dev/null 2> /tmp/err || errorDiaolog "Something got screwed up and we failed to create GRUB config." } localize () { yes | pip install tzupdate > /dev/null 2> /dev/null # ignore if it fails, let user choose tz tzSelectionMenu "Happy Hacking Linux" hwclock --systohc sed -i -e '/^#en_US/s/^#//' /etc/locale.gen # uncomment lines starting with #en_US locale-gen 2> /tmp/err || errorDialog "locale-gen is missing" # FIX ME: Allow user to choose language and keyboard echo "LANG=en_US.UTF-8" >> /etc/locale.conf echo "FONT=Lat2-Terminus16" >> /etc/vconsole.conf } createUser () { useradd -m -s /usr/bin/zsh $1 echo "$1:$2" | chpasswd echo "$1 ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers echo $1 > /etc/hostname echo "127.0.1.1 $1.localdomain $1" >> /etc/hosts } linkDotFiles () { getvar "username" username=$value dotFilesBase=$(basename "$1" | cut -f 1 -d '.') target=/home/$username/$dotFilesBase runuser -l $username -c "git clone $1 $target" #runuser -l $username -c "git clone $1 $target && cd $target && for file in .*; do cd /home/$username && rm -rf \$file && ln -s $target/\$file \$file; done" > /dev/null 2> /tmp/err || errorDialog "Can not install dotfiles at $1 :/" } installHappyDesktopConfig () { getvar "username" username=$value runuser -l $username -c "git clone https://github.com/happy-hacking-linux/happy-desktop.git /home/$username/.happy-desktop" > /dev/null 2> /tmp/err || errorDialog "Failed to clone the default desktop configuration. Please check your connection." runuser -l $username -c "mkdir -p /home/$username/.config" runuser -l $username -c "cd /home/$username/.config && ln -sf /home/$username/.happy-desktop/config/* ." > /dev/null 2>> /tmp/err || errorDialog "Failed to link desktop configuration." runuser -l $username -c "cd /home/$username && ln -sf /home/$username/.happy-desktop/dotfiles/.* ." > /dev/null 2>> /tmp/err || errorDialog "Failed to link default dotfiles." } installZSH () { installPkg "zsh" chsh -s $(which zsh) > /dev/null 2> /tmp/err || errorDialog "Something got screwed up, we can't change the default shell to ZSH." getvar "username" username=$value chsh -s $(which zsh) $username > /dev/null 2> /tmp/err || errorDialog "Something got screwed up, we can't change the default shell to ZSH." } installOhMyZSH () { getvar "username" username=$value installAurPkg "oh-my-zsh-git" cp /usr/share/oh-my-zsh/zshrc /home/$username/.zshrc } installYay () { installAurPkg "yay" } installVirtualBox () { installPkg "virtualbox-guest-modules-arch" installPkg "virtualbox-guest-utils" echo -e "vboxguest\nvboxsf\nvboxvideo" > /etc/modules-load.d/virtualbox.conf systemctl enable vboxservice.service } installMacbook () { echo "options snd-hda-intel index=1,0" > /etc/modprobe.d/alsa.conf installAurPkg "bcwc-pcie-git" # Webcam support systemctl enable bluetooth } installBasicPackages () { installPkg "base-devel" installPkg "net-tools" installPkg "pkgfile" installPkg "xf86-video-vesa" installPkg "openssh" installPkg "wget" installPkg "git" installPkg "acpi" installPkg "powertop" installPkg "htop" installPkg "python" installPkg "python-pip" installPkg "wpa_supplicant" installPkg "mc" installPkg "httpie" installPkg "dnsutils" installPkg "tlp" installPkg "unzip" installPkg "xf86-input-synaptics" installPkg "bat" installPkg "prettyping" installPkg "fzf" installPkg "tldr" installPkg "ack" installPkg "tmux" installPkg "ranger" installPkg "lsd" installPkg "fd" installPkg "ripgrep" installPkg "irssi" installPkg "tree" installPkg "bandwhich" installPkg "wireless-regdb" installPkg "wireless_tools" installPkg "netctl" installPkg "ntfs-3g" installPkg "dhclient" installPkg "dhcpcd" installPkg "b43-fwcutter" installPkg "broadcom-wl" installPkg "vim" installAurPkg "skm" installZSH } installPrinterSupport () { installPkg "cups" installPkg "avahi" } upgrade () { pacman --noconfirm -Syu > /dev/null 2> /tmp/err || errorDialog "Failed to upgrade the system. Make sure being connected to internet." } findBestMirrors () { createMirrorList > /dev/null 2> /tmp/err || errorDialog "Something got screwed up and we couldn't accomplish finding some fast and up-to-date servers :(" } installYaourt () { runAsUser "git clone https://aur.archlinux.org/package-query.git /tmp/package-query" > /dev/null 2> /tmp/err || errorDialog "Can not access Arch Linux repositories, check your internet connection." runAsUser "cd /tmp/package-query && yes | makepkg -si" > /dev/null 2> /tmp/err || errorDialog "Failed to build package-query." runAsUser "git clone https://aur.archlinux.org/yaourt.git /tmp/yaourt" > /dev/null 2> /tmp/err || errorDialog "Can not access Arch Linux repositories, check your internet connection." runAsUser "cd /tmp/yaourt && yes | makepkg -si" > /dev/null 2> /tmp/err || errorDialog "Failed to build Yaourt" } installSwayDesktop () { installPkg "sway" installPkg "swaybg" installPkg "swayidle" installPkg "swaylock" installPkg "alacritty" installPkg "grim" installPkg "rofi" installPkg "waybar" installPkg "feh" installPkg "alsa-utils" installPkg "playerctl" installPkg "mako" installPkg "qalculate-gtk" installPkg "waybar" installPkg "ffmpeg" installPkg "jq" installPkg "xorg-server-xwayland" } installI3Desktop () { installPkg "xorg" installPkg "xorg-xinit" installPkg "compton" installPkg "i3-gaps" installPkg "i3status" installPkg "i3lock" installPkg "rofi" installPkg "feh" installPkg "unclutter" installPkg "scrot" installPkg "dmenu" installPkg "alsa-utils" installPkg "moc" installPkg "slop" installPkg "playerctl" installPkg "libnotify" installPkg "dunst" installPkg "qalculate-gtk" installPkg "compton" installPkg "udisks2" installPkg "udiskie" installPkg "imagemagick" installPkg "maim" installPkg "network-manager-applet" installAurPkg "polybar" installAurPkg "light-git" } installXfce4Desktop () { installPkg "xfce4" } installFonts () { installPkg "ttf-dejavu" installPkg "adobe-source-han-serif-otc-fonts" installPkg "adobe-source-han-sans-otc-fonts" installAurPkg "ttf-monaco" installAurPkg "noto-fonts-emoji" } installURXVT () { installAurPkg "rxvt-unicode-256xresources" > /dev/null 2> /tmp/err || errorDialog "Failed to install RXVT-Unicode with 256 colors" installPkg "urxvt-perls" } installRefind () { installPkg "refind-efi" runuser -l $username -c "refind-install" > /dev/null 2> /tmp/err getvar "system-partition" systempt=$value getUUID $systempt echo "\"Boot using default options\" \"root=UUID=$uuid rw add_efi_memmap\"" > /boot/refind_linux.conf echo "\"Boot using fallback initramfs\" \"root=UUID=$uuid rw add_efi_memmap initrd=/boot/initramfs-linux-fallback.img\"" >> /boot/refind_linux.conf echo "\"Boot to terminal\" \"root=UUID=$uuid rw add_efi_memmap systemd.unit=multi-user.target\"" >> /boot/refind_linux.conf } installPkg () { installationProgress "$1" pacman -S --noconfirm "$1" > /dev/null 2> /tmp/err || errorDialog "Something went wrong with installing $1. Try again." } installAurPkg () { installationProgress "$1" runAsUser "yaourt -S --noconfirm $1" > /dev/null 2> /tmp/err || errorDialog "Something went wrong with installing $1. Try again." } runAsUser () { # run given command as a non-root user getvar "username" username=$value runuser -l $username -c "$1" } getUUID() { name=$(sed 's/^\/dev\///' <<< $1) uuid=$(/bin/ls -la /dev/disk/by-uuid | grep "$name" | awk '{print $9}') } CHECK="[OK]" battery() { echo "| Battery: $(acpi | grep 'Battery' | sed 's/Battery\s[0-9]*: \w*, //' | sed 's/\%.*//')%" } startingDialogs () { nameDialog usernameDialog dotFilesRepo=$(dialog --stdout \ --title "=^.^=" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Next" \ --cancel-label "Skip" \ --inputbox "Where is your dotfiles, $name?" 8 55 "https://github.com/$username/dotfiles.git") } mainMenu () { icon1="" icon2="" icon3="" icon4="" icon5="" getvar "partition-step" if [ "$value" = "done" ]; then icon1="${CHECK} " fi getvar "core-install-step" if [ "$value" = "done" ]; then icon2="${CHECK} " fi getvar "users-step" if [ "$value" = "done" ]; then icon3="${CHECK} " fi getvar "install-packages-step" if [ "$value" = "done" ]; then icon4="${CHECK} " fi getvar "localization-step" if [ "$value" = "done" ]; then icon5="${CHECK} " fi selected=$(dialog --stdout \ --title "=^.^=" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Select" \ --cancel-label "Welcome Screen" \ --menu "Complete the following installation steps one by one." 16 55 8 \ 1 "${icon1}Setup Disk Partitions" \ 2 "${icon2}Install Core System" \ 3 "${icon3}Create Users" \ 4 "${icon4}Install Packages" \ 5 "${icon5}Localize" \ 6 "Reboot") button=$? } diskMenu () { disks=$(lsblk -r | grep disk | cut -d" " -f1,4 | nl) disksArray=() while read i name size; do disksArray+=($i "/dev/$name ($size)") done <<< "$disks" selected=$(dialog --stdout \ --title "Installation Disk" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Next" \ --cancel-label "Main Menu" \ --menu "Select A Disk" \ 15 30 30 \ "${disksArray[@]}") button=$? selected=$(lsblk -r | grep disk | cut -d" " -f1 | sed -n "${selected}p") selected="/dev/${selected}" setvar "disk" "$selected" } partitionMenu () { selected=$(dialog --stdout \ --title "Setup Disk Partitions" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Select" \ --cancel-label "Main Menu" \ --menu "How do you want to create partitions? If you got nothing to lose in $1, just go with the simple option and format the disk completely. Or, choose one of the tools to modify your disk in your own risk." 17 55 5 \ 1 "Simple: Erase Everything on $1" \ 2 "Manual: Using cfdisk" \ 3 "Manual: Using fdisk" \ 4 "Manual: Using GNU Parted") } partitionSelectionForm () { values=$(dialog --stdout \ --ok-label "Done" \ --backtitle "Happy Hacking Linux $(battery)" \ --title "Select Partitions" \ --nocancel \ --form "" \ 7 50 0 \ "Root Partition:" 2 1 "${1}X" 2 18 35 0) systempt=$(echo "$values" | tail -n1) dialog --title "Select Partitions" --yesno "Warning: $systempt will be formatted, continue?" 7 40 if [ "$?" != "0" ]; then systempt="" fi if [[ -z "${systempt// }" ]]; then dialog --title "Select System Partition" \ --backtitle "Happy Hacking Linux $(battery)" \ --msgbox "Sorry, you have to choose the partition you'd like to install the system." 6 50 partitionSelectionForm else yes | mkfs.ext4 $systempt > /dev/null 2> /tmp/err || error "Failed to format the root partition" mount $systempt /mnt > /dev/null 2> /tmp/err || error "Failed to mount the root partition" setvar "system-partition" $systempt fi } nameDialog () { name=$(dialog --stdout \ --title "=^.^" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Next" \ --nocancel \ --inputbox "Oh, hai! What's your name?" 8 55) if [[ -z "${name// }" ]]; then dialog --title "=^.^=" \ --backtitle "Happy Hacking Linux $(battery)" \ --msgbox "Type your name please, or make something up" 5 55 nameDialog fi } usernameDialog () { username=$(echo "$name" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z) username=$(dialog --stdout \ --title "=^.^" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Next" \ --nocancel \ --inputbox "...and your favorite username?" 8 55 "$username") if [[ -z "${username// }" ]]; then dialog --title "=^.^=" \ --backtitle "Happy Hacking Linux $(battery)" \ --msgbox "A username is required, try again" 5 55 usernamedDialog fi } passwordDialog () { password=$(dialog --stdout \ --title "Creating User" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Done" \ --nocancel \ --passwordbox "Type a new password:" 8 50) passwordRepeat=$(dialog --stdout \ --title "Creating User" \ --backtitle "Happy Hacking Linux $(battery)" \ --ok-label "Done" \ --nocancel \ --passwordbox "Verify your new password:" 8 50) if [ "$password" != "$passwordRepeat" ]; then dialog --title "Password" \ --backtitle "Happy Hacking Linux $(battery)" \ --msgbox "Passwords you've typed don't match. Try again." 5 50 passwordDialog fi if [[ -z "${password// }" ]]; then dialog --title "Password" \ --backtitle "Happy Hacking Linux $(battery)" \ --msgbox "A password is required. Try again please." 5 50 passwordDialog fi } errorDialog () { echo "$1\n\n" > ./install-errors.log [[ -f /tmp/err ]] && cat /tmp/err >> ./install-errors.log echo "Message: $1\nOutput: \n" | cat - /tmp/err > /tmp/err.bak && mv /tmp/err.bak /tmp/err dialog --title "Oops, there was an error" \ --backtitle "Happy Hacking Linux $(battery)" \ --textbox /tmp/err 20 50 rm /tmp/err mainMenuStep } installationProgress () { total=72 instcounter=$((instcounter+1)) percent=$((100*$instcounter/$total)) echo $percent | dialog --title "Installation" \ --backtitle "Happy Hacking Linux $(battery)" \ --gauge "Downloading package: $1" \ 7 70 0 } command=$1 mainMenuStep () { mainMenu if [ "$button" = "1" ]; then setvar "starting-step" "" startingStep return fi if [ "$selected" = "1" ]; then partitionStep elif [ "$selected" = "2" ]; then coreInstallStep elif [ "$selected" = "3" ]; then usersStep elif [ "$selected" = "4" ]; then installPackagesStep elif [ "$selected" = "5" ]; then localizeStep elif [ "$selected" = "6" ]; then exitStep fi } installVirtualBoxStep () { # Install VirtualBox Guest additions if the installation is running in a VirtualBox machine if lspci | grep -i virtualbox -q; then dialog --infobox "Looks like this is a VirtualBox setup, hold on please..." 5 50; installVirtualBox fi } installMacbookStep () { # Install Macbook if the installation is running in a Macbook if lspci | grep -i thunderbolt -q; then dialog --infobox "Looks like this is a Macbook, I'll do some adjustments for you..." 5 50; installMacbook fi } installDotFilesStep () { getvar "dot-files-repo" dotFilesRepo=$value if [[ -n "${dotFilesRepo// }" ]]; then dialog --infobox "Fingers crossed, we're linking your dotfiles into ~/" 5 50; linkDotFiles $dotFilesRepo fi } installBootStep () { getvar "boot-install-step" if [ "$value" != "done" ]; then dialog --title "Setup Boot" --yesno "Do you want me to override existing boot with new one ? Warning: You may lose access to a parallel system if exists." 8 40 if [ "$?" == "0" ]; then dialog --infobox "Installing GRUB for /boot" 5 50; installGRUB setvar "boot-install-step" "done" else installRefindStep fi fi } installRefindStep () { getvar "boot-install-step" if [ "$value" != "done" ]; then dialog --title "Setup rEFInd" --yesno "Do you need rEFInd to be installed?" 8 40 if [ "$?" == "0" ]; then dialog --infobox "Installing rEFInd" 5 50; installRefind fi fi } installYaourtStep () { getvar "install-yaourt-step" if [ "$value" == "done" ]; then return fi dialog --infobox "Installing AUR and Yaourt..." 5 50; installYaourt setvar "install-yaourt-step" "done" } findBestMirrorsStep () { getvar "find-best-mirrors-step" if [ "$value" == "done" ]; then return fi dialog --infobox "Looking for faster and more up-to-date mirrors for rest of the installation..." 6 50; findBestMirrors setvar "find-best-mirrors-step" "done" } installBasicPackagesStep () { getvar "install-basic-packages-step" if [ "$value" == "done" ]; then return fi installBasicPackages "Basic Packages" setvar "install-basic-packages-step" "done" } upgradeStep () { getvar "upgrade-step" if [ "$value" == "done" ]; then return fi dialog --infobox "Upgrading the system..." 5 50; upgrade setvar "upgrade-step" "done" } installPackagesStep () { getvar "install-packages-step" if [ "$value" == "done" ]; then localizeStep return fi upgradeStep installBasicPackagesStep installYaourtStep installYay installOhMyZSH installFonts installURXVT installSwayDesktop installDotFilesStep dialog --infobox "Configuring Happy Desktop..." 5 50; installHappyDesktopConfig installVirtualBoxStep installMacbookStep installBootStep setvar "install-packages-step" "done" localizeStep } finishingStep() { # Make sure brcmfmac is not blacklisted sed -i '/brcmfmac/d' /usr/lib/modprobe.d/broadcom-wl.conf 2> /dev/null # Enable the wifi interface systemctl enable netctl-auto@$(iw dev | awk '$1=="Interface"{print $2}') tlp start } exitStep () { dialog --infobox "Finishing touches..." 5 50; finishingStep dialog --title "=^.^=" \ --backtitle "Happy Hacking Linux" \ --yes-label "Reboot" \ --no-label "Main Menu" \ --yesno "Installation seems to be done, let's reboot your system. Don't forget ejecting the installation disk." 13 55 if [ "$?" = "0" ]; then touch /tmp/reboot exit else mainMenuStep fi } usersStep () { getvar "users-step" if [ "$value" == "done" ]; then installPackagesStep return fi passwordDialog getvar "username" username=$value createUser $username $password setvar "users-step" "done" installPackagesStep } localizeStep () { getvar "localization-step" if [ "$value" != "done" ]; then localize setvar "localization-step" "done" fi exitStep } coreInstallStep () { getvar "core-install-step" if [ "$value" != "done" ]; then dialog --infobox "Bootstrapping the core system, it may take a while depending on your connection." 6 50; installCoreSystem setvar "core-install-step" "done" fi usersStep } partitionStep () { diskMenu if [ "$button" = "1" ]; then mainMenuStep return fi disk=$selected partitionMenu $disk if [ "$selected" = "1" ]; then dialog --title "Select Partitions" --yesno "Warning: Disk $disk will be formatted, continue?" 7 40 if [ "$?" == "0" ]; then autoPartition $disk else partitionStep fi elif [ "$selected" = "2" ]; then cfdisk $disk partitionSelectionForm $disk elif [ "$selected" = "3" ]; then fdisk $disk partitionSelectionForm $disk elif [ "$selected" = "4" ]; then parted $disk partitionSelectionForm $disk elif [ "$selected" = "5" ]; then mainMenuStep return else mainMenuStep return fi setvar "partition-step" "done" coreInstallStep } networkStep () { getvar "network-step" if [ "$value" == "done" ]; then partitionStep fi gateway=`ip r | grep default | cut -d ' ' -f 3` test=$(ping -q -w 1 -c 1 $gateway> /dev/null && echo 1 || echo 0) if [ $test -eq 1 ]; then setvar "network-step" "done" partitionStep else wifi-menu sleep 1 ./autorun.sh network fi } startingStep () { getvar "starting-step" if [ "$value" == "done" ]; then mainMenuStep fi init startingDialogs setvar "name" $name setvar "username" $username setvar "dot-files-repo" $dotFilesRepo setvar "starting-step" "done" networkStep } if [ "$command" = "continue" ]; then usersStep elif [ "$command" = "network" ]; then networkStep else startingStep fi