-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·95 lines (71 loc) · 2.7 KB
/
install.sh
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
#!/bin/bash
DEBIAN_DL_LINK="https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-12-06/2023-12-05-raspios-bullseye-armhf-lite.img.xz"
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
./conf.sh
echo "Downloading debian image..."
wget -nv --show-progress -O - $DEBIAN_DL_LINK | unxz > debian.img
LOOP_DEVICE=$(losetup -fP --show debian.img)
mkdir boot
mount "${LOOP_DEVICE}p1" ./boot
sync
umount ./boot
rmdir ./boot
mkdir image
mount "${LOOP_DEVICE}p2" ./image
mkdir ./image/kiosksetup
cp -r ./files/* ./image/kiosksetup
chown -R root ./image/kiosksetup
mv ./kiosk.sh ./image/kiosksetup
chmod +x ./image/kiosksetup/kiosk.sh
cp ./kiosk.service ./image/etc/systemd/system
rm ./image/etc/apt/sources.list
cp ./files/sources.list ./image/etc/apt
mv ./25-wlan.network ./image/etc/systemd/network
rm -f ./image/etc/resolv.conf
mv ./resolv.conf ./image/etc
mv ./image/etc/network/interfaces ./image/etc/network/interfaces.save
mv ./image/etc/network/interfaces.d ./image/etc/network/interfaces.d.save
rm -f ./image/etc/systemd/system/network-online.target.wants/*
rm -f ./image/etc/systemd/system/multi-user.target.wants/*
ln -s ./image/usr/lib/systemd/system/systemd-networkd.service ./image/etc/systemd/system/network-online.target.wants
ln -s ./image/usr/lib/systemd/system/systemd-networkd.service ./image/etc/systemd/system/multi-user.target.wants
mv ./wpa_supplicant-wlan0.conf ./image/etc/wpa_supplicant
ln -s ./image/lib/systemd/system/[email protected] ./image/etc/systemd/system/multi-user.target.wants/[email protected]
cp ./files/firstboot.service ./image/etc/systemd/system
ln -s ./image/etc/systemd/system/firstboot.service ./image/etc/systemd/system/multi-user.target.wants/firstboot.service
mv ./firstboot.sh ./image/kiosksetup
chmod +x ./image/kiosksetup/firstboot.sh
sync
umount ./image
rmdir ./image
losetup -d "$LOOP_DEVICE"
printf "\n\n"
echo "Available hard drives:"
printf "\n"
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
printf "\n"
echo "Enter the name of the hard drive to flash the image to."
echo "Enter it in the form of \"sdXX\" or \"mmcblkXX\" etc.."
printf "\n"
read -p ":" selected_drive
if [ -z "$selected_drive" ]; then
echo "Invalid input. Exiting script."
exit
fi
echo "You have chosen to flash to '/dev/$selected_drive'."
echo "You can also cancel and write the image to disk yourself."
read -p "Do you want to proceed? (y/n): " confirm
printf "\n"
if [ "$confirm" != "y" ]; then
echo "Operation canceled. Exiting."
exit 1
fi
echo "Flashing the image. Please wait..."
dd if="./debian.img" of="/dev/$selected_drive" bs=4M status=progress
sync
eject /dev/$selected_drive
rm ./debian.img
echo "You can now remove the SD-Card"