-
Notifications
You must be signed in to change notification settings - Fork 1
/
rpi-linux
executable file
·80 lines (72 loc) · 2.68 KB
/
rpi-linux
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
#!/bin/bash
# This is a personal script used for upgrading the kernel and udev rules on my pi cams.
export LC_ALL=$(locale -a|grep -ix 'c.utf-\?8' || echo C)
if [[ -f "/etc/opt/board.txt" ]]; then
. /etc/opt/board.txt
else
echo "The board isn't supported."
exit 0
fi
DOWNLOAD="aria2c -c --download-result=hide --console-log-level=error --disable-ipv6=true --summary-interval=0 --show-files=false"
URL="https://github.com/pyavitz/rpi-linux/releases/download/personal/"
UDEV_RULES="https://raw.githubusercontent.com/pyavitz/rpi-img-builder/master/files/misc"
if [[ `command -v aria2c` ]]; then :; else sudo apt install aria2 -y; fi
if [[ `command -v wget` ]]; then :; else sudo apt install wget -y; fi
# Optional
INSTALL_RULES="false"
# Install new udev rules
if [[ "$INSTALL_RULES" == "true" ]]; then
sudo mkdir -p /etc/udev/rules.d/
sudo mkdir -p /lib/udev/rules.d/
if [[ -f "/lib/udev/rules.d/99-com.rules" ]]; then
sudo rm -f /lib/udev/rules.d/99-com.rules
fi
if [[ -f "/etc/udev/rules.d/10-vchiq-permissions.rules" ]]; then
sudo rm -f /etc/udev/rules.d/10-vchiq-permissions.rules
fi
if [[ -f "/etc/udev/rules.d/99-com.rules" ]]; then
sudo rm -f /etc/udev/rules.d/99-com.rules
sudo wget -cq --show-progress $UDEV_RULES/99-com.rules -P /etc/udev/rules.d/
else
sudo wget -cq --show-progress $UDEV_RULES/99-com.rules -P /etc/udev/rules.d/
fi
if [[ -f "/lib/udev/rules.d/10-local-rpi.rules" ]]; then
sudo rm -f /lib/udev/rules.d/10-local-rpi.rules
sudo wget -cq --show-progress $UDEV_RULES/10-local-rpi.rules -P /lib/udev/rules.d/
else
sudo wget -cq --show-progress $UDEV_RULES/10-local-rpi.rules -P /lib/udev/rules.d/
fi
if [[ -f "/lib/udev/rules.d/60-rpi.gpio-common.rules" ]]; then
sudo rm -f /lib/udev/rules.d/60-rpi.gpio-common.rules
sudo wget -cq --show-progress $UDEV_RULES/60-rpi.gpio-common.rules -P /lib/udev/rules.d/
else
sudo wget -cq --show-progress $UDEV_RULES/60-rpi.gpio-common.rules -P /lib/udev/rules.d/
fi
fi
RELEASE=`echo $1`
LINUX_IMAGE="linux-image-${SERIES}"
# Install new kernel
if [[ -d "${HOME}/.deb" ]]; then
if [[ -f "${HOME}/.deb/${LINUX_IMAGE}_${RELEASE}_${ARCH_EXT}.deb" ]]; then
echo ""
echo "File already exists?"
exit 0
fi
fi
mkdir -p ${HOME}/.deb
cd ${HOME}/.deb/
if [[ `wget -S --spider ${URL}${LINUX_IMAGE}_${RELEASE}_${ARCH_EXT}.deb 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
echo ""
echo -e "Downloading ${LINUX_IMAGE}_${RELEASE}_${ARCH_EXT}.deb ..."
${DOWNLOAD} ${URL}${LINUX_IMAGE}_${RELEASE}_${ARCH_EXT}.deb
echo ""; echo ""
echo -e "Installing ${LINUX_IMAGE}_${RELEASE}_${ARCH_EXT}.deb ..."
sudo dpkg -i ${LINUX_IMAGE}_${RELEASE}_${ARCH_EXT}.deb
cd ~
echo -e "Done."
else
cd ~
echo -e "HELP? Example: rpi-linux 6.1.55-1"
exit 0
fi
exit 0