manjaro-arm-installer 15.6 KB
Newer Older
Dan Johansen's avatar
Dan Johansen committed
1 2 3
#! /bin/bash

# Set globals
4
TMPDIR=/var/tmp/manjaro-arm-installer
5
ARCH='aarch64'
6
NSPAWN='systemd-nspawn -q --resolv-conf=copy-host --timezone=off -D'
Dan Johansen's avatar
Dan Johansen committed
7

8 9 10 11 12 13 14
# clearing variables
DEVICE=""
EDITION=""
USER=""
PASSWORD=""
ROOTPASSWORD=""
SDCARD=""
15 16
TIMEZONE=""
LOCALE=""
17

18 19 20 21 22 23
# check if root
if [ "$EUID" -ne 0 ]
  then echo "This script requires root permissions to run. Please run as root or with sudo!"
  exit
fi

24
# Sanity checks for dependencies
25
if [ ! -f /usr/bin/git ]; then
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    echo "git command is missing! Please install git!"
    exit 1
    elif [ ! -f /usr/bin/parted ]; then
    echo "parted command is missing! Please install parted!"
    exit 1
    elif [ ! -f /usr/bin/systemd-nspawn ]; then
    echo "systemd-nspawn command is missing! Please install systemd!"
    exit 1
    elif [ ! -f /usr/bin/wget ]; then
    echo "wget command is missing! Please install wget!"
    exit 1
    elif [ ! -f /usr/bin/dialog ]; then
    echo "dialog command is missing! Please install dialog!"
    exit 1
    elif [ ! -f /usr/bin/bsdtar ]; then
    echo "bsdtar command is missing! Please install libarchive!"
    exit 1
fi
44

Dan Johansen's avatar
Dan Johansen committed
45 46

# Functions
47 48 49 50 51 52 53 54
msg() {
    ALL_OFF="\e[1;0m"
    BOLD="\e[1;1m"
    GREEN="${BOLD}\e[1;32m"
      local mesg=$1; shift
      printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
 }

55 56 57 58 59 60 61
info() {
    ALL_OFF="\e[1;0m"
    BOLD="\e[1;1m"
    BLUE="${BOLD}\e[1;34m"
      local mesg=$1; shift
      printf "${BLUE}  ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
 }
Dan Johansen's avatar
Dan Johansen committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

usage_build_installer() {
    echo "Usage: ${0##*/} [options]"
    echo '    -h                 This help'
    echo ''
    echo ''
    exit $1
}

get_timer(){
    echo $(date +%s)
}

# $1: start timer
elapsed_time(){
    echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
}

show_elapsed_time(){
    msg "Time %s: %s minutes..." "$1" "$(elapsed_time $2)"
}

84
getarmprofiles () {
85
    info "Getting package lists ready for $DEVICE $EDITION edition..."
86 87 88
    if ls $TMPDIR/arm-profiles/* 1> /dev/null 2>&1; then
        cd $TMPDIR/arm-profiles
        git pull 1> /dev/null 2>&1
89
    else
90 91
        mkdir -p $TMPDIR
        chmod 777 $TMPDIR
92 93
        cd $TMPDIR
        git clone https://gitlab.com/Strit/arm-profiles.git 1> /dev/null 2>&1
94 95 96 97 98 99 100 101 102 103 104 105
    fi

}

create_install() {
 if [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "xu4" ]]; then
        ARCH='armv7h'
    else
        ARCH='aarch64'
    fi

    msg "Creating install for $DEVICE..."
106 107
    
    # fetch and extract rootfs
108
    info "Downloading latest $ARCH rootfs..."
109
    cd $TMPDIR
110
    wget -q --show-progress --progress=bar:force:noscroll https://www.strits.dk/files/Manjaro-ARM-$ARCH-latest.tar.gz
111
    
112
    info "Extracting $ARCH rootfs..."
113
    bsdtar -xpf $TMPDIR/Manjaro-ARM-$ARCH-latest.tar.gz -C $TMPDIR/root
Dan Johansen's avatar
Dan Johansen committed
114
    
115
    info "Setting up keyrings..."
Dan Johansen's avatar
Dan Johansen committed
116 117
    $NSPAWN $TMPDIR/root pacman-key --init 1> /dev/null 2>&1
    $NSPAWN $TMPDIR/root pacman-key --populate archlinuxarm manjaro manjaro-arm 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
118
    
119
    info "Installing packages for $EDITION on $DEVICE..."
Dan Johansen's avatar
Dan Johansen committed
120
    # Install device and editions specific packages
121
    $NSPAWN $TMPDIR/root pacman -Syyu base $PKG_DEVICE $PKG_EDITION --noconfirm
Dan Johansen's avatar
Dan Johansen committed
122
    
123
    info "Enabling services..."
Dan Johansen's avatar
Dan Johansen committed
124
    # Enable services
Dan Johansen's avatar
Dan Johansen committed
125 126
    $NSPAWN $TMPDIR/root systemctl enable systemd-networkd.service getty.target haveged.service dhcpcd.service 1> /dev/null 2>&1
    $NSPAWN $TMPDIR/root systemctl enable $SRV_EDITION 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
127

128
    info "Applying overlay for $EDITION..."
129
    cp -ap $TMPDIR/arm-profiles/overlays/$EDITION/* $TMPDIR/root/
Dan Johansen's avatar
Dan Johansen committed
130
    
131
    info "Setting up users..."
Dan Johansen's avatar
Dan Johansen committed
132
    #setup users
133 134 135
    echo "$USER" > $TMPDIR/user
    echo "$PASSWORD" >> $TMPDIR/password
    echo "$PASSWORD" >> $TMPDIR/password
136 137
    echo "$ROOTPASSWORD" >> $TMPDIR/rootpassword
    echo "$ROOTPASSWORD" >> $TMPDIR/rootpassword
Dan Johansen's avatar
Dan Johansen committed
138 139 140
    $NSPAWN $TMPDIR/root passwd root < $TMPDIR/rootpassword 1> /dev/null 2>&1
    $NSPAWN $TMPDIR/root useradd -m -g users -G wheel,storage,network,power -s /bin/bash $(cat $TMPDIR/user) 1> /dev/null 2>&1
    $NSPAWN $TMPDIR/root passwd $(cat $TMPDIR/user) < $TMPDIR/password 1> /dev/null 2>&1
141

Dan Johansen's avatar
Dan Johansen committed
142
    
143
    info "Enabling user services..."
Dan Johansen's avatar
Dan Johansen committed
144 145 146
    if [[ "$EDITION" = "minimal" ]] || [[ "$EDITION" = "server" ]]; then
        echo "No user services for $EDITION edition"
    else
Dan Johansen's avatar
Dan Johansen committed
147
        $NSPAWN $TMPDIR/root --user $(cat $TMPDIR/user) systemctl --user enable pulseaudio.service 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
148 149
    fi

150
    info "Setting up system settings..."
Dan Johansen's avatar
Dan Johansen committed
151
    #system setup
Dan Johansen's avatar
Dan Johansen committed
152
    $NSPAWN $TMPDIR/root chmod u+s /usr/bin/ping 1> /dev/null 2>&1
153 154 155 156
    rm -f $TMPDIR/root/etc/ssl/certs/ca-certificates.crt
    rm -f $TMPDIR/root/etc/ca-certificates/extracted/tls-ca-bundle.pem
    cp -a /etc/ssl/certs/ca-certificates.crt $TMPDIR/root/etc/ssl/certs/
    cp -a /etc/ca-certificates/extracted/tls-ca-bundle.pem $TMPDIR/root/etc/ca-certificates/extracted/
Dan Johansen's avatar
Dan Johansen committed
157 158
    $NSPAWN $TMPDIR/root ln -sf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime 1> /dev/null 2>&1
    $NSPAWN $TMPDIR/root sed -i s/"#$LOCALE"/"$LOCALE"/g /etc/locale.gen 1> /dev/null 2>&1
159
    echo "LANG=$LOCALE" | tee --append $TMPDIR/root/etc/locale.conf 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
160
    $NSPAWN $TMPDIR/root locale-gen
161
    echo "KEYMAP=$KEYMAP" | tee --append $TMPDIR/root/etc/vconsole.conf 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
162
    $NSPAWN $TMPDIR/root localectl set-x11-keymap $KEYMAP 1> /dev/null 2>&1
163 164 165
    echo "$HOSTNAME" | tee --append $TMPDIR/root/etc/hostname 1> /dev/null 2>&1
    chown -R root:root $TMPDIR/root/etc 1> /dev/null 2>&1
    chown root:polkitd $TMPDIR/root/etc/polkit-1/rules.d 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
166
    
167
    info "Doing device specific setups for $DEVICE..."
Dan Johansen's avatar
Dan Johansen committed
168
    if [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "rpi3" ]]; then
169 170 171 172
        echo "dtparam=audio=on" | tee --append $TMPDIR/root/boot/config.txt
        echo "hdmi_drive=2" | tee --append $TMPDIR/root/boot/config.txt
        echo "audio_pwm_mode=2" | tee --append $TMPDIR/root/boot/config.txt
        echo "/dev/mmcblk0p1  /boot   vfat    defaults        0       0" | tee --append $TMPDIR/root/etc/fstab
Dan Johansen's avatar
Dan Johansen committed
173
    elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]]; then
174
        $NSPAWN $TMPDIR/root systemctl enable amlogic.service 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
175
    elif [[ "$DEVICE" = "pinebook" ]]; then
Dan Johansen's avatar
Dan Johansen committed
176
        $NSPAWN $TMPDIR/root systemctl enable pinebook-post-install.service 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
177
    else
Dan Johansen's avatar
Dan Johansen committed
178
        echo "No device specific setting needed for $DEVICE"
Dan Johansen's avatar
Dan Johansen committed
179 180
    fi
    
181
    info "Cleaning install for unwanted files..."
Dan Johansen's avatar
Dan Johansen committed
182
       if [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "xu4" ]]; then
183
        rm $TMPDIR/root/usr/bin/qemu-arm-static
Dan Johansen's avatar
Dan Johansen committed
184
    else
185
        rm $TMPDIR/root/usr/bin/qemu-aarch64-static
Dan Johansen's avatar
Dan Johansen committed
186
    fi
187 188 189 190
    rm -rf $TMPDIR/root/var/cache/pacman/pkg/*
    rm -rf $TMPDIR/root/var/log/*
    rm -rf $TMPDIR/root/usr/lib/systemd/system/systemd-firstboot.service
    rm -rf $TMPDIR/root/etc/machine-id
191 192
    
    # Remove temp files on host
193 194
    rm -rf $TMPDIR/user $TMPDIR/password $TMPDIR/rootpassword
    rm -rf $TMPDIR/Manjaro-ARM-$ARCH-latest.tar.gz*
Dan Johansen's avatar
Dan Johansen committed
195

196
    msg "$DEVICE $EDITION install complete"
Dan Johansen's avatar
Dan Johansen committed
197 198 199
}

prepare_card () {
200
    msg "Getting $SDCARD ready for $DEVICE..."
Dan Johansen's avatar
Dan Johansen committed
201 202 203
    # For Raspberry Pi devices
    if [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "rpi3" ]]; then
        #partition with boot and root
204 205
        parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
        parted -s $SDCARD mkpart primary fat32 0% 100M 1> /dev/null 2>&1
206
        START=`cat /sys/block/$DEV_NAME/${DEV_NAME}1/start` 
Dan Johansen's avatar
Dan Johansen committed
207
        SIZE=`cat /sys/block/$DEV_NAME/${DEV_NAME}1/size`
208
        END_SECTOR=$(expr $START + $SIZE)
209 210 211 212
        parted -s $SDCARD mkpart primary ext4 "${END_SECTOR}s" 100% 1> /dev/null 2>&1
        partprobe $SDCARD 1> /dev/null 2>&1
        mkfs.vfat "${SDCARD}p1" 1> /dev/null 2>&1
        mkfs.ext4 "${SDCARD}p2" 1> /dev/null 2>&1
213 214
        
        #Mount SD card
Dan Johansen's avatar
Dan Johansen committed
215 216
        mkdir -p $TMPDIR/root
        mkdir -p $TMPDIR/boot
217 218
        mount ${SDCARD}1 $TMPDIR/boot
        mount ${SDCARD}2 $TMPDIR/root
Dan Johansen's avatar
Dan Johansen committed
219 220 221 222

    # For Odroid devices
    elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]] || [[ "$DEVICE" = "xu4" ]]; then
        #Clear first 8mb
223
        dd if=/dev/zero of=${SDCARD} bs=1M count=8 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
224 225
	
    #partition with a single root partition
226 227 228 229
        parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
        parted -s $SDCARD mkpart primary ext4 0% 100% 1> /dev/null 2>&1
        partprobe $SDCARD 1> /dev/null 2>&1
        mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}p1 1> /dev/null 2>&1
230 231
        
        #Mount SD card
Dan Johansen's avatar
Dan Johansen committed
232
        mkdir -p $TMPDIR/root
233 234
        chmod 777 -R $TMPDIR/root
        mount ${SDCARD}1 $TMPDIR/root
Dan Johansen's avatar
Dan Johansen committed
235

236 237
    # For pine devices
   elif [[ "$DEVICE" = "pinebook" ]] || [[ "$DEVICE" = "sopine" ]]; then
Dan Johansen's avatar
Dan Johansen committed
238 239

    #Clear first 8mb
240
        dd if=/dev/zero of=${SDCARD} bs=1M count=8 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
241 242
	
    #partition with a single root partition
243 244 245 246
        parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
        parted -s $SDCARD mkpart primary ext4 0% 100% 1> /dev/null 2>&1
        partprobe $SDCARD 1> /dev/null 2>&1
        mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}p1 1> /dev/null 2>&1
247 248
        
        # Mount SD card
Dan Johansen's avatar
Dan Johansen committed
249
        mkdir -p $TMPDIR/root
250 251
        chmod 777 -R $TMPDIR/root
        mount ${SDCARD}1 $TMPDIR/root
252

Dan Johansen's avatar
Dan Johansen committed
253
    # For rockpro64 device
254
    elif [[ "$DEVICE" = "rock64" ]] || [[ "$DEVICE" = "rockpro64" ]]; then
Dan Johansen's avatar
Dan Johansen committed
255 256

    #Clear first 8mb
257
        dd if=/dev/zero of=${SDCARD} bs=1M count=32 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
258 259
	
    #partition with a single root partition
260 261 262 263
        parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
        parted -s $SDCARD mkpart primary ext4 32M 100% 1> /dev/null 2>&1
        partprobe $SDCARD 1> /dev/null 2>&1
        mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}p1 1> /dev/null 2>&1
264 265
        
        # Mount SD card
Dan Johansen's avatar
Dan Johansen committed
266
        mkdir -p $TMPDIR/root
267 268
        chmod 777 -R $TMPDIR/root
        mount ${SDCARD}1 $TMPDIR/root
269 270 271 272 273 274 275 276
    fi
}

cleanup () {
    msg "Writing bootloader and cleaning up after install..."
   # For Raspberry Pi devices
    if [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "rpi3" ]]; then
       #copy rootfs contents over to the FS
277
        mv $TMPDIR/root/boot/* $TMPDIR/boot
278 279
        
        #clean up
280 281 282 283
        umount $TMPDIR/root
        umount $TMPDIR/boot
        rm -r $TMPDIR/root $TMPDIR/boot
        partprobe $SDCARD 1> /dev/null 2>&1
284 285 286 287 288
        
# For Odroid devices
    elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]] || [[ "$DEVICE" = "xu4" ]]; then
    #flash bootloader
        cd $TMPDIR/root/boot/
289
        ./sd_fusing.sh $SDCARD 1> /dev/null 2>&1
290 291 292
        cd ~

    #clean up
293 294 295
        umount $TMPDIR/root
        rm -r $TMPDIR/root
        partprobe $SDCARD 1> /dev/null 2>&1
296 297
        
    # For pinebook device
298
    elif [[ "$DEVICE" = "pinebook" ]] || [[ "$DEVICE" = "sopine" ]]; then
299
    #flash bootloader
300
        dd if=$TMPDIR/root/boot/u-boot-sunxi-with-spl-$DEVICE.bin of=${SDCARD} bs=8k seek=1 1> /dev/null 2>&1
301 302
        
    #clean up
303 304 305
        umount $TMPDIR/root
        rm -r $TMPDIR/root
        partprobe $SDCARD 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
306
        
307 308
        
    # For rockpro64 device
309
    elif [[ "$DEVICE" = "rock64" ]] || [[ "$DEVICE" = "rockpro64" ]]; then
Dan Johansen's avatar
Dan Johansen committed
310
    #flash bootloader
311 312 313
        dd if=$TMPDIR/root/boot/idbloader.img of=${SDCARD} seek=64 conv=notrunc 1> /dev/null 2>&1
        dd if=$TMPDIR/root/boot/uboot.img of=${SDCARD} seek=16384 conv=notrunc 1> /dev/null 2>&1
        dd if=$TMPDIR/root/boot/trust.img of=${SDCARD} seek=24576 conv=notrunc 1> /dev/null 2>&1
Dan Johansen's avatar
Dan Johansen committed
314 315
        
    #clean up
316 317 318
        umount $TMPDIR/root
        rm -r $TMPDIR/root
        partprobe $SDCARD 1> /dev/null 2>&1
319 320
        
fi
Dan Johansen's avatar
Dan Johansen committed
321 322
}

323 324

# Using Dialog to ask for user input for variables
325 326
DEVICE=$(dialog --clear --title "Manjaro ARM Installer" \
        --menu "Choose a device:" 20 51 6 \
327 328
        "rpi3" "Raspberry Pi 3" \
        "oc2" "Odroid C2" \
329
	"pinebook" "Pinebook" \
330 331
	"sopine" "Sopine/Pine64-LTS" \
	"rock64" "Rock64" \
332 333 334
	"rpi2" "Raspberry Pi 2 (unmaintained)" \
	"oc1" "Odroid C1/C1+ (unmaintained)" \
	"xu4" "Odroid XU4 (unmaintained)" 3>&1 1>&2 2>&3 3>&-)
335 336 337 338 339


#The if statement makes sure that the user has put in something in the previous prompt. If not (left blank or pressed cancel) the script will end
if [ ! -z "$DEVICE" ]
then
340 341
EDITION=$(dialog --clear --title "Manjaro ARM Installer" \
	--menu "Choose an edition:" 20 50 5 \
342 343
	"minimal" "Minimal Edition (Just CLI)" \
	"lxqt" "Full LXQT Desktop and apps (lightweight)" \
344
	"kde" "Full KDE/Plasma Desktop (Heavy)" \
345
	"mate" "Full MATE desktop and apps (lightweight, unmaintained)" \
346
	"i3" "Mininal i3 WM with apps (very light)" 3>&1 1>&2 2>&3 3>&-) 
347 348 349 350 351 352 353 354 355

else 
	clear
	exit 1
fi


if [ ! -z "$EDITION" ]
then
356
USER=$(dialog --clear --title "Manjaro ARM Installer" \
357 358 359 360 361 362 363 364 365 366 367 368
	--inputbox "Enter username:" 8 50 \
        3>&1 1>&2 2>&3 3>&-)
else 
	clear
	exit 1
fi




if [ ! -z "$USER" ]
then
369 370
PASSWORD=$(dialog --clear --title "Manjaro ARM Installer" \
	--passwordbox "Enter Password for $USER:" 8 50 \
371 372 373 374 375 376 377 378 379 380 381
        3>&1 1>&2 2>&3 3>&- \
	)
else 
	clear
	exit 1
fi



if [ ! -z "$PASSWORD" ]
then
382
ROOTPASSWORD=$(dialog --clear --title "Manjaro ARM Installer" \
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
	--passwordbox "Enter Root Password:" 8 50 \
        3>&1 1>&2 2>&3 3>&- \
	)
else 
	clear
	exit 1
fi




if [ ! -z "$ROOTPASSWORD" ]
then

# simple command to put the results of lsblk (just the names of the devices) into an array and make that array populate the options	
let i=0
W=()
while read -r line; do
    let i=$i+1
    W+=($line "")
403
done < <( lsblk -dn -o NAME )
404
SDCARD=$(dialog --title "Manjaro ARM Installer" \
Dan Johansen's avatar
Dan Johansen committed
405
	--menu "Choose your SDCard - Be sure the correct drive is selected!" 20 50 5 \
406 407 408 409 410 411 412 413 414 415
       	"${W[@]}" 3>&2 2>&1 1>&3)

# add /dev/ to the selected option above
SDCARD=/dev/$SDCARD
else 
	clear
	exit 1
fi


416 417 418 419 420 421 422 423 424
if [ ! -z "$SDCARD" ]
then
let i=0
W=()
while read -r line; do
    let i=$i+1
    W+=($line "")
done < <( timedatectl list-timezones )
TIMEZONE=$(dialog --clear --title "Manjaro ARM Installer" \
Dan Johansen's avatar
Dan Johansen committed
425
    --menu "Choose your timezone!" 20 50 15 \
426 427 428 429 430 431
        "${W[@]}" 3>&1 1>&2 2>&3 3>&- \
	)
else 
	clear
	exit 1
fi
432 433


434 435 436 437 438 439 440 441 442
if [ ! -z "$TIMEZONE" ]
then
let i=0
W=()
while read -r line; do
    let i=$i+1
    W+=($line "")
done < <( cat /etc/locale.gen | grep "UTF-8" | tail -n +2 | awk '{print $1}' | sed -e 's/^#*//' )
LOCALE=$(dialog --clear --title "Manjaro ARM Installer" \
Dan Johansen's avatar
Dan Johansen committed
443
	--menu "Choose your locale!" 20 50 15 \
444 445 446 447 448 449 450 451 452
        "${W[@]}" 3>&1 1>&2 2>&3 3>&- \
	)
else 
	clear
	exit 1
fi

if [ ! -z "$LOCALE" ]
then
453 454 455 456 457 458 459
let i=0
W=()
while read -r line; do
    let i=$i+1
    W+=($line "")
done < <( localectl list-keymaps )
KEYMAP=$(dialog --clear --title "Manjaro ARM Installer" \
Dan Johansen's avatar
Dan Johansen committed
460
	--menu "Choose your keyboard layout:" 20 50 15 \
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
        "${W[@]}" 3>&1 1>&2 2>&3 3>&- \
	)
else 
	clear
	exit 1
fi

if [ ! -z "$KEYMAP" ]
then
HOSTNAME=$(dialog --clear --title "Manjaro ARM Installer" \
	--inputbox "Enter desired hostname for this system:" 8 50 \
        3>&1 1>&2 2>&3 3>&- \
	)
else 
	clear
	exit 1
fi

if [ ! -z "$HOSTNAME" ]
then
481 482 483 484 485
dialog --clear --title "Manjaro ARM Installer" \
    --yesno "Is the below information correct:
    Username = $USER
    Password for $USER = $PASSWORD
    Password for root = $ROOTPASSWORD
486
    SD Card = $SDCARD
487
    Timezone = $TIMEZONE
488 489 490
    Locale = $LOCALE
    Keyboard layout = $KEYMAP
    Hostname = $HOSTNAME" 20 50 \
491 492 493 494 495 496 497 498 499 500 501 502 503
    3>&1 1>&2 2>&3 3>&-
else
    clear
    exit 1
fi

response=$?
case $response in
   0) clear; msg "Proceeding....";;
   1) clear; msg "Installation aborted...."; exit 1;;
   255) clear; msg "Installation aborted..."; exit 1;;
esac

504

Dan Johansen's avatar
Dan Johansen committed
505 506 507 508 509 510
if [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "xu4" ]]; then
    ARCH='armv7h'
else
    ARCH='aarch64'
fi

511 512
# get the profiles
getarmprofiles
Dan Johansen's avatar
Dan Johansen committed
513 514

#Package lists
515 516 517
PKG_DEVICE=$(grep "^[^#;]" $TMPDIR/arm-profiles/devices/$DEVICE | awk '{print $1}')
PKG_EDITION=$(grep "^[^#;]" $TMPDIR/arm-profiles/editions/$EDITION | awk '{print $1}')
SRV_EDITION=$(grep "^[^#;]" $TMPDIR/arm-profiles/services/$EDITION | awk '{print $1}')
Dan Johansen's avatar
Dan Johansen committed
518

519

Dan Johansen's avatar
Dan Johansen committed
520
# Commands
521
timer_start=$(get_timer)
Dan Johansen's avatar
Dan Johansen committed
522 523

prepare_card
524 525 526 527
create_install
cleanup
show_elapsed_time "${FUNCNAME}" "${timer_start}"
sync