rev |
line source |
pankso@44
|
1 #!/bin/sh
|
pankso@44
|
2 #
|
pankso@44
|
3 # TazBerry - SliTaz Raspberry Pi Config Tool
|
pankso@44
|
4 #
|
pankso@44
|
5 # Copyright (C) 2014 SliTaz ARM - BSD License
|
pankso@44
|
6 # Author: Christophe Lincoln <pankso@slitaz.org>
|
pankso@44
|
7 #
|
pankso@44
|
8 . /lib/libtaz.sh
|
pankso@137
|
9 check_root
|
pankso@44
|
10
|
pankso@44
|
11 title="{ TazBerry }"
|
pankso@44
|
12 config="/boot/config.txt"
|
pankso@44
|
13 tmpdir="/tmp/tazberry"
|
pankso@44
|
14 tmp="$tmpdir/$$"
|
pankso@44
|
15 height="20"
|
pankso@44
|
16 width="72"
|
pankso@44
|
17
|
pankso@147
|
18 # Mirror URL
|
pankso@147
|
19 rpi_mirror="http://mirror.slitaz.org/arm/rpi/"
|
pankso@147
|
20
|
pankso@44
|
21 # Use a tmp directory
|
pankso@44
|
22 mkdir -p ${tmpdir}
|
pankso@44
|
23
|
pankso@44
|
24 # Small built-in help
|
pankso@44
|
25 help() {
|
pankso@44
|
26 cat << EOT
|
pankso@44
|
27
|
pankso@44
|
28 $(boldify "$(gettext 'Usage:')") $(basename $0) [command|rpi_function]
|
pankso@44
|
29
|
pankso@44
|
30 $(boldify "$(gettext 'Commands:')")
|
pankso@122
|
31 oclock $(gettext 'Configure overclocking')
|
pankso@156
|
32 linux-up $(gettext 'Update SliTaz R-Pi Linux kernel')
|
pankso@134
|
33 cam-setup $(gettext 'Configure your Pi to use the Camera')
|
pankso@44
|
34 ls-functions $(gettext 'List TazBerry functions')
|
pankso@105
|
35 rpi_ $(gettext 'Execute any tazberry_function')
|
pankso@44
|
36 testsuite $(gettext 'Run TazBerry testsuite')
|
pankso@44
|
37
|
pankso@44
|
38 EOT
|
pankso@44
|
39 }
|
pankso@44
|
40
|
pankso@44
|
41 #
|
pankso@44
|
42 # RPi functions
|
pankso@44
|
43 #
|
pankso@44
|
44
|
paul@65
|
45 # This could move to /usr/bin/slitaz-??? or something since it's not
|
pankso@58
|
46 # ARM specific
|
pankso@44
|
47 rpi_stats() {
|
pankso@58
|
48 ip=$(ifconfig | fgrep -A 1 "encap:Ethernet" | fgrep "inet" | cut -d ":" -f 2)
|
pankso@58
|
49 mem_total=$(free -m | fgrep "Mem:" | awk '{print $2}')
|
pankso@58
|
50 mem_used=$(free -m | fgrep "Mem:" | awk '{print $3}')
|
pankso@58
|
51 mem_used_pct=$(( ( ${mem_used} * 100) / ${mem_total} ))
|
pankso@44
|
52 cat << EOT
|
pankso@67
|
53 $(gettext 'Kernel') : $(uname -snrm)
|
pankso@67
|
54 $(gettext 'Uptime') : $(uptime | awk '{print $3}' | sed s"/:/h /" | sed s"/,/min/")
|
pankso@67
|
55 $(gettext 'Network IP') : $(echo $ip | awk '{print $1}')
|
pankso@67
|
56 $(gettext 'CPU heat') : $(awk '{printf "%3.1f C\n", $1/1000}' /sys/class/thermal/thermal_zone0/temp)
|
pankso@67
|
57 $(gettext 'Processes') : $(ps | wc -l)
|
pankso@67
|
58 $(gettext 'Memory usage') : ${mem_used_pct}%
|
pankso@44
|
59 EOT
|
pankso@44
|
60 }
|
pankso@44
|
61
|
pankso@44
|
62 rpi_turbo() {
|
pankso@44
|
63 if ! fgrep -q 'force_turbo=1' ${config}; then
|
pankso@44
|
64 gettext "Enabling Raspberry Pi force turbo..."
|
pankso@44
|
65 echo "force_turbo=1" >> ${config}; status
|
pankso@44
|
66 else
|
pankso@44
|
67 gettext "Disabling Raspberry Pi force turbo..."
|
pankso@44
|
68 sed -i '/force_turbo=1/'d ${config}; status
|
pankso@44
|
69 fi
|
pankso@44
|
70 }
|
pankso@44
|
71
|
pankso@44
|
72 # RPi Overclocking
|
pankso@44
|
73 rpi_oclock() {
|
pankso@44
|
74 cat << EOT
|
pankso@44
|
75 none 700MHz ARM 250MHz core 400MHz SDRAM 0 overvolt
|
pankso@44
|
76 modest 800MHz ARM 300MHz core 400MHz SDRAM 0 overvolt
|
pankso@44
|
77 medium 900MHz ARM 333MHz core 450MHz SDRAM 2 overvolt
|
pankso@44
|
78 high 950MHz ARM 450MHz core 450MHz SDRAM 6 overvolt
|
pankso@44
|
79 turbo 1000MHz ARM 500MHz core 500MHz SDRAM 6 overvolt
|
pankso@44
|
80 EOT
|
pankso@44
|
81 }
|
pankso@44
|
82
|
pankso@147
|
83 # Update custom Raspberry Pi Kernel
|
pankso@154
|
84 linux_update() {
|
pankso@147
|
85 cache="/var/cache/tazpkg"
|
pankso@152
|
86 current="/var/lib/tazpkg/installed/linux"
|
pankso@154
|
87 {
|
pankso@154
|
88 echo "XXX" && echo 20
|
pankso@154
|
89 echo -e "\n$(gettext 'Raspberry Pi kernel update')"
|
pankso@154
|
90 echo "XXX" && sleep 1
|
pankso@154
|
91 mkdir -p ${cache}
|
pankso@154
|
92 rm -f ${cache}/linux-version.txt
|
pankso@147
|
93
|
pankso@154
|
94 # Last version
|
pankso@154
|
95 echo "XXX" && echo 40
|
pankso@154
|
96 echo -e "\n$(gettext 'Fetching latest Kernel version string...')"
|
pankso@154
|
97 echo "XXX" && sleep 1
|
pankso@154
|
98 if busybox wget -q -s ${rpi_mirror}/packages/last-linux.txt; then
|
pankso@154
|
99 wget -q ${rpi_mirror}/packages/last-linux.txt \
|
pankso@154
|
100 -O ${cache}/linux-version.txt || exit 1
|
pankso@154
|
101 else
|
pankso@154
|
102 echo "XXX" && echo 100
|
pankso@154
|
103 echo -e "\n$(gettext 'Mirror is unreachable')"
|
pankso@154
|
104 echo "XXX" && sleep 1
|
pankso@154
|
105 exit 1
|
pankso@154
|
106 fi
|
pankso@154
|
107 kvers=$(cat $cache/linux-version.txt)
|
pankso@157
|
108 pkg="linux-${kvers}-arm.tazpkg"
|
pankso@154
|
109
|
pankso@154
|
110 echo "XXX" && echo 50
|
pankso@154
|
111 echo -e "\n$(gettext 'Last Kernel version:') $kvers"
|
pankso@154
|
112 echo "XXX" && sleep 2
|
pankso@154
|
113 rm -rf ${cache}/linux-${kvers}*
|
pankso@154
|
114
|
pankso@154
|
115 # Download
|
pankso@154
|
116 echo "XXX" && echo 60
|
pankso@154
|
117 echo -e "\n$(gettext 'Fetching latest Linux package...')"
|
pankso@154
|
118 echo "XXX"
|
pankso@157
|
119 wget -q ${rpi_mirror}/packages/${pkg} -O ${cache}/${pkg} || exit 1
|
pankso@154
|
120
|
pankso@154
|
121 # Install
|
pankso@154
|
122 echo "XXX" && echo 80
|
pankso@157
|
123 echo -e "\n$(gettext 'Installing:') ${pkg}"
|
pankso@154
|
124 echo "XXX"
|
pankso@154
|
125 cd ${cache}
|
pankso@157
|
126 spk-add ${pkg} --forced >/dev/null 2>&1 || exit 1
|
pankso@154
|
127
|
pankso@154
|
128 echo "XXX" && echo 100
|
pankso@156
|
129 echo -e "\n$(gettext 'Cleaning installing files...')"
|
pankso@154
|
130 echo "XXX" && sleep 2
|
pankso@154
|
131 rm -f ${cache}/linux-version.txt
|
pankso@154
|
132
|
pankso@154
|
133 } | dialog --title "{ Kernel Update }" \
|
pankso@154
|
134 --gauge "" 8 ${width} 0
|
pankso@154
|
135 # Reboot ?
|
pankso@156
|
136 reboot_box \
|
pankso@154
|
137 "$(gettext 'You must reboot to use your new Linux Kernel.')"
|
pankso@147
|
138 }
|
pankso@147
|
139
|
pankso@122
|
140 # Unset overclocking
|
pankso@122
|
141 unset_oclock() {
|
pankso@122
|
142 debug "unset_oclock"
|
pankso@122
|
143 sed -i \
|
pankso@122
|
144 -e '/# Overclocking.*/'d \
|
pankso@122
|
145 -e '/arm_freq=/'d \
|
pankso@122
|
146 -e '/core_freq=/'d \
|
pankso@122
|
147 -e '/sdram_freq=/'d \
|
pankso@122
|
148 -e '/over_voltage=/'d ${config}
|
pankso@122
|
149 # Remove if 3 empty lines follows
|
pankso@122
|
150 sed -i '1N;N;/^\n\n$/d;P;D' ${config}
|
pankso@122
|
151 }
|
pankso@122
|
152
|
pankso@122
|
153 # Set overclocking: set_oclock [mode]
|
pankso@122
|
154 set_oclock() {
|
pankso@122
|
155 debug "set_oclock $1"
|
pankso@122
|
156 case "$1" in
|
pankso@122
|
157 none)
|
pankso@122
|
158 arm_freq=700
|
pankso@122
|
159 core_freq=250
|
pankso@122
|
160 sdram_freq=400
|
pankso@122
|
161 over_voltage=0 ;;
|
pankso@122
|
162 modest)
|
pankso@122
|
163 arm_freq=800
|
pankso@122
|
164 core_freq=300
|
pankso@122
|
165 sdram_freq=400
|
pankso@122
|
166 over_voltage=0 ;;
|
pankso@122
|
167 medium)
|
pankso@122
|
168 arm_freq=900
|
pankso@122
|
169 core_freq=333
|
pankso@122
|
170 sdram_freq=450
|
pankso@122
|
171 over_voltage=2 ;;
|
paul@127
|
172 high)
|
pankso@122
|
173 arm_freq=950
|
pankso@122
|
174 core_freq=450
|
pankso@122
|
175 sdram_freq=450
|
pankso@122
|
176 over_voltage=6 ;;
|
pankso@122
|
177 turbo)
|
pankso@122
|
178 arm_freq=1000
|
pankso@122
|
179 core_freq=500
|
pankso@122
|
180 sdram_freq=500
|
pankso@122
|
181 over_voltage=6 ;;
|
pankso@122
|
182 esac
|
pankso@122
|
183 unset_oclock
|
pankso@122
|
184 cat >> ${config} << EOT
|
pankso@122
|
185 # Overclocking Settings
|
pankso@122
|
186 arm_freq=$arm_freq
|
pankso@122
|
187 core_freq=$core_freq
|
pankso@122
|
188 sdram_freq=$sdram_freq
|
pankso@122
|
189 over_voltage=$over_voltage
|
pankso@122
|
190
|
pankso@122
|
191 EOT
|
pankso@122
|
192 }
|
pankso@122
|
193
|
pankso@147
|
194 tazberry_back() {
|
pankso@148
|
195 gettext "Press ENTER to go back to TazBerry"; read
|
pankso@147
|
196 }
|
pankso@147
|
197
|
pankso@44
|
198 #
|
pankso@44
|
199 # GUI Functions
|
pankso@44
|
200 #
|
pankso@44
|
201
|
pankso@44
|
202 # Usage: msg_box "title" "message"
|
pankso@44
|
203 msg_box() {
|
pankso@44
|
204 dialog --title "{ $1 }" --cr-wrap \
|
pankso@44
|
205 --ok-label "TazBerry" --msgbox "\n$2" ${height} ${width}
|
pankso@44
|
206 }
|
pankso@44
|
207
|
pankso@44
|
208 # Usage: text_box "file"
|
pankso@44
|
209 text_box() {
|
pankso@44
|
210 local file="$1"
|
pankso@44
|
211 if [ -f "$file" ]; then
|
pankso@44
|
212 dialog --cr-wrap \
|
pankso@115
|
213 --title "{ $(gettext 'Viewing file:') $file }" \
|
pankso@44
|
214 --extra-button \
|
pankso@44
|
215 --extra-label "Edit file" \
|
pankso@44
|
216 --ok-label "TazBerry" \
|
pankso@44
|
217 --textbox ${file} ${height} ${width}
|
pankso@44
|
218 else
|
pankso@44
|
219 dialog --title "$title" \
|
pankso@44
|
220 --msgbox "\nERROR: $file does not exist" 10 ${width}
|
pankso@44
|
221 fi
|
pankso@44
|
222 # Handle options
|
pankso@44
|
223 case "$?" in
|
pankso@73
|
224 3) editor ${file} ;;
|
pankso@44
|
225 esac
|
pankso@44
|
226 }
|
pankso@44
|
227
|
pankso@44
|
228 # Usage: tail_box "file"
|
pankso@44
|
229 tail_box() {
|
pankso@115
|
230 dialog --title "{ $(gettext 'Watching file:') $2 }" \
|
pankso@44
|
231 --tailbox "$1" ${height} ${width}
|
pankso@44
|
232 }
|
pankso@44
|
233
|
pankso@154
|
234 # Usage: reboot_box "Message..."
|
pankso@154
|
235 reboot_box() {
|
pankso@154
|
236 dialog --title "$title" --yesno "\n${2}\n\n
|
pankso@154
|
237 Do You wish to reboot now ?" \
|
pankso@154
|
238 ${height} ${width}
|
pankso@154
|
239 [ "$?" == 0 ] && reboot
|
pankso@154
|
240 }
|
pankso@154
|
241
|
pankso@44
|
242 # Packages info and spk-up button
|
pankso@44
|
243 pkgs_box() {
|
pankso@44
|
244 out="$tmpdir/spk-info.txt"
|
pankso@44
|
245 spk info --output=raw > ${out}
|
pankso@44
|
246 dialog --cr-wrap \
|
pankso@44
|
247 --title "{ $(gettext 'Packages') }" \
|
pankso@44
|
248 --extra-button \
|
pankso@44
|
249 --extra-label "$(gettext 'Upgrade')" \
|
pankso@44
|
250 --ok-label "TazBerry" \
|
pankso@44
|
251 --textbox "$out" ${height} ${width}
|
pankso@44
|
252 # Handle options
|
pankso@44
|
253 case "$?" in
|
pankso@147
|
254 3) spk-up && tazberry_back ;;
|
pankso@44
|
255 esac
|
pankso@44
|
256 }
|
pankso@44
|
257
|
pankso@122
|
258 # Overclocking info TODO: button to setup
|
pankso@44
|
259 oclock_box() {
|
pankso@122
|
260 mode=$(fgrep arm_freq ${config} | cut -d '=' -f 2)
|
pankso@122
|
261 case "$mode" in
|
pankso@122
|
262 700) mode="none" ;;
|
pankso@122
|
263 800) mode="modest" ;;
|
pankso@122
|
264 900) mode="medium" ;;
|
pankso@122
|
265 950) mode="high" ;;
|
pankso@122
|
266 1000) mode="turbo" ;;
|
pankso@122
|
267 esac
|
pankso@122
|
268 dialog \
|
pankso@122
|
269 --clear --colors \
|
pankso@122
|
270 --extra-button \
|
pankso@122
|
271 --title "{ Overclocking }" \
|
pankso@44
|
272 --ok-label "TazBerry" \
|
pankso@122
|
273 --extra-label "Set Overclock" \
|
pankso@122
|
274 --cancel-label "Unset Oclock" \
|
paul@127
|
275 --menu "\nSet Raspberry Pi overclocking, current setting: \Zb\Z2$mode" \
|
pankso@122
|
276 ${height} ${width} 14 \
|
pankso@122
|
277 "none" "700MHz ARM 250MHz core 400MHz SDRAM 0 overvolt" \
|
pankso@122
|
278 "modest" "800MHz ARM 300MHz core 400MHz SDRAM 0 overvolt" \
|
pankso@122
|
279 "medium" "900MHz ARM 333MHz core 450MHz SDRAM 2 overvolt" \
|
pankso@122
|
280 "high" "950MHz ARM 450MHz core 450MHz SDRAM 6 overvolt" \
|
pankso@122
|
281 "turbo" "1000MHz ARM 500MHz core 500MHz SDRAM 6 overvolt" 2>${tmp}
|
pankso@122
|
282 retval="$?"
|
pankso@122
|
283 mode=$(cat $tmp)
|
pankso@122
|
284 case "$retval" in
|
pankso@122
|
285 0) continue ;;
|
pankso@122
|
286 1) unset_oclock ;;
|
pankso@122
|
287 3) set_oclock "$mode" ;;
|
pankso@122
|
288 255) rm -rf ${tmpdir} && exit 0 ;;
|
pankso@122
|
289 esac
|
pankso@44
|
290 }
|
pankso@44
|
291
|
pankso@105
|
292 gpu_mem_box() {
|
pankso@105
|
293 dialog \
|
pankso@105
|
294 --clear \
|
pankso@105
|
295 --title "$title" \
|
pankso@105
|
296 --ok-label "Set mem" \
|
pankso@105
|
297 --cancel-label "TazBerry" \
|
paul@108
|
298 --menu "\nSet the memory allocated to the GPU (in MB)" \
|
pankso@105
|
299 ${height} ${width} 14 \
|
pankso@105
|
300 "16" "For server, NAS, base system without X" \
|
pankso@105
|
301 "32" "For very small TFT and TV display" \
|
pankso@105
|
302 "64" "Default value, fine for low latency desktop" \
|
pankso@105
|
303 "128" "For a faster desktop, using a video player" \
|
pankso@105
|
304 "256" "For media center, GL/3D applications" 2>${tmp}
|
pankso@105
|
305 mem=$(cat $tmp)
|
pankso@105
|
306 sed -i \
|
pankso@105
|
307 -e s"/#gpu_mem=.*/gpu_mem=$mem/" \
|
pankso@105
|
308 -e s"/gpu_mem=.*/gpu_mem=$mem/" /boot/config.txt
|
pankso@105
|
309 }
|
pankso@105
|
310
|
pankso@134
|
311 picam_setup() {
|
pankso@134
|
312 db="/var/lib/tazpkg/installed"
|
pankso@134
|
313 gpu_mem=128
|
pankso@134
|
314 pct="0"
|
pankso@134
|
315 {
|
pankso@134
|
316 # Needed packages
|
pankso@134
|
317 for pkg in raspberrypi-vc raspberrypi-boot-x
|
pankso@134
|
318 do
|
pankso@134
|
319 echo "XXX" && echo $((${pct} + 20))
|
pankso@134
|
320 echo -e "\nInstalling: $pkg"
|
pankso@134
|
321 echo "XXX"
|
pankso@157
|
322 [ -d "$db/$pkg" ] || spk-add ${pkg} >/dev/null 2>&1
|
pankso@134
|
323 sleep 1
|
pankso@134
|
324 done
|
pankso@134
|
325
|
pankso@134
|
326 echo "XXX" && echo 60
|
pankso@134
|
327 echo -e "\nSetting up: ${config}"
|
pankso@134
|
328 echo "XXX" && sleep 1
|
pankso@134
|
329 # 0 to disable camera, 1 to enable it
|
pankso@134
|
330 if ! grep -q "start_x=1" ${config}; then
|
pankso@134
|
331 cat >> ${config} << EOT
|
pankso@134
|
332
|
pankso@134
|
333 # Camera settings
|
pankso@134
|
334 start_x=1
|
pankso@134
|
335
|
pankso@134
|
336 EOT
|
pankso@134
|
337 fi
|
pankso@134
|
338 # In case it was commented ot disabled
|
pankso@134
|
339 sed -i s'/#start_x=.*/start_x=1/' ${config}
|
pankso@134
|
340 sed -i s'/start_x=.*/start_x=1/' ${config}
|
pankso@134
|
341
|
paul@153
|
342 # PiCam needs 128 MB of GPU memory
|
pankso@134
|
343 echo "XXX" && echo 80
|
pankso@134
|
344 echo -e "\nSetting GPU memory to: ${gpu_mem}"
|
pankso@134
|
345 echo "XXX" && sleep 1
|
pankso@134
|
346
|
pankso@134
|
347 sed -i "s/#gpu_mem=.*/gpu_mem=${gpu_mem}/" ${config}
|
pankso@134
|
348 sed -i "s/gpu_mem=.*/gpu_mem=${gpu_mem}/" ${config}
|
pankso@134
|
349
|
pankso@134
|
350 echo "XXX" && echo 100
|
pankso@134
|
351 echo -e "\nPiCam config done..."
|
pankso@134
|
352 echo "XXX" && sleep 1
|
pankso@134
|
353
|
pankso@134
|
354 } | dialog --title "{ PiCam Setup }" \
|
pankso@134
|
355 --gauge "" 8 ${width} 0
|
pankso@134
|
356
|
pankso@134
|
357 # Reboot ?
|
pankso@158
|
358 reboot_box \
|
pankso@154
|
359 "$(gettext 'SliTaz is configured for the PiCam but you need a reboot to use it.')"
|
pankso@134
|
360 }
|
pankso@134
|
361
|
pankso@137
|
362 # Breakout bords!
|
pankso@137
|
363 boards_box() {
|
pankso@137
|
364 dialog \
|
pankso@137
|
365 --clear \
|
pankso@137
|
366 --title "$title" \
|
pankso@137
|
367 --ok-label "Exec" \
|
pankso@152
|
368 --cancel-label "TazBerry" \
|
pankso@137
|
369 --menu "\nSetup or use a breakout board" ${height} ${width} 14 \
|
pankso@162
|
370 "camera" "$(gettext 'Configure your Pi to use a Camera')" \
|
pankso@187
|
371 "piglow" "$(gettext 'Setup your Pi to use PiGlow')" \
|
pankso@187
|
372 "raspicomm" "$(gettext 'Initialize RaspiComm board')" \
|
pankso@187
|
373 "pitft" "$(gettext 'Setup PiTFT touchscreen')" 2>${tmp}
|
pankso@137
|
374
|
pankso@137
|
375 # Handle options
|
pankso@137
|
376 case "$?" in
|
pankso@150
|
377 1|255) continue ;;
|
pankso@137
|
378 esac
|
pankso@137
|
379
|
pankso@137
|
380 # Handle actions
|
pankso@137
|
381 action=$(cat $tmp)
|
pankso@137
|
382 case "$action" in
|
pankso@162
|
383 camera)
|
pankso@137
|
384 picam_setup ;;
|
pankso@137
|
385 piglow)
|
pankso@137
|
386 for pkg in python-rpi-pyglow wiringpi-piglow; do
|
pankso@137
|
387 spk-add ${pkg}
|
pankso@137
|
388 done
|
pankso@137
|
389 newline
|
pankso@137
|
390 echo -n "Do you wish to try the leds [y/N] ? " ; read anser
|
pankso@149
|
391 if [ "$anser" == "y" ]; then
|
pankso@149
|
392 echo "Enter a value between: 5-255" && pyglow test
|
pankso@149
|
393 fi ;;
|
pankso@187
|
394 raspicomm)
|
pankso@187
|
395 raspicomm init; read -t 4 ;;
|
pankso@187
|
396 pitft)
|
pankso@187
|
397 pitft-setup
|
pankso@187
|
398 echo -n "Press ENTER to continue..."; read ;;
|
pankso@137
|
399 esac
|
pankso@137
|
400 }
|
pankso@137
|
401
|
pankso@44
|
402 # Main Dialog menu
|
pankso@44
|
403 main_box() {
|
pankso@44
|
404 dialog \
|
pankso@44
|
405 --clear \
|
pankso@44
|
406 --title "$title" \
|
pankso@44
|
407 --ok-label "Exec" \
|
pankso@44
|
408 --cancel-label "Quit" \
|
pankso@44
|
409 --menu "" ${height} ${width} 14 \
|
pankso@44
|
410 "rpi-stats" "$(gettext 'Show some RPi system stats')" \
|
pankso@105
|
411 "gpu-mem" "$(gettext 'Set memory split between ARM and GPU')" \
|
pankso@137
|
412 "boards" "$(gettext 'Boards settings and tools (Camera, PyGlow)')" \
|
pankso@167
|
413 "act-led" "$(gettext 'Turn on/off RPi onboard ACT green led')" \
|
pankso@122
|
414 "oclock" "$(gettext 'Overclocking configuration')" \
|
pankso@105
|
415 "rpi-turbo" "$(gettext 'Enable or disable RPi turbo on next boot')" \
|
pankso@88
|
416 "boot-cmdline" "$(gettext 'View boot args /boot/cmdline.txt')" \
|
pankso@88
|
417 "boot-config" "$(gettext 'View config file /boot/config.txt')" \
|
pankso@147
|
418 "linux-up" "$(gettext 'Update SliTaz Raspberry Pi Linux Kernel')" \
|
pankso@115
|
419 "packages" "$(gettext 'SliTaz packages manager') (spk)" \
|
pankso@115
|
420 "config" "$(gettext 'System config (lang, keyboard, wifi)')" \
|
pankso@122
|
421 "reboot" "$(gettext 'Reboot SliTaz system')" \
|
pankso@44
|
422 "halt" "$(gettext 'Halt the Raspberry Pi')" \
|
pankso@88
|
423 "quit" "$(gettext 'Exit TazBerry tool')" 2>${tmp}
|
pankso@44
|
424
|
pankso@44
|
425 # Handle options
|
pankso@105
|
426 case "$?" in
|
pankso@46
|
427 1|255) rm -rf ${tmpdir} && exit 0 ;;
|
pankso@44
|
428 esac
|
pankso@44
|
429
|
pankso@44
|
430 # Handle actions
|
pankso@44
|
431 action=$(cat $tmp)
|
pankso@44
|
432 case "$action" in
|
pankso@44
|
433 rpi-stats)
|
pankso@44
|
434 msg_box "RPi Stats" "$(rpi_stats)" ;;
|
pankso@105
|
435 gpu-mem)
|
pankso@167
|
436 gpu_mem_box ;;
|
pankso@137
|
437 boards)
|
pankso@167
|
438 boards_box ;;
|
pankso@167
|
439 act-led)
|
pankso@167
|
440 pileds act ;;
|
pankso@100
|
441 oclock)
|
pankso@100
|
442 oclock_box ;;
|
pankso@44
|
443 rpi-turbo)
|
pankso@44
|
444 rpi_turbo && newline
|
pankso@147
|
445 tazberry_back ;;
|
pankso@105
|
446 boot-cmdline)
|
pankso@105
|
447 text_box /boot/cmdline.txt ;;
|
pankso@105
|
448 boot-config)
|
pankso@105
|
449 text_box ${config} ;;
|
pankso@147
|
450 linux-up)
|
pankso@155
|
451 linux_update
|
pankso@147
|
452 tazberry_back ;;
|
pankso@44
|
453 packages)
|
pankso@88
|
454 spk-dialog ;;
|
pankso@88
|
455 config)
|
pankso@88
|
456 slitaz-config ;;
|
pankso@44
|
457 reboot)
|
pankso@44
|
458 reboot ;;
|
pankso@44
|
459 halt)
|
pankso@115
|
460 poweroff ;;
|
pankso@44
|
461 quit)
|
pankso@44
|
462 rm -rf ${tmpdir} && exit 0 ;;
|
pankso@44
|
463 esac
|
pankso@44
|
464 }
|
pankso@44
|
465
|
pankso@44
|
466 # Progress bar testsuite
|
pankso@44
|
467 gauge_box() {
|
pankso@44
|
468 { for i in $(seq 1 100); do
|
pankso@44
|
469 echo $i
|
pankso@44
|
470 sleep 0.01
|
pankso@44
|
471 done
|
pankso@44
|
472 echo 100; } | dialog --title "{ TazBerry }" \
|
pankso@44
|
473 --gauge "Work in progress..." 6 ${width} 0
|
pankso@44
|
474 }
|
pankso@44
|
475
|
pankso@44
|
476 #
|
pankso@44
|
477 # Handle commands
|
pankso@44
|
478 #
|
pankso@44
|
479
|
pankso@44
|
480 case "$1" in
|
pankso@44
|
481 oclock)
|
pankso@122
|
482 oclock_box ;;
|
pankso@44
|
483
|
pankso@156
|
484 linux-up)
|
pankso@156
|
485 linux_update ;;
|
pankso@156
|
486
|
pankso@134
|
487 cam-setup)
|
pankso@134
|
488 picam_setup ;;
|
pankso@134
|
489
|
pankso@44
|
490 ls-functions)
|
pankso@44
|
491 newline
|
pankso@44
|
492 boldify "$(gettext 'TazBerry functions list')"
|
pankso@44
|
493 separator
|
pankso@44
|
494 grep "^rpi_*" $0 | awk '{print " ", $1}'
|
pankso@44
|
495 newline ;;
|
pankso@44
|
496
|
pankso@44
|
497 testsuite)
|
pankso@44
|
498 gauge_box
|
pankso@44
|
499 msg_box "Testsuite" "Test message"
|
pankso@44
|
500 rpi_stats
|
pankso@44
|
501 newline ;;
|
pankso@44
|
502
|
pankso@44
|
503 rpi_*)
|
pankso@44
|
504 # Execute functions
|
pankso@44
|
505 $@ ;;
|
pankso@44
|
506
|
pankso@44
|
507 "")
|
pankso@44
|
508 # No args: display Ncurses dialog
|
pankso@44
|
509 while true; do
|
pankso@44
|
510 main_box
|
pankso@44
|
511 done ;;
|
pankso@44
|
512
|
pankso@44
|
513 *|*help|-h)
|
pankso@44
|
514 # Display help
|
pankso@44
|
515 help ;;
|
pankso@44
|
516 esac
|
pankso@44
|
517
|
pankso@44
|
518 # Clean exit
|
pankso@44
|
519 rm -rf ${tmpdir}
|
pankso@44
|
520 exit 0
|