-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·146 lines (111 loc) · 3.19 KB
/
install.sh
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Used by read_write_config_json.sh
CONFIG_JSON_FILEPATH=$BASEDIR/config.json
# Make sure others can't modify the scripts
chmod o-w $BASEDIR/scripts/*
source $BASEDIR/scripts/ensure_sudo.sh
source $BASEDIR/scripts/read_write_config_json.sh
source $BASEDIR/scripts/user_yes_no.sh
source $BASEDIR/scripts/write_boot_config.sh
source $BASEDIR/scripts/systemd_services.sh
computer_type=$(tr -d '\0' < /sys/firmware/devicetree/base/model)
restart=false
needs_service=false
#
# Power LED
#
disable_power_led()
{
write_config_json disable_power_led true
write_boot_config "" true dtparam pwr_led_trigger none
write_boot_config "" true dtparam pwr_led_activelow off
restart=true
}
# Raspberry Pi Zero does not have a Power LED
if [[ $computer_type != *"Zero"* ]]; then
user_yes_no "Do you want to disable the Power LED?" disable_power_led
fi
#
# Activity LED
#
disable_activity_led()
{
write_config_json disable_activity_led true
write_boot_config "" true dtparam act_led_trigger none
# Config is different for Raspberry Pi Zero
if [[ $computer_type == *"Zero"* ]]; then
write_boot_config "" true dtparam act_led_activelow on
else
write_boot_config "" true dtparam act_led_activelow off
fi
restart=true
}
user_yes_no "Do you want to disable the Activity LED?" disable_activity_led
#
# Ethernet LEDs
#
# https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README
ethernet_off=0
model=$(tr -d '\0' < /proc/device-tree/model)
if [[ $model == *"3 Model B Plus"* ]]; then
ethernet_off=14
elif [[ $model == *"4 Model B"* ]]; then
ethernet_off=4
fi
if [ $ethernet_off -ne 0 ]; then
disable_ethernet_leds()
{
write_config_json disable_ethernet_leds true
write_boot_config "" true dtparam eth_led0 $ethernet_off
write_boot_config "" true dtparam eth_led1 $ethernet_off
restart=true
}
user_yes_no "Do you want to disable the Ethernet LEDs?" disable_ethernet_leds
fi
#
# Bluetooth
#
disable_bluetooth()
{
write_config_json disable_bluetooth true
write_boot_config "" false dtoverlay disable-bt
stop_service hciuart.service
stop_service bluealsa.service
stop_service bluetooth.service
restart=true
}
user_yes_no "Do you want to disable Bluetooth?" disable_bluetooth
#
# Wifi
#
disable_wifi()
{
write_config_json disable_wifi true
write_boot_config "" false dtoverlay disable-wifi
restart=true
}
user_yes_no "Do you want to disable Wifi?" disable_wifi
#
# HDMI
#
disable_hdmi()
{
write_config_json disable_hdmi true
# Make sure the new KMS driver is deactivated, otherwise HDMI can't be disabled by tvservice
write_boot_config "#" false dtoverlay vc4-kms-v3d
needs_service=true
restart=true
}
user_yes_no "Do you want to disable HDMI?" disable_hdmi
if [ "$needs_service" = true ]; then
setup_service $BASEDIR/services/save_energy.service $BASEDIR
start_service save_energy.service
fi
if [ "$restart" = true ]; then
reboot()
{
sudo reboot now
}
user_yes_no "You need to reboot for all changes to take effect. Do you want to REBOOT now?" reboot
fi