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@154
|
108
|
pankso@154
|
109 echo "XXX" && echo 50
|
pankso@154
|
110 echo -e "\n$(gettext 'Last Kernel version:') $kvers"
|
pankso@154
|
111 echo "XXX" && sleep 2
|
pankso@154
|
112 rm -rf ${cache}/linux-${kvers}*
|
pankso@154
|
113
|
pankso@154
|
114 # Download
|
pankso@154
|
115 echo "XXX" && echo 60
|
pankso@154
|
116 echo -e "\n$(gettext 'Fetching latest Linux package...')"
|
pankso@154
|
117 echo "XXX"
|
pankso@154
|
118 wget -q ${rpi_mirror}/packages/linux-${kvers}.tazpkg \
|
pankso@154
|
119 -O ${cache}/linux-${kvers}.tazpkg || exit 1
|
pankso@154
|
120
|
pankso@154
|
121 # Install
|
pankso@154
|
122 echo "XXX" && echo 80
|
pankso@154
|
123 echo -e "\n$(gettext 'Installing:') linux-${kvers}.tazpkg"
|
pankso@154
|
124 echo "XXX"
|
pankso@154
|
125 cd ${cache}
|
pankso@154
|
126 spk-add linux-${kvers}.tazpkg --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@142
|
322 [ -d "$db/$pkg" ] || spk-add ${pkg} >/dev/null 2>/dev/null
|
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@154
|
358 reboot_ox \
|
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@137
|
370 "cam-setup" "$(gettext 'Configure your Pi to use a Camera')" \
|
pankso@137
|
371 "piglow" "$(gettext 'Setup your Pi to use PiGlow')" 2>${tmp}
|
pankso@137
|
372
|
pankso@137
|
373 # Handle options
|
pankso@137
|
374 case "$?" in
|
pankso@150
|
375 1|255) continue ;;
|
pankso@137
|
376 esac
|
pankso@137
|
377
|
pankso@137
|
378 # Handle actions
|
pankso@137
|
379 action=$(cat $tmp)
|
pankso@137
|
380 case "$action" in
|
pankso@137
|
381 cam-setup)
|
pankso@137
|
382 picam_setup ;;
|
pankso@137
|
383 piglow)
|
pankso@137
|
384 for pkg in python-rpi-pyglow wiringpi-piglow; do
|
pankso@137
|
385 spk-add ${pkg}
|
pankso@137
|
386 done
|
pankso@137
|
387 newline
|
pankso@137
|
388 echo -n "Do you wish to try the leds [y/N] ? " ; read anser
|
pankso@149
|
389 if [ "$anser" == "y" ]; then
|
pankso@149
|
390 echo "Enter a value between: 5-255" && pyglow test
|
pankso@149
|
391 fi ;;
|
pankso@137
|
392 esac
|
pankso@137
|
393 }
|
pankso@137
|
394
|
pankso@44
|
395 # Main Dialog menu
|
pankso@44
|
396 main_box() {
|
pankso@44
|
397 dialog \
|
pankso@44
|
398 --clear \
|
pankso@44
|
399 --title "$title" \
|
pankso@44
|
400 --ok-label "Exec" \
|
pankso@44
|
401 --cancel-label "Quit" \
|
pankso@44
|
402 --menu "" ${height} ${width} 14 \
|
pankso@44
|
403 "rpi-stats" "$(gettext 'Show some RPi system stats')" \
|
pankso@105
|
404 "gpu-mem" "$(gettext 'Set memory split between ARM and GPU')" \
|
pankso@137
|
405 "boards" "$(gettext 'Boards settings and tools (Camera, PyGlow)')" \
|
pankso@105
|
406 "act-led" "$(gettext 'Test the RPi onboard ACT green led')" \
|
pankso@122
|
407 "oclock" "$(gettext 'Overclocking configuration')" \
|
pankso@105
|
408 "rpi-turbo" "$(gettext 'Enable or disable RPi turbo on next boot')" \
|
pankso@88
|
409 "boot-cmdline" "$(gettext 'View boot args /boot/cmdline.txt')" \
|
pankso@88
|
410 "boot-config" "$(gettext 'View config file /boot/config.txt')" \
|
pankso@147
|
411 "linux-up" "$(gettext 'Update SliTaz Raspberry Pi Linux Kernel')" \
|
pankso@115
|
412 "packages" "$(gettext 'SliTaz packages manager') (spk)" \
|
pankso@115
|
413 "config" "$(gettext 'System config (lang, keyboard, wifi)')" \
|
pankso@122
|
414 "reboot" "$(gettext 'Reboot SliTaz system')" \
|
pankso@44
|
415 "halt" "$(gettext 'Halt the Raspberry Pi')" \
|
pankso@88
|
416 "quit" "$(gettext 'Exit TazBerry tool')" 2>${tmp}
|
pankso@44
|
417
|
pankso@44
|
418 # Handle options
|
pankso@105
|
419 case "$?" in
|
pankso@46
|
420 1|255) rm -rf ${tmpdir} && exit 0 ;;
|
pankso@44
|
421 esac
|
pankso@44
|
422
|
pankso@44
|
423 # Handle actions
|
pankso@44
|
424 action=$(cat $tmp)
|
pankso@44
|
425 case "$action" in
|
pankso@44
|
426 rpi-stats)
|
pankso@44
|
427 msg_box "RPi Stats" "$(rpi_stats)" ;;
|
pankso@105
|
428 gpu-mem)
|
pankso@105
|
429 gpu_mem_box ;;
|
pankso@137
|
430 boards)
|
pankso@137
|
431 boards_box ;;
|
pankso@105
|
432 act-led)
|
pankso@105
|
433 brightness="/sys/class/leds/led0/brightness"
|
pankso@105
|
434 (echo "1" > ${brightness}
|
pankso@105
|
435 sleep 3; echo "0" > ${brightness}) & ;;
|
pankso@100
|
436 oclock)
|
pankso@100
|
437 oclock_box ;;
|
pankso@44
|
438 rpi-turbo)
|
pankso@44
|
439 rpi_turbo && newline
|
pankso@147
|
440 tazberry_back ;;
|
pankso@105
|
441 boot-cmdline)
|
pankso@105
|
442 text_box /boot/cmdline.txt ;;
|
pankso@105
|
443 boot-config)
|
pankso@105
|
444 text_box ${config} ;;
|
pankso@147
|
445 linux-up)
|
pankso@155
|
446 linux_update
|
pankso@147
|
447 tazberry_back ;;
|
pankso@44
|
448 packages)
|
pankso@88
|
449 spk-dialog ;;
|
pankso@88
|
450 config)
|
pankso@88
|
451 slitaz-config ;;
|
pankso@44
|
452 reboot)
|
pankso@44
|
453 reboot ;;
|
pankso@44
|
454 halt)
|
pankso@115
|
455 poweroff ;;
|
pankso@44
|
456 quit)
|
pankso@44
|
457 rm -rf ${tmpdir} && exit 0 ;;
|
pankso@44
|
458 esac
|
pankso@44
|
459 }
|
pankso@44
|
460
|
pankso@44
|
461 # Progress bar testsuite
|
pankso@44
|
462 gauge_box() {
|
pankso@44
|
463 { for i in $(seq 1 100); do
|
pankso@44
|
464 echo $i
|
pankso@44
|
465 sleep 0.01
|
pankso@44
|
466 done
|
pankso@44
|
467 echo 100; } | dialog --title "{ TazBerry }" \
|
pankso@44
|
468 --gauge "Work in progress..." 6 ${width} 0
|
pankso@44
|
469 }
|
pankso@44
|
470
|
pankso@44
|
471 #
|
pankso@44
|
472 # Handle commands
|
pankso@44
|
473 #
|
pankso@44
|
474
|
pankso@44
|
475 case "$1" in
|
pankso@44
|
476 oclock)
|
pankso@122
|
477 oclock_box ;;
|
pankso@44
|
478
|
pankso@156
|
479 linux-up)
|
pankso@156
|
480 linux_update ;;
|
pankso@156
|
481
|
pankso@134
|
482 cam-setup)
|
pankso@134
|
483 picam_setup ;;
|
pankso@134
|
484
|
pankso@44
|
485 ls-functions)
|
pankso@44
|
486 newline
|
pankso@44
|
487 boldify "$(gettext 'TazBerry functions list')"
|
pankso@44
|
488 separator
|
pankso@44
|
489 grep "^rpi_*" $0 | awk '{print " ", $1}'
|
pankso@44
|
490 newline ;;
|
pankso@44
|
491
|
pankso@44
|
492 testsuite)
|
pankso@44
|
493 gauge_box
|
pankso@44
|
494 msg_box "Testsuite" "Test message"
|
pankso@44
|
495 rpi_stats
|
pankso@44
|
496 newline ;;
|
pankso@44
|
497
|
pankso@44
|
498 rpi_*)
|
pankso@44
|
499 # Execute functions
|
pankso@44
|
500 $@ ;;
|
pankso@44
|
501
|
pankso@44
|
502 "")
|
pankso@44
|
503 # No args: display Ncurses dialog
|
pankso@44
|
504 while true; do
|
pankso@44
|
505 main_box
|
pankso@44
|
506 done ;;
|
pankso@44
|
507
|
pankso@44
|
508 *|*help|-h)
|
pankso@44
|
509 # Display help
|
pankso@44
|
510 help ;;
|
pankso@44
|
511 esac
|
pankso@44
|
512
|
pankso@44
|
513 # Clean exit
|
pankso@44
|
514 rm -rf ${tmpdir}
|
pankso@44
|
515 exit 0
|