Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (93 loc) · 2.88 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·103 lines (93 loc) · 2.88 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
#!/bin/bash
SERVICE_NAME="hyperpixel4-init.service"
SERVICE_PATH="/etc/systemd/system"
BINARY_NAME="hyperpixel4-init"
ROTATE_NAME="hyperpixel4-rotate"
BINARY_PATH="/usr/bin"
OVERLAY_PATH="/boot/overlays"
OVERLAY_NAME="hyperpixel4.dtbo"
OVERLAY_SRC="hyperpixel4.dts"
CONFIG="/boot/config.txt"
CONFIG_LINES=(
"dtoverlay=hyperpixel4"
"overscan_left=0"
"overscan_right=0"
"overscan_top=0"
"overscan_bottom=0"
"enable_dpi_lcd=1"
"display_default_lcd=1"
"display_rotate=0"
"dpi_group=2"
"dpi_mode=87"
"dpi_output_format=0x7f216"
"hdmi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6"
)
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo ./install.sh'\n"
exit 1
fi
if [ ! -f "dist/$OVERLAY_NAME" ]; then
if [ ! -f "/usr/bin/dtc" ]; then
printf "This script requires device-tree-compiler, please \"sudo apt install device-tree-compiler\"\n";
exit 1
fi
printf "Notice: building $OVERLAY_NAME\n";
dtc -I dts -O dtb -o dist/$OVERLAY_NAME src/$OVERLAY_SRC > /dev/null 2>&1
fi
if [ -d "$SERVICE_PATH" ]; then
cp dist/$BINARY_NAME $BINARY_PATH
cp dist/$SERVICE_NAME $SERVICE_PATH
systemctl daemon-reload
systemctl enable $SERVICE_NAME
systemctl start $SERVICE_NAME
printf "Installed: $BINARY_PATH/$BINARY_NAME\n"
printf "Installed: $SERVICE_PATH/$SERVICE_NAME\n"
else
printf "Warning: cannot find $SERVICE_PATH for $SERVICE_NAME\n"
fi
if [ -d "$BINARY_PATH" ]; then
cp dist/$ROTATE_NAME $BINARY_PATH
printf "Installed: $BINARY_PATH/$ROTATE_NAME\n"
fi
if [ -d "$OVERLAY_PATH" ]; then
cp dist/$OVERLAY_NAME $OVERLAY_PATH
printf "Installed: $OVERLAY_PATH/$OVERLAY_NAME\n"
else
printf "Warning: unable to copy $OVERLAY_NAME to $OVERLAY_PATH\n"
fi
if [ -f "$CONFIG" ]; then
NEWLINE=0
for ((i = 0; i < ${#CONFIG_LINES[@]}; i++)); do
CONFIG_LINE="${CONFIG_LINES[$i]}"
grep -e "^#$CONFIG_LINE" $CONFIG > /dev/null
STATUS=$?
if [ $STATUS -eq 1 ]; then
grep -e "^$CONFIG_LINE" $CONFIG > /dev/null
STATUS=$?
if [ $STATUS -eq 1 ]; then
# Line is missing from config file
if [ ! $NEWLINE -eq 1 ]; then
# Add newline if this is the first new entry
echo "" >> $CONFIG
NEWLINE=1
fi
# Add the config line
echo "$CONFIG_LINE" >> $CONFIG
printf "Config: Added $CONFIG_LINE to $CONFIG\n"
else
printf "Skipped: $CONFIG_LINE already exists in $CONFIG\n"
fi
else
sed $CONFIG -i -e "s/^#$CONFIG_LINE/$CONFIG_LINE/"
printf "Config: Uncommented $CONFIG_LINE in $CONFIG\n"
fi
done
else
printf "Warning: unable to find $CONFIG, is /boot not mounted?\n"
printf "Please add $OVERLAY_CONFIG to your config.txt\n"
fi
printf "\nBefore rebooting, use 'hyperpixel4-rotate left/right/normal/inverted' to rotate your display!\n\n"
printf " left - Landscape, power/HDMI on bottom\n"
printf " right - Landscape, power/HDMI on top\n"
printf " normal - Portrait, USB ports on top\n"
printf " inverted - Portrait, USB ports on bottom\n\n"