Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
| 3 | #Created by helmuthdu mailto: helmuthdu[at]gmail[dot]com |
| 4 | #------------------------------------------------------------------------------- |
| 5 | #This program is free software: you can redistribute it and/or modify |
| 6 | #it under the terms of the GNU General Public License as published by |
| 7 | #the Free Software Foundation, either version 3 of the License, or |
| 8 | #(at your option) any later version. |
| 9 | # |
| 10 | #This program is distributed in the hope that it will be useful, |
| 11 | #but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | #GNU General Public License for more details. |
| 14 | # |
| 15 | #You should have received a copy of the GNU General Public License |
| 16 | #along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | #------------------------------------------------------------------------------- |
| 18 | # Run this script after your first boot with archlinux (as root) |
| 19 | |
| 20 | if [[ -f `pwd`/sharedfuncs ]]; then |
| 21 | source sharedfuncs |
| 22 | else |
| 23 | echo "missing file: sharedfuncs" |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | #ARCHLINUX INSTALL SCRIPTS MODE {{{ |
| 28 | #SELECT KEYMAP {{{ |
| 29 | select_keymap(){ |
| 30 | print_title "KEYMAP - https://wiki.archlinux.org/index.php/KEYMAP" |
| 31 | print_info "The KEYMAP variable is specified in the /etc/rc.conf file. It defines what keymap the keyboard is in the virtual consoles. Keytable files are provided by the kbd package." |
| 32 | OPTION=n |
| 33 | while [[ $OPTION != y ]]; do |
| 34 | setkeymap |
| 35 | read_input_text "Confirm keymap: $KEYMAP" |
| 36 | done |
Helmuth Saatkamp | 9330518 | 2013-06-03 15:13:45 -0300 | [diff] [blame] | 37 | loadkeys $KEYMAP |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 38 | } |
| 39 | #}}} |
| 40 | #DEFAULT EDITOR {{{ |
| 41 | select_editor(){ |
| 42 | print_title "DEFAULT EDITOR" |
| 43 | editors_list=("emacs" "nano" "vi" "vim"); |
| 44 | PS3="$prompt1" |
| 45 | echo -e "Select editor\n" |
| 46 | select EDITOR in "${editors_list[@]}"; do |
| 47 | if contains_element "$EDITOR" "${editors_list[@]}"; then |
| 48 | package_install "$EDITOR" |
| 49 | break |
| 50 | else |
| 51 | invalid_option |
| 52 | fi |
| 53 | done |
| 54 | } |
| 55 | #}}} |
| 56 | #MIRRORLIST {{{ |
| 57 | configure_mirrorlist(){ |
| 58 | local countries_code=("AU" "BY" "BE" "BR" "BG" "CA" "CL" "CN" "CO" "CZ" "DK" "EE" "FI" "FR" "DE" "GR" "HU" "IN" "IE" "IL" "IT" "JP" "KZ" "KR" "LV" "LU" "MK" "NL" "NC" "NZ" "NO" "PL" "PT" "RO" "RU" "RS" "SG" "SK" "ZA" "ES" "LK" "SE" "CH" "TW" "TR" "UA" "GB" "US" "UZ" "VN") |
| 59 | local countries_name=("Australia" "Belarus" "Belgium" "Brazil" "Bulgaria" "Canada" "Chile" "China" "Colombia" "Czech Republic" "Denmark" "Estonia" "Finland" "France" "Germany" "Greece" "Hungary" "India" "Ireland" "Israel" "Italy" "Japan" "Kazakhstan" "Korea" "Latvia" "Luxembourg" "Macedonia" "Netherlands" "New Caledonia" "New Zealand" "Norway" "Poland" "Portugal" "Romania" "Russian" "Serbia" "Singapore" "Slovakia" "South Africa" "Spain" "Sri Lanka" "Sweden" "Switzerland" "Taiwan" "Turkey" "Ukraine" "United Kingdom" "United States" "Uzbekistan" "Viet Nam") |
| 60 | country_list(){ |
| 61 | #`reflector --list-countries | sed 's/[0-9]//g' | sed 's/^/"/g' | sed 's/,.*//g' | sed 's/ *$//g' | sed 's/$/"/g' | sed -e :a -e '$!N; s/\n/ /; ta'` |
| 62 | PS3="$prompt1" |
| 63 | echo "Select your country:" |
| 64 | select OPT in "${countries_name[@]}"; do |
| 65 | if contains_element "$OPT" "${countries_name[@]}"; then |
| 66 | country=${countries_code[$(( $REPLY - 1 ))]} |
| 67 | break |
| 68 | else |
| 69 | invalid_option |
| 70 | fi |
| 71 | done |
| 72 | } |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 73 | print_title "MIRRORLIST - https://wiki.archlinux.org/index.php/Mirrors" |
| 74 | print_info "This option is a guide to selecting and configuring your mirrors, and a listing of current available mirrors." |
| 75 | OPTION=n |
| 76 | while [[ $OPTION != y ]]; do |
| 77 | country_list |
| 78 | read_input_text "Confirm country: $OPT" |
| 79 | done |
| 80 | |
Helmuth Saatkamp | 866ea8b | 2013-06-03 15:20:30 -0300 | [diff] [blame] | 81 | url="https://www.archlinux.org/mirrorlist/?country=${country}&use_mirror_status=on" |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 82 | |
| 83 | tmpfile=$(mktemp --suffix=-mirrorlist) |
| 84 | |
| 85 | # Get latest mirror list and save to tmpfile |
Helmuth Saatkamp | 9e582f0 | 2013-06-03 15:03:52 -0300 | [diff] [blame] | 86 | curl -so ${tmpfile} ${url} |
Helmuth Saatkamp | d00ac39 | 2013-06-03 14:49:26 -0300 | [diff] [blame] | 87 | sed -i 's/^#Server/Server/g' ${tmpfile} |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 88 | |
| 89 | # Backup and replace current mirrorlist file (if new file is non-zero) |
Helmuth Saatkamp | d00ac39 | 2013-06-03 14:49:26 -0300 | [diff] [blame] | 90 | if [[ -s ${tmpfile} ]]; then |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 91 | { echo " Backing up the original mirrorlist..." |
| 92 | mv -i /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig; } && |
| 93 | { echo " Rotating the new list into place..." |
Helmuth Saatkamp | d00ac39 | 2013-06-03 14:49:26 -0300 | [diff] [blame] | 94 | mv -i ${tmpfile} /etc/pacman.d/mirrorlist; } |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 95 | else |
| 96 | echo " Unable to update, could not download list." |
| 97 | fi |
| 98 | # allow global read access (required for non-root yaourt execution) |
| 99 | chmod +r /etc/pacman.d/mirrorlist |
| 100 | $EDITOR /etc/pacman.d/mirrorlist |
| 101 | } |
| 102 | #}}} |
| 103 | #CREATE PARTITION {{{ |
| 104 | create_partition(){ |
| 105 | select_device(){ |
| 106 | devices_list=(`lsblk -d | awk '{print "/dev/" $1}' | grep 'sd\|hd'`); |
| 107 | PS3="$prompt1" |
| 108 | echo -e "Select device:\n" |
| 109 | select DEVICE in "${devices_list[@]}"; do |
| 110 | if contains_element "$DEVICE" "${devices_list[@]}"; then |
| 111 | break |
| 112 | else |
| 113 | invalid_option |
| 114 | fi |
| 115 | done |
| 116 | } |
| 117 | print_title "https://wiki.archlinux.org/index.php/Partitioning" |
| 118 | print_info "Partitioning a hard drive allows one to logically divide the available space into sections that can be accessed independently of one another. Partition information is stored within a hard drive's Master Boot Record." |
| 119 | partition_app=("cfdisk" "cgdisk" "gdisk" "parted"); |
| 120 | PS3="$prompt1" |
| 121 | echo -e "Select partition program:" |
| 122 | select OPT in "${partition_app[@]}"; do |
| 123 | if contains_element "$OPT" "${partition_app[@]}"; then |
| 124 | select_device |
| 125 | $OPT $DEVICE |
| 126 | break |
| 127 | else |
| 128 | invalid_option |
| 129 | fi |
| 130 | done |
| 131 | } |
| 132 | #}}} |
| 133 | #FORMAT DEVICE {{{ |
| 134 | format_device(){ |
| 135 | print_title "https://wiki.archlinux.org/index.php/Format_a_device" |
| 136 | print_info "This step will select and format the selected partiton where the archlinux will be installed" |
| 137 | print_warning "\tAll data on the ROOT and SWAP partition will be LOST." |
| 138 | i=0 |
| 139 | partitions=(`cat /proc/partitions | awk 'length($3)>1' | awk '{print "/dev/" $4}' | awk 'length($0)>8' | grep 'sd\|hd'`) |
Helmuth | 19c9e39 | 2013-08-30 15:08:47 -0300 | [diff] [blame] | 140 | |
| 141 | if [[ $UEFI -eq 1 ]]; then |
| 142 | device_name=("root" "EFI" "swap" "another") |
| 143 | else |
| 144 | device_name=("root" "swap" "another") |
| 145 | fi |
Helmuth | 7bfb14e | 2013-09-04 09:00:31 -0300 | [diff] [blame] | 146 | |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 147 | select_filesystem(){ |
Helmuth | 7bfb14e | 2013-09-04 09:00:31 -0300 | [diff] [blame] | 148 | filesystem=( "btrfs" "ext2" "ext3" "ext4" "f2fs" "jfs" "nilfs2" "ntfs" "vfat" "xfs"); |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 149 | PS3="$prompt1" |
| 150 | echo -e "Select filesystem:\n" |
| 151 | select TYPE in "${filesystem[@]}"; do |
| 152 | if contains_element "$TYPE" "${filesystem[@]}"; then |
| 153 | break |
| 154 | else |
| 155 | invalid_option |
| 156 | fi |
| 157 | done |
| 158 | } |
| 159 | umount_partition(){ |
Helmuth | f26be34 | 2013-10-09 10:17:25 -0300 | [diff] [blame] | 160 | #umount swaps |
| 161 | swapoff -a |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 162 | #check if partition is mounted and umount |
| 163 | mount|grep $1 && umount $1 |
| 164 | } |
| 165 | remove_partition(){ |
| 166 | #remove the selected partition from list |
| 167 | unset partitions[$DEVICE_NUMBER] |
| 168 | partitions=(${partitions[@]}) |
| 169 | #increase i |
| 170 | [[ ${device_name[i]} != another ]] && i=$(( i + 1 )) |
| 171 | } |
| 172 | format_partition(){ |
| 173 | read_input_text "Confirm format $1 partition" |
| 174 | if [[ $OPTION == y ]]; then |
| 175 | umount_partition "$1" |
| 176 | [[ -z $3 ]] && select_filesystem |
| 177 | mkfs.$TYPE $1 |
| 178 | fsck $1 |
| 179 | mkdir -p $2 |
| 180 | mount -t $TYPE $1 $2 |
| 181 | remove_partition "$1" |
| 182 | fi |
| 183 | } |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 184 | create_swap(){ |
| 185 | swap_options=( "partition" "file" "skip"); |
| 186 | PS3="$prompt1" |
Helmuth | e8025ab | 2013-10-09 10:03:42 -0300 | [diff] [blame] | 187 | echo -e "Select ${BYellow}${device_name[i]}${White} type:\n" |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 188 | select TYPE in "${swap_options[@]}"; do |
| 189 | case "$REPLY" in |
| 190 | 1) |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 191 | select DEVICE in "${partitions[@]}"; do |
| 192 | #get the selected number - 1 |
| 193 | DEVICE_NUMBER=$(( $REPLY - 1 )) |
| 194 | if contains_element "$DEVICE" "${partitions[@]}"; then |
| 195 | read_input_text "Confirm format $DEVICE partition" |
| 196 | if [[ $OPTION == y ]]; then |
| 197 | umount_partition "$DEVICE" |
| 198 | mkswap $DEVICE |
| 199 | swapon $DEVICE |
| 200 | remove_partition "$DEVICE" |
| 201 | fi |
| 202 | fi |
| 203 | break |
| 204 | done |
Helmuth | e8025ab | 2013-10-09 10:03:42 -0300 | [diff] [blame] | 205 | break |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 206 | ;; |
| 207 | 2) |
| 208 | TOTAL_MEM=`grep MemTotal /proc/meminfo | awk '{print $2/1024}' | sed 's/\..*//'` |
Helmuth | 6a18374 | 2013-10-09 09:46:02 -0300 | [diff] [blame] | 209 | fallocate -l ${TOTAL_MEM}M $MOUNTPOINT/swapfile |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 210 | chmod 600 $MOUNTPOINT/swapfile |
| 211 | mkswap $MOUNTPOINT/swapfile |
| 212 | swapon $MOUNTPOINT/swapfile |
Helmuth | 6a18374 | 2013-10-09 09:46:02 -0300 | [diff] [blame] | 213 | i=$(( i + 1 )) |
Helmuth | e8025ab | 2013-10-09 10:03:42 -0300 | [diff] [blame] | 214 | break |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 215 | ;; |
| 216 | 3) |
Helmuth | 35141f5 | 2013-10-09 09:54:57 -0300 | [diff] [blame] | 217 | i=$(( i + 1 )) |
Helmuth | e8025ab | 2013-10-09 10:03:42 -0300 | [diff] [blame] | 218 | break |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 219 | ;; |
| 220 | *) |
| 221 | invalid_option |
| 222 | ;; |
Helmuth | 1c67122 | 2013-10-09 09:38:20 -0300 | [diff] [blame] | 223 | esac |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 224 | done |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 225 | } |
| 226 | function check_mountpoint(){ |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 227 | if mount|grep $2; then |
| 228 | echo "Successfully mounted" |
| 229 | remove_partition "$1" |
| 230 | else |
| 231 | echo "WARNING: Not Successfully mounted" |
| 232 | fi |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 233 | } |
| 234 | while true; do |
| 235 | PS3="$prompt1" |
Helmuth | 4641564 | 2013-10-09 09:29:38 -0300 | [diff] [blame] | 236 | if [[ ${device_name[i]} == swap ]]; then |
| 237 | create_swap |
Helmuth | 6c8fc7e | 2013-10-09 10:12:29 -0300 | [diff] [blame] | 238 | else |
| 239 | echo -e "Select ${BYellow}${device_name[i]}${White} partition:\n" |
| 240 | select DEVICE in "${partitions[@]}"; do |
| 241 | #get the selected number - 1 |
| 242 | DEVICE_NUMBER=$(( $REPLY - 1 )) |
| 243 | if contains_element "$DEVICE" "${partitions[@]}"; then |
| 244 | case ${device_name[i]} in |
| 245 | root) |
| 246 | ROOT_DEVICE=$DEVICE |
| 247 | # MBR |
| 248 | BOOT_DEVICE=`echo $ROOT_DEVICE | sed 's/[0-9]//'` |
| 249 | format_partition "$DEVICE" "$MOUNTPOINT" |
| 250 | ;; |
| 251 | EFI) |
| 252 | format_partition "$DEVICE" "$MOUNTPOINT"/boot/efi |
| 253 | ;; |
| 254 | another) |
| 255 | read -p "Mountpoint [ex: /home]:" DIR |
| 256 | select_filesystem |
| 257 | read_input_text "Format $DEVICE partition" |
| 258 | if [[ $OPTION == y ]]; then |
| 259 | format_partition "$DEVICE" "$MOUNTPOINT$DIR" "$TYPE" |
| 260 | else |
| 261 | read_input_text "Confirm type="$TYPE" dev="$DEVICE" dir="$DIR"" |
| 262 | if [[ $OPTION == y ]]; then |
| 263 | mkdir -p $MOUNTPOINT$DIR |
| 264 | mount -t $TYPE $DEVICE $MOUNTPOINT$DIR |
| 265 | check_mountpoint "$DEVICE" "$MOUNTPOINT$DIR" |
| 266 | fi |
| 267 | [[ $DIR == "/boot" ]] && BOOT_DEVICE=$DEVICE |
| 268 | fi |
| 269 | ;; |
| 270 | esac |
| 271 | break |
| 272 | else |
| 273 | invalid_option |
| 274 | fi |
| 275 | done |
| 276 | fi |
| 277 | #check if there is no partitions left |
| 278 | if [[ ${#partitions[@]} -eq 0 && ${device_name[i]} != swap ]]; then |
Helmuth | f8562db | 2013-10-09 09:42:46 -0300 | [diff] [blame] | 279 | break |
Helmuth | 35141f5 | 2013-10-09 09:54:57 -0300 | [diff] [blame] | 280 | elif [[ ${device_name[i]} == another ]]; then |
| 281 | read_input_text "Configure more partitions" |
| 282 | [[ $OPTION != y ]] && break |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 283 | fi |
| 284 | done |
| 285 | pause_function |
| 286 | } |
| 287 | #}}} |
| 288 | #INSTALL BASE SYSTEM {{{ |
| 289 | install_base_system(){ |
| 290 | print_title "INSTALL BASE SYSTEM" |
| 291 | print_info "Using the pacstrap script we install the base system. The base-devel package group will be installed also." |
| 292 | pacstrap $MOUNTPOINT base base-devel btrfs-progs ntp |
Helmuth | 39b5254 | 2013-08-09 12:18:52 -0300 | [diff] [blame] | 293 | WIRELESS_DEV=`ip link | grep wlp | awk '{print $2}'| sed 's/://'` |
| 294 | if [[ -n $WIRELESS_DEV ]]; then |
Helmuth | 0fd4d14 | 2013-08-23 14:09:13 -0300 | [diff] [blame] | 295 | pacstrap $MOUNTPOINT iw wireless_tools wpa_actiond wpa_supplicant dialog |
Helmuth | 39b5254 | 2013-08-09 12:18:52 -0300 | [diff] [blame] | 296 | fi |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 297 | } |
| 298 | #}}} |
| 299 | #CONFIGURE KEYMAP {{{ |
| 300 | configure_keymap(){ |
| 301 | #ADD KEYMAP TO THE NEW SETUP |
| 302 | echo "KEYMAP=$KEYMAP" > $MOUNTPOINT/etc/vconsole.conf |
| 303 | } |
| 304 | #}}} |
| 305 | #CONFIGURE FSTAB {{{ |
| 306 | configure_fstab(){ |
| 307 | print_title "FSTAB - https://wiki.archlinux.org/index.php/Fstab" |
| 308 | print_info "The /etc/fstab file contains static filesystem information. It defines how storage devices and partitions are to be mounted and integrated into the overall system. It is read by the mount command to determine which options to use when mounting a specific device or partition." |
| 309 | if [[ ! -f $MOUNTPOINT/etc/fstab.aui ]]; then |
| 310 | cp $MOUNTPOINT/etc/fstab $MOUNTPOINT/etc/fstab.aui |
| 311 | else |
| 312 | cp $MOUNTPOINT/etc/fstab.aui $MOUNTPOINT/etc/fstab |
| 313 | fi |
| 314 | FSTAB=("DEV" "UUID" "LABEL"); |
| 315 | PS3="$prompt1" |
| 316 | echo -e "Configure fstab based on:" |
| 317 | select OPT in "${FSTAB[@]}"; do |
| 318 | case "$REPLY" in |
| 319 | 1) genfstab -p $MOUNTPOINT >> $MOUNTPOINT/etc/fstab ;; |
| 320 | 2) genfstab -U $MOUNTPOINT >> $MOUNTPOINT/etc/fstab ;; |
| 321 | 3) genfstab -L $MOUNTPOINT >> $MOUNTPOINT/etc/fstab ;; |
| 322 | *) invalid_option ;; |
| 323 | esac |
| 324 | [[ -n $OPT ]] && break |
| 325 | done |
| 326 | echo "Review your fstab" |
Helmuth | 2107ec0 | 2013-10-09 11:47:03 -0300 | [diff] [blame^] | 327 | sed -i "s/\\${MOUNTPOINT}//" $MOUNTPOINT/etc/fstab |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 328 | pause_function |
| 329 | $EDITOR $MOUNTPOINT/etc/fstab |
| 330 | } |
| 331 | #}}} |
| 332 | #CONFIGURE HOSTNAME {{{ |
| 333 | configure_hostname(){ |
| 334 | print_title "HOSTNAME - https://wiki.archlinux.org/index.php/HOSTNAME" |
| 335 | print_info "A host name is a unique name created to identify a machine on a network.Host names are restricted to alphanumeric characters.\nThe hyphen (-) can be used, but a host name cannot start or end with it. Length is restricted to 63 characters." |
| 336 | read -p "Hostname [ex: archlinux]: " HN |
| 337 | echo "$HN" > $MOUNTPOINT/etc/hostname |
| 338 | if [[ ! -f $MOUNTPOINT/etc/hosts.aui ]]; then |
| 339 | cp $MOUNTPOINT/etc/hosts $MOUNTPOINT/etc/hosts.aui |
| 340 | else |
| 341 | cp $MOUNTPOINT/etc/hosts.aui $MOUNTPOINT/etc/hosts |
| 342 | fi |
| 343 | arch_chroot "sed -i '/127.0.0.1/s/$/ '${HN}'/' /etc/hosts" |
| 344 | arch_chroot "sed -i '/::1/s/$/ '${HN}'/' /etc/hosts" |
| 345 | } |
| 346 | #}}} |
| 347 | #CONFIGURE TIMEZONE {{{ |
| 348 | configure_timezone(){ |
| 349 | print_title "TIMEZONE - https://wiki.archlinux.org/index.php/Timezone" |
| 350 | print_info "In an operating system the time (clock) is determined by four parts: Time value, Time standard, Time Zone, and DST (Daylight Saving Time if applicable)." |
| 351 | OPTION=n |
| 352 | while [[ $OPTION != y ]]; do |
| 353 | settimezone |
| 354 | read_input_text "Confirm timezone ($ZONE/$SUBZONE)" |
| 355 | done |
| 356 | arch_chroot "ln -s /usr/share/zoneinfo/${ZONE}/${SUBZONE} /etc/localtime" |
| 357 | } |
| 358 | #}}} |
| 359 | #CONFIGURE HARDWARECLOCK {{{ |
| 360 | configure_hardwareclock(){ |
| 361 | print_title "HARDWARE CLOCK TIME - https://wiki.archlinux.org/index.php/Internationalization" |
| 362 | print_info "This is set in /etc/adjtime. Set the hardware clock mode uniformly between your operating systems on the same machine. Otherwise, they will overwrite the time and cause clock shifts (which can cause time drift correction to be miscalibrated)." |
| 363 | hwclock_list=('UTC' 'Localtime'); |
| 364 | PS3="$prompt1" |
| 365 | select OPT in "${hwclock_list[@]}"; do |
| 366 | case "$REPLY" in |
| 367 | 1) arch_chroot "hwclock --systohc --utc"; |
| 368 | ;; |
| 369 | 2) arch_chroot "hwclock --systohc --localtime"; |
| 370 | ;; |
| 371 | *) invalid_option ;; |
| 372 | esac |
| 373 | [[ -n $OPT ]] && break |
| 374 | done |
| 375 | } |
| 376 | #}}} |
| 377 | #CONFIGURE LOCALE {{{ |
| 378 | configure_locale(){ |
| 379 | print_title "LOCALE - https://wiki.archlinux.org/index.php/Locale" |
| 380 | print_info "Locales are used in Linux to define which language the user uses. As the locales define the character sets being used as well, setting up the correct locale is especially important if the language contains non-ASCII characters." |
| 381 | OPTION=n |
| 382 | while [[ $OPTION != y ]]; do |
| 383 | setlocale |
| 384 | read_input_text "Confirm locale ($LOCALE)" |
| 385 | done |
| 386 | echo 'LANG="'$LOCALE_UTF8'"' > $MOUNTPOINT/etc/locale.conf |
| 387 | arch_chroot "sed -i '/'${LOCALE}'/s/^#//' /etc/locale.gen" |
| 388 | arch_chroot "locale-gen" |
| 389 | } |
| 390 | #}}} |
| 391 | #CONFIGURE MKINITCPIO {{{ |
| 392 | configure_mkinitcpio(){ |
| 393 | print_title "MKINITCPIO - https://wiki.archlinux.org/index.php/Mkinitcpio" |
| 394 | print_info "mkinitcpio is a Bash script used to create an initial ramdisk environment." |
| 395 | arch_chroot "mkinitcpio -p linux" |
| 396 | } |
| 397 | #}}} |
| 398 | #INSTALL BOOTLOADER {{{ |
| 399 | install_bootloader(){ |
| 400 | print_title "BOOTLOADER - https://wiki.archlinux.org/index.php/Bootloader" |
| 401 | print_info "The boot loader is responsible for loading the kernel and initial RAM disk before initiating the boot process." |
| 402 | bootloader=("Grub2" "Syslinux" "Skip") |
| 403 | PS3="$prompt1" |
| 404 | echo -e "Install bootloader:\n" |
| 405 | select BOOTLOADER in "${bootloader[@]}"; do |
| 406 | case "$REPLY" in |
| 407 | 1) |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 408 | #make grub automatically detect others OS |
Helmuth | 39b5254 | 2013-08-09 12:18:52 -0300 | [diff] [blame] | 409 | if [[ $UEFI -eq 1 ]]; then |
| 410 | pacstrap $MOUNTPOINT grub efibootmgr |
| 411 | else |
| 412 | pacstrap $MOUNTPOINT grub |
| 413 | fi |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 414 | pacstrap $MOUNTPOINT os-prober |
| 415 | break |
| 416 | ;; |
| 417 | 2) |
| 418 | pacstrap $MOUNTPOINT syslinux |
| 419 | break |
| 420 | ;; |
| 421 | 3) |
| 422 | break |
| 423 | ;; |
| 424 | *) |
| 425 | invalid_option |
| 426 | ;; |
| 427 | esac |
| 428 | done |
| 429 | } |
| 430 | #}}} |
| 431 | #CONFIGURE BOOTLOADER {{{ |
| 432 | configure_bootloader(){ |
| 433 | case $BOOTLOADER in |
| 434 | Grub2) |
| 435 | print_title "GRUB2 - https://wiki.archlinux.org/index.php/GRUB2" |
| 436 | print_info "GRUB2 is the next generation of the GRand Unified Bootloader (GRUB).\nIn brief, the bootloader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel." |
| 437 | arch_chroot "modprobe dm-mod" |
| 438 | if [[ $UEFI -eq 1 ]]; then |
| 439 | arch_chroot "grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck" |
| 440 | else |
Helmuth | 39b5254 | 2013-08-09 12:18:52 -0300 | [diff] [blame] | 441 | arch_chroot "grub-install --recheck ${BOOT_DEVICE}" |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 442 | fi |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 443 | arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" |
| 444 | ;; |
| 445 | Syslinux) |
| 446 | print_title "SYSLINUX - https://wiki.archlinux.org/index.php/Syslinux" |
| 447 | print_info "Syslinux is a collection of boot loaders capable of booting from hard drives, CDs, and over the network via PXE. It supports the fat, ext2, ext3, ext4, and btrfs file systems." |
| 448 | syslinux_install_mode=("Automatic" "Manual") |
| 449 | PS3="$prompt1" |
| 450 | echo -e "Syslinux Install:\n" |
| 451 | select OPT in "${syslinux_install_mode[@]}"; do |
| 452 | case "$REPLY" in |
| 453 | 1) |
Helmuth | df52c6e | 2013-08-15 14:06:49 -0300 | [diff] [blame] | 454 | arch_chroot "syslinux-install_update -iam" |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 455 | break |
| 456 | ;; |
| 457 | 2) |
| 458 | print_info "Your boot partition, on which you plan to install Syslinux, must contain a FAT, ext2, ext3, ext4, or Btrfs file system. You should install it on a mounted directory, not a /dev/sdXY device. You do not have to install it on the root directory of a file system, e.g., with device /dev/sda1 mounted on /boot you can install Syslinux in the syslinux directory" |
| 459 | echo -e $prompt3 |
| 460 | print_warning "mkdir /boot/syslinux\nextlinux --install /boot/syslinux " |
| 461 | arch-chroot $MOUNTPOINT |
| 462 | break |
| 463 | ;; |
| 464 | *) |
| 465 | invalid_option |
| 466 | ;; |
| 467 | esac |
| 468 | done |
| 469 | ;; |
| 470 | esac |
| 471 | } |
| 472 | #}}} |
| 473 | #ROOT PASSWORD {{{ |
| 474 | root_password(){ |
| 475 | print_title "ROOT PASSWORD" |
| 476 | print_warning "Enter your new root password" |
| 477 | arch_chroot "passwd" |
| 478 | pause_function |
| 479 | } |
| 480 | #}}} |
| 481 | #FINISH {{{ |
| 482 | finish(){ |
| 483 | print_title "INSTALL COMPLETED" |
| 484 | #COPY AUI TO ROOT FOLDER IN THE NEW SYSTEM |
| 485 | print_warning "\nA copy of the AUI will be placed in /root directory of your new system" |
| 486 | cp -R `pwd` $MOUNTPOINT/root |
| 487 | read_input_text "Reboot system" |
| 488 | if [[ $OPTION == y ]]; then |
| 489 | #umount mounted partitions |
| 490 | mounted_partitions=(`findmnt --fstab -o TARGET -t noswap,notmpfs | grep /mnt`) |
| 491 | for i in ${mounted_partitions[@]}; do |
| 492 | umount $i |
| 493 | done |
| 494 | reboot |
| 495 | fi |
| 496 | exit 0 |
| 497 | } |
| 498 | #}}} |
| 499 | |
| 500 | print_title "https://wiki.archlinux.org/index.php/Arch_Install_Scripts" |
| 501 | print_info "The Arch Install Scripts are a set of Bash scripts that simplify Arch installation." |
| 502 | pause_function |
Helmuth | 19c9e39 | 2013-08-30 15:08:47 -0300 | [diff] [blame] | 503 | check_boot_system |
Helmuth | cd3331d | 2013-08-09 12:21:57 -0300 | [diff] [blame] | 504 | check_connection |
Helmuth | f26be34 | 2013-10-09 10:17:25 -0300 | [diff] [blame] | 505 | pacman -Sy |
Helmuth Saatkamp | 7d3a37f | 2013-04-24 10:51:46 -0300 | [diff] [blame] | 506 | while true |
| 507 | do |
| 508 | print_title "ARCHLINUX ULTIMATE INSTALL - https://github.com/helmuthdu/aui" |
| 509 | echo " 1) $(mainmenu_item "${checklist[1]}" "Select Keymap")" |
| 510 | echo " 2) $(mainmenu_item "${checklist[2]}" "Select Editor")" |
| 511 | echo " 3) $(mainmenu_item "${checklist[3]}" "Configure Mirrorlist")" |
| 512 | echo " 4) $(mainmenu_item "${checklist[4]}" "Create Partition")" |
| 513 | echo " 5) $(mainmenu_item "${checklist[5]}" "Format Device")" |
| 514 | echo " 6) $(mainmenu_item "${checklist[6]}" "Install Base System")" |
| 515 | echo " 7) $(mainmenu_item "${checklist[7]}" "Configure Fstab")" |
| 516 | echo " 8) $(mainmenu_item "${checklist[8]}" "Configure Hostname")" |
| 517 | echo " 9) $(mainmenu_item "${checklist[9]}" "Configure Timezone")" |
| 518 | echo "10) $(mainmenu_item "${checklist[10]}" "Configure Hardware Clock")" |
| 519 | echo "11) $(mainmenu_item "${checklist[11]}" "Configure Locale")" |
| 520 | echo "12) $(mainmenu_item "${checklist[12]}" "Configure Mkinitcpio")" |
| 521 | echo "13) $(mainmenu_item "${checklist[13]}" "Install Bootloader")" |
| 522 | echo "14) $(mainmenu_item "${checklist[14]}" "Root Password")" |
| 523 | echo "" |
| 524 | echo " d) Done" |
| 525 | echo "" |
| 526 | read_input_options |
| 527 | for OPT in ${OPTIONS[@]}; do |
| 528 | case "$OPT" in |
| 529 | 1) |
| 530 | select_keymap |
| 531 | checklist[1]=1 |
| 532 | ;; |
| 533 | 2) |
| 534 | select_editor |
| 535 | checklist[2]=1 |
| 536 | ;; |
| 537 | 3) |
| 538 | configure_mirrorlist |
| 539 | checklist[3]=1 |
| 540 | ;; |
| 541 | 4) |
| 542 | create_partition |
| 543 | checklist[4]=1 |
| 544 | ;; |
| 545 | 5) |
| 546 | format_device |
| 547 | checklist[5]=1 |
| 548 | ;; |
| 549 | 6) |
| 550 | install_base_system |
| 551 | configure_keymap |
| 552 | checklist[6]=1 |
| 553 | ;; |
| 554 | 7) |
| 555 | configure_fstab |
| 556 | checklist[7]=1 |
| 557 | ;; |
| 558 | 8) |
| 559 | configure_hostname |
| 560 | checklist[8]=1 |
| 561 | ;; |
| 562 | 9) |
| 563 | configure_timezone |
| 564 | checklist[9]=1 |
| 565 | ;; |
| 566 | 10) |
| 567 | configure_hardwareclock |
| 568 | checklist[10]=1 |
| 569 | ;; |
| 570 | 11) |
| 571 | configure_locale |
| 572 | checklist[11]=1 |
| 573 | ;; |
| 574 | 12) |
| 575 | configure_mkinitcpio |
| 576 | checklist[12]=1 |
| 577 | ;; |
| 578 | 13) |
| 579 | install_bootloader |
| 580 | configure_bootloader |
| 581 | checklist[13]=1 |
| 582 | ;; |
| 583 | 14) |
| 584 | root_password |
| 585 | checklist[14]=1 |
| 586 | ;; |
| 587 | "d") |
| 588 | finish |
| 589 | ;; |
| 590 | *) |
| 591 | invalid_option |
| 592 | ;; |
| 593 | esac |
| 594 | done |
| 595 | done |
| 596 | #}}} |