-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRaspberry-Pi3-installation-script
142 lines (123 loc) · 4.59 KB
/
Raspberry-Pi3-installation-script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# This script can be run by executing the following:
# curl -sL https://git.io/JfLYQ | bash
# and should be run as user
set -uo pipefail
trap 's=$?; printf "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
block=$(dialog --stdout --inputbox "Wo soll Arch installiert werden (ohne Pfad)?" 0 0) || exit 1
clear
: ${block:?"You have to answer!"}
modell=$(dialog --stdout --inputbox "Welches Raspberry Pi Modell (nur Nummer)?" 0 0) || exit 1
clear
: ${modell:?"You have to answer!"}
version=$(dialog --stdout --inputbox "Soll Raspberry Pi latest (anworte: normal) oder Aarch64 (antworte: aarch64) installiert werden)?" 0 0) || exit 1
clear
: ${version:?"You have to answer!"}
if [ $modell = "zero" ];
then
wlan=$(dialog --stdout --inputbox "Soll WLAN eingerichtet werden?" 0 0) || exit 1
clear
: ${wlan:?"You have to answer with yes or no."}
if [ $wlan = "yes" ] || [ $wlan = "ja" ];
then
ssid=$(dialog --stdout --inputbox "Wie lautet die SSID?" 0 0) || exit 1
clear
: ${ssid:?"You have to answer with yes or no."}
passwort=$(dialog --stdout --inputbox "Wie lautet das Passwort?" 0 0) || exit 1
clear
: ${passwort:?"You have to answer with yes or no."}
fi
fi
pfad="/dev/$block"
if [[ "$block" = sd* ]]; then
pfad1="${pfad}1"
pfad2="${pfad}2"
else
pfad1="${pfad}p1"
pfad2="${pfad}p2"
fi
mountroot="/mnt/arch/root"
mountboot="/mnt/arch/boot"
sudo parted $pfad --script -- mklabel msdos
sudo parted $pfad --script -- mkpart primary fat32 1 512
sudo parted $pfad --script -- mkpart primary ext4 512 100%
sudo parted $pfad --script -- set 1 boot on
sudo parted $pfad --script print
sudo mkfs.vfat -F32 $pfad1
sudo mkfs.ext4 -F $pfad2
sudo mkdir -p /mnt/arch/{boot,root}
if mount | grep $mountboot > /dev/null; then
mountedboot=$(dialog --stdout --inputbox "${mountboot} ist eingehängt, soll es ausgehängt werden?" 0 0) || exit 1
clear
: ${mountedboot:?"You have to answer!"}
if [ $mountedboot = "yes" ] || [ $mountedboot = "ja" ];
then
umount $mountboot
fi
fi
if mount | grep $mountroot > /dev/null; then
mountedboot=$(dialog --stdout --inputbox "${mountroot} ist eingehängt, soll es ausgehängt werden?" 0 0) || exit 1
clear
: ${mountedroot:?"You have to answer!"}
if [ $mountedroot = "yes" ] || [ $mountedroot = "ja" ];
then
umount $mountroot
fi
fi
sudo mount $pfad1 $mountboot
sudo mount $pfad2 $mountroot
if [ $modell = "zero" ];
then
if [ "$version" = normal ];
then
FILE=ArchLinuxARM-rpi-latest.tar.gz
if ! test -f "$FILE"; then
sudo wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
fi
pv ArchLinuxARM-rpi-latest.tar.gz | sudo tar -C $mountroot -xz
fi
#### WLAN einrichten
if [ "$wlan" = "yes" ] || [ "$wlan" = "ja" ];
then
printf "[Match]\nName=wlan0\n\n[Network]\nDHCP=yes" > $mountroot/etc/systemd/network/wlan0.network
printf "country=AT\nctrl_interface=DIR=/run/wpa_supplicant\nctrl_interface_group=wheel\nupdate_config=1" > $mountroot/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
wpa_passphrase "${ssid}" "${passwort}" > $mountroot/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ln -s /usr/lib/systemd/system/[email protected] $mountroot/etc/systemd/system/multi-user.target.wants/[email protected]
fi
fi
if [ "$modell" = 2 ] || [ "$modell" = 3 ];
then
if [ "$version" = normal ];
then
FILE=ArchLinuxARM-rpi-armv7-latest.tar.gz
if ! test -f "$FILE"; then
sudo wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
fi
pv ArchLinuxARM-rpi-armv7-latest.tar.gz | sudo tar -C $mountroot -xz
fi
fi
if [ "$modell" = 4 ];
then
if [ "$version" = normal ];
then
FILE=ArchLinuxARM-rpi-4-latest.tar.gz
if ! test -f "$FILE"; then
sudo wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz
fi
pv ArchLinuxARM-rpi-4-latest.tar.gz | sudo tar -C $mountroot -xz
fi
fi
if [ "$version" = "aarch64" ];
then
FILE=ArchLinuxARM-rpi-aarch64-latest.tar.gz
if ! test -f "$FILE"; then
sudo wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz
fi
pv ArchLinuxARM-rpi-aarch64-latest.tar.gz | sudo tar -C $mountroot -xz
sudo sed -i 's/mmcblk0/mmcblk1/g' $mountroot/etc/fstab
fi
sudo mv /mnt/arch/root/boot/* /mnt/arch/boot
sync
sudo umount /mnt/arch/boot /mnt/arch/root
sudo rm -r /mnt/arch
printf "\n#################\n### Ready :) ###\n#################\n"