This repository was archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcreate_image
More file actions
executable file
·108 lines (84 loc) · 3.31 KB
/
Copy pathcreate_image
File metadata and controls
executable file
·108 lines (84 loc) · 3.31 KB
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
#!/usr/bin/env bash
# Creates a turtlebot3 image suitable for MSR
# Get the location of this script
script=$(readlink -f "$0")
script_dir=$(dirname "$script")
# ---- Setup Script Parameters ----
# Build Directory
# Create the build directory (as optionally specified by the first argument)
if [ -z "$1" ]
then
build_dir=build/turtlebot_image
else
build_dir="$1"
fi
mkdir -p $build_dir
cd $build_dir
# The image file name
image=turtle.img
# The directory containing the root file system for the raspberry pi
rootfs=raspi_root
if [ -f "$image" ]
then
echo "Raspberry Pi Ubuntu Already Present at $image. Skipping download (delete it to re-download)";
else
echo "Downloading the raspberry pi ubuntu image"
curl -L "https://cdimage.ubuntu.com/releases/20.04.3/release/ubuntu-20.04.3-preinstalled-server-armhf+raspi.img.xz" | unxz > $image
fi
echo "Preparing the disk image"
# Expand the size of the image file
truncate -s 8GB $image
# Expand the second partion within the image file
parted $image resizepart 2 100%
echo "Mounting the image"
# mount the image on loop device
loop_dev=$(sudo losetup --show -Pf $image)
# Resize the filesystem to fit the expanded partion:
sudo e2fsck -y -f ${loop_dev}p2
sudo resize2fs ${loop_dev}p2
echo "Mounting the disk image"
mkdir -p $rootfs
sudo mount ${loop_dev}p2 $rootfs
sudo mount ${loop_dev}p1 $rootfs/boot/firmware
echo "Basic ROS setup"
sudo cp ${script_dir}/create_scripts/setup_ros $rootfs
sudo chmod 755 $rootfs/setup_ros
sudo proot -q qemu-arm-static -S $rootfs /setup_ros
sudo rm $rootfs/setup_ros
echo "Turtlebot3 Setup"
sudo cp ${script_dir}/create_scripts/setup_turtle $rootfs
sudo chmod 755 $rootfs/setup_turtle
sudo proot -q qemu-arm-static -S $rootfs /setup_turtle
sudo rm $rootfs/setup_turtle
echo "MSR specific setup"
sudo cp ${script_dir}/create_scripts/setup_msr $rootfs
sudo chmod 755 $rootfs/setup_msr
sudo proot -q qemu-arm-static -S $rootfs /setup_msr
sudo rm $rootfs/setup_msr
echo "Installing robotdns scripts"
curl -L "https://raw.githubusercontent.com/m-elwin/robotdns/main/21-robotdns-register.sh" | sudo tee $rootfs/etc/NetworkManager/dispatcher.d/21-robotdns-register.sh
sudo chmod 500 $rootfs/etc/NetworkManager/dispatcher.d/21-robotdns-register.sh
echo "Building the firmware. When booted, you can install the firmware with 'opencr_update stock' OR 'opencr_update raw'"
${script_dir}/build_firmware opencr_firmware
# copy the firmware files to the image
sudo mkdir $rootfs/usr/share/opencr
sudo cp opencr_firmware/burger.opencr $rootfs/usr/share/opencr
sudo cp opencr_firmware/raw-burger.opencr $rootfs/usr/share/opencr
sudo cp opencr_firmware/opencr_ld_shell $rootfs/usr/bin
sudo cp opencr_firmware/opencr_update $rootfs/usr/bin
echo "Nuturtlebot Installation Ubuntu"
sudo cp ${script_dir}/create_scripts/setup_nuturtlebot $rootfs
sudo chmod 755 $rootfs/setup_nuturtlebot
sudo proot -q qemu-arm-static -S $rootfs /setup_nuturtlebot
sudo rm $rootfs/setup_nuturtlebot
echo "Cleanup Ubuntu"
sudo cp ${script_dir}/create_scripts/cleanup_ubuntu $rootfs
sudo chmod 755 $rootfs/cleanup_ubuntu
sudo proot -q qemu-arm-static -S $rootfs /cleanup_ubuntu
sudo rm $rootfs/cleanup_ubuntu
echo "Copying the final static configuration"
# Copy over the configuration
sudo cp -ra ${script_dir}/config_root/* $rootfs
sudo umount $rootfs/boot/firmware
sudo umount $rootfs
sudo losetup -d $loop_dev