util-menu.sh 6.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# !/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.

main_menu() {
    declare -i loopmenu=1
    while ((loopmenu)); do
16
        if [[ $HIGHLIGHT != 7 ]]; then
17 18
           HIGHLIGHT=$(( HIGHLIGHT + 1 ))
        fi
Bernhard Landauer's avatar
Bernhard Landauer committed
19

20
        DIALOG " $_MMTitle " --default-item ${HIGHLIGHT} \
Bernhard Landauer's avatar
Bernhard Landauer committed
21
          --menu "\n$_MMBody\n " 0 0 7 \
22 23
          "1" "$_PrepMenuTitle|>" \
          "2" "$_InstBsMenuTitle|>" \
24
          "3" "$_ConfBseMenuTitle|>" \
Matti Hyttinen's avatar
Matti Hyttinen committed
25 26 27
          "4" "$_SeeConfOptTitle" \
          "5" "$_InstAdvBase|>" \
          "6" "$_Done" 2>${ANSWER}
28 29 30 31 32
        HIGHLIGHT=$(cat ${ANSWER})

        case $(cat ${ANSWER}) in
            "1") prep_menu
                ;;
33
            "2") check_mount && install_base_menu
34
                ;;
35
            "3") check_base && config_base_menu
36
                ;;
37
            "4") check_base && {
patrick's avatar
patrick committed
38
                    type edit_configs &>/dev/null || import ${LIBDIR}/util-config.sh
39 40
                    edit_configs
                    }
41
                ;;
Matti Hyttinen's avatar
Matti Hyttinen committed
42
            "5") check_base && {
patrick's avatar
patrick committed
43
                    type advanced_menu &>/dev/null || import ${LIBDIR}/util-advanced.sh
44 45
                    advanced_menu
                    }
46
                ;;
47 48 49 50 51
             *) loopmenu=0
                exit_done
                ;;
        esac
    done
Bernhard Landauer's avatar
Bernhard Landauer committed
52 53
}

54 55 56
# Preparation
prep_menu() {
    local PARENT="$FUNCNAME"
57 58
    declare -i loopmenu=1
    while ((loopmenu)); do
59 60 61 62 63 64 65 66 67
        submenu 7
        DIALOG " $_PrepMenuTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n$_PrepMenuBody\n " 0 0 7 \
          "1" "$_VCKeymapTitle" \
          "2" "$_DevShowOpt" \
          "3" "$_PrepPartDisk" \
          "4" "$_PrepLUKS" \
          "5" "$_PrepLVM $_PrepLVM2" \
          "6" "$_PrepMntPart" \
          "7" "$_Back" 2>${ANSWER}
Bernhard Landauer's avatar
Bernhard Landauer committed
68
        HIGHLIGHT_SUB=$(cat ${ANSWER})
69

Bernhard Landauer's avatar
Bernhard Landauer committed
70
        case $(cat ${ANSWER}) in
71
            "1") select_keymap
Bernhard Landauer's avatar
Bernhard Landauer committed
72
                 set_keymap
73 74
                 ;;
            "2") show_devices
Bernhard Landauer's avatar
Bernhard Landauer committed
75
                 ;;
76
            "3") umount_partitions
77
                 select_device && create_partitions
Bernhard Landauer's avatar
Bernhard Landauer committed
78
                 ;;
79
            "4") luks_menu
Bernhard Landauer's avatar
Bernhard Landauer committed
80
                 ;;
81
            "5") lvm_menu
Bernhard Landauer's avatar
Bernhard Landauer committed
82
                 ;;
83
            "6") mount_partitions
Bernhard Landauer's avatar
Bernhard Landauer committed
84 85 86 87 88
                 ;;
            *) loopmenu=0
                return 0
                 ;;
        esac
89
    done
90 91 92 93 94
}

# Base Installation
install_base_menu() {
    local PARENT="$FUNCNAME"
95 96
    declare -i loopmenu=1
    while ((loopmenu)); do
97
        submenu 7
Bernhard Landauer's avatar
Bernhard Landauer committed
98
        DIALOG " $_InstBsMenuTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n$_InstBseMenuBody\n " 0 0 6 \
99
          "1" "$_PrepMirror|>" \
Bernhard Landauer's avatar
Bernhard Landauer committed
100 101
          "2" "$_PrepPacKey" \
          "3" "$_InstBse" \
Matti Hyttinen's avatar
Matti Hyttinen committed
102
          "4" "$_InstDEStable|>" \
103 104
          "5" "$_InstBootldr" \
          "6" "$_Back" 2>${ANSWER}
Bernhard Landauer's avatar
Bernhard Landauer committed
105
        HIGHLIGHT_SUB=$(cat ${ANSWER})
106

Bernhard Landauer's avatar
Bernhard Landauer committed
107 108 109 110
        case $(cat ${ANSWER}) in
            "1") configure_mirrorlist
                 ;;
            "2") clear
111
                 (
Bernhard Landauer's avatar
Bernhard Landauer committed
112
                    ctrlc(){
113 114 115 116 117 118 119
                      return 0
                    }
                    trap ctrlc SIGINT
                    trap ctrlc SIGTERM
                    pacman-key --init;pacman-key --populate archlinux manjaro;pacman-key --refresh-keys;
                    check_for_error 'refresh pacman-keys'
                  )
Bernhard Landauer's avatar
Bernhard Landauer committed
120
                 ;;
121
            "3") install_base
Bernhard Landauer's avatar
Bernhard Landauer committed
122
                 ;;
123
            "4") check_base && {
Bernhard Landauer's avatar
Bernhard Landauer committed
124
                    install_manjaro_de_wm_pkg || DIALOG " $_InstBseTitle " --msgbox "\n$_InstFail\n " 0 0
125
                 }
Matti Hyttinen's avatar
Matti Hyttinen committed
126
                 ;;
127
            "5") install_bootloader
Bernhard Landauer's avatar
Bernhard Landauer committed
128 129 130 131 132
                 ;;
            *) loopmenu=0
                return 0
                 ;;
        esac
133
    done
134 135 136 137 138
}

# Base Configuration
config_base_menu() {
    local PARENT="$FUNCNAME"
139 140 141
    declare -i loopmenu=1
    while ((loopmenu)); do
        submenu 8
Bernhard Landauer's avatar
Bernhard Landauer committed
142
        DIALOG " $_ConfBseMenuTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n$_ConfBseBody\n " 0 0 8 \
143 144 145
          "1" "$_ConfBseFstab" \
          "2" "$_ConfBseHost" \
          "3" "$_ConfBseSysLoc" \
Matti Hyttinen's avatar
Matti Hyttinen committed
146 147 148 149
          "4" "$_PrepKBLayout" \
          "5" "$_ConfBseTimeHC" \
          "6" "$_ConfUsrRoot" \
          "7" "$_ConfUsrNew" \
150 151 152 153 154 155 156 157 158 159
          "8" "$_Back" 2>${ANSWER}
        HIGHLIGHT_SUB=$(cat ${ANSWER})

        case $(cat ${ANSWER}) in
            "1") generate_fstab
                ;;
            "2") set_hostname
                ;;
            "3") set_locale
                ;;
Matti Hyttinen's avatar
Matti Hyttinen committed
160
            "4") set_xkbmap
161
                ;;
Matti Hyttinen's avatar
Matti Hyttinen committed
162
            "5") set_timezone && set_hw_clock
163
                ;;
Matti Hyttinen's avatar
Matti Hyttinen committed
164
            "6") set_root_password
165
                ;;
Matti Hyttinen's avatar
Matti Hyttinen committed
166
            "7") create_new_user
167 168 169 170 171 172
                ;;
            *) loopmenu=0
                return 0
                ;;
        esac
    done
173 174
}

Matti Hyttinen's avatar
Matti Hyttinen committed
175
install_drivers_menu() {
176
    HIGHLIGHT_SUB=1
Matti Hyttinen's avatar
Matti Hyttinen committed
177 178
    declare -i loopmenu=1
    while ((loopmenu)); do
179
        DIALOG " $_InstDrvTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n " 0 0 3 \
180 181 182
          "1" "$_InstGrMenuTitle|>" \
          "2" "$_InstNWDrv" \
          "3" "$_Back" 2>${ANSWER}
Matti Hyttinen's avatar
Matti Hyttinen committed
183 184

        case $(cat ${ANSWER}) in
185
            "1") install_graphics_menu
186
                HIGHLIGHT_SUB=2
Matti Hyttinen's avatar
Matti Hyttinen committed
187
                ;;
188
            "2") setup_network_drivers || DIALOG " $_InstBseTitle " --infobox "\n$_InstFail\n " 0 0
189
                HIGHLIGHT_SUB=3
Matti Hyttinen's avatar
Matti Hyttinen committed
190
                ;;
191 192
            *) HIGHLIGHT_SUB=5
                loopmenu=0
Matti Hyttinen's avatar
Matti Hyttinen committed
193 194 195 196 197
                return 0
                ;;
        esac
    done
}
198

199
install_graphics_menu() {
200
    DIALOG " $_InstGrMenuDD " --menu "\n " 0 0 3 \
201 202
      "1" "$_InstFree" \
      "2" "$_InstProp" \
203
      "3" "$_SelDDrv" 2>${ANSWER} || return 0
204 205 206 207 208

    case $(cat ${ANSWER}) in
        "1") clear
            arch_chroot "mhwd -a pci free 0300" 2>$ERR
            check_for_error "$_InstFree" $?
209
            touch /mnt/.video_installed
210 211 212 213
            ;;
        "2") clear
            arch_chroot "mhwd -a pci nonfree 0300" 2>$ERR
            check_for_error "$_InstProp" $?
214
            touch /mnt/.video_installed
215 216 217 218 219
            ;;
        "3") setup_graphics_card
            ;;
    esac
}