-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathmake_custom_pi_os
executable file
·71 lines (59 loc) · 2.25 KB
/
make_custom_pi_os
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
#!/usr/bin/env bash
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$DIR/argparse.bash" || exit 1
argparse "$@" <<EOF || exit 1
parser.add_argument('dest', help="The destination folder")
parser.add_argument('-g', '--get_image', action='store_true',
help='Pick a number [default %(default)s]')
parser.add_argument('-v', '--variant', action='store',
choices=['raspios_lite_armhf', 'raspios_lite_arm64', 'raspios_armhf', 'raspios_arm64', 'raspios_full_armhf', 'raspios_full_arm64'],
default='raspios_lite_armhf',
help='Which variant to use [default: %(default)s]')
EOF
case $DEST in
*"-"*)
echo "Error, destination folder cannot contain a dash"
exit 1
;;
*" "*)
echo "Error, destination folder cannot contain a space"
exit 1
;;
*)
;;
esac
echo Settings:
echo "making dstro in ${DEST}"
echo "variant: ${VARIANT}"
for a in "${MULTIPLE[@]}"; do
echo " $a"
done
if [ -d "${DEST}" ]; then
echo "Error, folder already exists: ${DEST}"
exit 1
fi
if [ -f "${DEST}" ]; then
echo "Error, file already exists: ${DEST}"
exit 1
fi
cp -a "${DIR}/dist_generators/dist_example" "${DEST}"
chown -R "${USER}":"$(id -gn "${USER}")" "${DEST}"
"${DIR}/dist_generators/dist_example_script" "${DEST}"
"$DIR/update-custompios-paths" "${DEST}/src"
if [ "$GET_IMAGE" ]; then
echo -n "Downloading latest Raspbian image"
CURRENT_RASPBIAN=$(curl -s "https://downloads.raspberrypi.org/${VARIANT}/images/" | grep raspios | tail -n 1 | awk -F "href=\"" '{print $2}' | awk -F "/" '{print $1}')
if [ $? -ne 0 ]; then
echo -e "\nerror getting date"
exit 1
fi
CURRENT_RASPBIAN_FILE="$(curl -s "http://downloads.raspberrypi.org/${VARIANT}/images/${CURRENT_RASPBIAN}"/ | grep .xz | head -n 1 | awk -F "href=\"" '{print $2}' | awk -F "\">" '{print $1}')"
if [ $? -ne 0 ]; then
echo -e "\nerror getting file name"
exit 1
fi
CURRENT_RASPBIAN_URL="https://downloads.raspberrypi.org/${VARIANT}/images/${CURRENT_RASPBIAN}/${CURRENT_RASPBIAN_FILE}"
echo " from ${CURRENT_RASPBIAN_URL}"
curl -L -o "${DEST}/src/image/${CURRENT_RASPBIAN_FILE}" "${CURRENT_RASPBIAN_URL}"
fi