Skip to content

Commit 3b76e9b

Browse files
committed
Added standalone-rpi-imager.sh script
1 parent 4d262fa commit 3b76e9b

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# This script can be used to set up a standalone installation of
6+
# Raspberry Pi Imager (rpi-imager) in a specific directory
7+
8+
# Tested on Debian 13 (trixie)
9+
10+
# To run this script without downloading it:
11+
# bash <(curl -fsSL https://raw.githubusercontent.com/dmotte/misc/main/scripts/provisioning/standalone-rpi-imager.sh) -lauto
12+
13+
options=$(getopt -o +c:d:l: -l checksum: -l install-dir: -l launcher: -- "$@")
14+
eval "set -- $options"
15+
16+
checksum=''
17+
install_dir="$HOME/apps/rpi-imager"
18+
launcher=''
19+
20+
while :; do
21+
case $1 in
22+
-c|--checksum) shift; checksum=$1;;
23+
-d|--install-dir) shift; install_dir=$1;;
24+
-l|--launcher) shift; launcher=$1;;
25+
--) shift; break;;
26+
esac
27+
shift
28+
done
29+
30+
readonly version=${1:-latest}
31+
32+
[ "$launcher" != auto ] ||
33+
launcher=~/.local/share/applications/rpi-imager.desktop
34+
35+
################################################################################
36+
37+
if [ -d "$install_dir" ]; then
38+
echo "Directory $install_dir already exists" >&2; exit 1
39+
fi
40+
41+
mkdir -pv "$install_dir"
42+
43+
readonly imager_url="https://downloads.raspberrypi.com/imager/imager_${version}_amd64.AppImage"
44+
readonly imager_path=$install_dir/imager.AppImage
45+
46+
echo "Downloading $imager_url to $imager_path"
47+
curl -fLo "$imager_path" "$imager_url"
48+
49+
if [ -n "$checksum" ]; then
50+
echo "$checksum $imager_path" | sha256sum -c
51+
fi
52+
53+
if [ -n "$launcher" ]; then
54+
echo "Creating launcher file $launcher"
55+
7z e "$imager_path" usr/share/icons/hicolor/scalable/apps/rpi-imager.svg -so \
56+
> "$install_dir/icon.svg"
57+
echo 5ef45ade3239f9710ee3f4d5e0c65d03b40621898f2ff35ecfdf6025b223a753 \
58+
"$install_dir/icon.svg" | sha256sum -c
59+
60+
install -Tm644 /dev/stdin "$launcher" << EOF
61+
[Desktop Entry]
62+
Type=Application
63+
Name=Raspberry Pi Imager
64+
Icon=$install_dir/icon.svg
65+
Exec=$imager_path %F
66+
Terminal=false
67+
EOF
68+
fi

0 commit comments

Comments
 (0)