slitaz-arm diff rpi/tazberry @ rev 44
Add TazBerry, kernel config patch and some fixes to spi
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Mar 09 10:14:01 2014 +0100 (2014-03-09) |
parents | |
children | b946dc4f933a |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/rpi/tazberry Sun Mar 09 10:14:01 2014 +0100 1.3 @@ -0,0 +1,244 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# TazBerry - SliTaz Raspberry Pi Config Tool 1.7 +# 1.8 +# Copyright (C) 2014 SliTaz ARM - BSD License 1.9 +# Author: Christophe Lincoln <pankso@slitaz.org> 1.10 +# 1.11 +. /lib/libtaz.sh 1.12 + 1.13 +title="{ TazBerry }" 1.14 +config="/boot/config.txt" 1.15 +tmpdir="/tmp/tazberry" 1.16 +tmp="$tmpdir/$$" 1.17 +height="20" 1.18 +width="72" 1.19 + 1.20 +# Use a tmp directory 1.21 +mkdir -p ${tmpdir} 1.22 + 1.23 +# Small built-in help 1.24 +help() { 1.25 + cat << EOT 1.26 + 1.27 +$(boldify "$(gettext 'Usage:')") $(basename $0) [command|rpi_function] 1.28 + 1.29 +$(boldify "$(gettext 'Commands:')") 1.30 + oclock $(gettext 'Display overclocking information') 1.31 + ls-functions $(gettext 'List TazBerry functions') 1.32 + testsuite $(gettext 'Run TazBerry testsuite') 1.33 + 1.34 +EOT 1.35 +} 1.36 + 1.37 +# 1.38 +# RPi functions 1.39 +# 1.40 + 1.41 +rpi_stats() { 1.42 + cat << EOT 1.43 +$(gettext 'Kernel') : $(uname -snrm) 1.44 +$(gettext 'Uptime') :$(uptime | cut -d "," -f 1,2) 1.45 +$(gettext 'CPU heat') : $(awk '{printf "%3.1f C\n", $1/1000}' \ 1.46 + /sys/class/thermal/thermal_zone0/temp) 1.47 +EOT 1.48 +} 1.49 + 1.50 +rpi_turbo() { 1.51 + if ! fgrep -q 'force_turbo=1' ${config}; then 1.52 + gettext "Enabling Raspberry Pi force turbo..." 1.53 + echo "force_turbo=1" >> ${config}; status 1.54 + else 1.55 + gettext "Disabling Raspberry Pi force turbo..." 1.56 + sed -i '/force_turbo=1/'d ${config}; status 1.57 + fi 1.58 +} 1.59 + 1.60 +# RPi Overclocking 1.61 +rpi_oclock() { 1.62 + cat << EOT 1.63 +none 700MHz ARM 250MHz core 400MHz SDRAM 0 overvolt 1.64 +modest 800MHz ARM 300MHz core 400MHz SDRAM 0 overvolt 1.65 +medium 900MHz ARM 333MHz core 450MHz SDRAM 2 overvolt 1.66 +high 950MHz ARM 450MHz core 450MHz SDRAM 6 overvolt 1.67 +turbo 1000MHz ARM 500MHz core 500MHz SDRAM 6 overvolt 1.68 +EOT 1.69 +} 1.70 + 1.71 +# 1.72 +# GUI Functions 1.73 +# 1.74 + 1.75 +# Usage: msg_box "title" "message" 1.76 +msg_box() { 1.77 + dialog --title "{ $1 }" --cr-wrap \ 1.78 + --ok-label "TazBerry" --msgbox "\n$2" ${height} ${width} 1.79 +} 1.80 + 1.81 +# Usage: text_box "file" 1.82 +text_box() { 1.83 + local file="$1" 1.84 + if [ -f "$file" ]; then 1.85 + dialog --cr-wrap \ 1.86 + --title " $(gettext 'Viewing file:') $file " \ 1.87 + --extra-button \ 1.88 + --extra-label "Edit file" \ 1.89 + --ok-label "TazBerry" \ 1.90 + --textbox ${file} ${height} ${width} 1.91 + else 1.92 + dialog --title "$title" \ 1.93 + --msgbox "\nERROR: $file does not exist" 10 ${width} 1.94 + fi 1.95 + # Handle options 1.96 + case "$?" in 1.97 + 3) nano ${file} ;; 1.98 + esac 1.99 +} 1.100 + 1.101 +# Usage: tail_box "file" 1.102 +tail_box() { 1.103 + dialog --title " $(gettext 'Watching file:') $2 " \ 1.104 + --tailbox "$1" ${height} ${width} 1.105 +} 1.106 + 1.107 +# Packages info and spk-up button 1.108 +pkgs_box() { 1.109 + out="$tmpdir/spk-info.txt" 1.110 + spk info --output=raw > ${out} 1.111 + dialog --cr-wrap \ 1.112 + --title "{ $(gettext 'Packages') }" \ 1.113 + --extra-button \ 1.114 + --extra-label "$(gettext 'Upgrade')" \ 1.115 + --ok-label "TazBerry" \ 1.116 + --textbox "$out" ${height} ${width} 1.117 + # Handle options 1.118 + case "$?" in 1.119 + 3) spk-up && gettext "Press ENTER to go back to TazBerry"; read ;; 1.120 + esac 1.121 +} 1.122 + 1.123 +oclock_box() { 1.124 + out="$tmpdir/overclocking.txt" 1.125 + cat > ${out} << EOT 1.126 + 1.127 +Overclocking modes: 1.128 +------------------- 1.129 +$(rpi_oclock) 1.130 + 1.131 +Current /boot/config.txt 1.132 +------------------------ 1.133 +$(cat $config) 1.134 + 1.135 +EOT 1.136 + dialog --cr-wrap \ 1.137 + --title "$title" \ 1.138 + --ok-label "TazBerry" \ 1.139 + --textbox "$out" ${height} ${width} 1.140 +} 1.141 + 1.142 +# Main Dialog menu 1.143 +main_box() { 1.144 + dialog \ 1.145 + --clear \ 1.146 + --title "$title" \ 1.147 + --ok-label "Exec" \ 1.148 + --cancel-label "Quit" \ 1.149 + --menu "" ${height} ${width} 14 \ 1.150 +"rpi-stats" "$(gettext 'Show some RPi system stats')" \ 1.151 +"cmdline.txt" "$(gettext 'View boot args /boot/cmdline.txt')" \ 1.152 +"config.txt" "$(gettext 'View config file /boot/config.txt')" \ 1.153 +"rpi-turbo" "$(gettext 'Enable or disable RPi turbo on next boot')" \ 1.154 +"oclock" "$(gettext 'Overclocking information and config')" \ 1.155 +"packages" "$(gettext 'Packages info and upgrade (spk)')" \ 1.156 +"keyboard" "$(gettext 'System keyboard setting')" \ 1.157 +"reboot" "$(gettext 'Reboot SliTaz')" \ 1.158 +"halt" "$(gettext 'Halt the Raspberry Pi')" \ 1.159 +"quit" "$(gettext 'Exit from TazBerry tool')" 2>${tmp} 1.160 + 1.161 + # Handle options 1.162 + opt=${?} 1.163 + case "$opt" in 1.164 + 1|255) rm ${tmpdir} && exit 0 ;; 1.165 + esac 1.166 + 1.167 + # Handle actions 1.168 + action=$(cat $tmp) 1.169 + case "$action" in 1.170 + rpi-stats) 1.171 + msg_box "RPi Stats" "$(rpi_stats)" ;; 1.172 + cmdline.txt) 1.173 + text_box /boot/cmdline.txt ;; 1.174 + config.txt) 1.175 + text_box ${config} ;; 1.176 + rpi-turbo) 1.177 + rpi_turbo && newline 1.178 + gettext "Press ENTER to go back to TazBerry"; read ;; 1.179 + oclock) 1.180 + oclock_box ;; 1.181 + packages) 1.182 + pkgs_box ;; 1.183 + keyboard) 1.184 + tazkeymap ;; 1.185 + reboot) 1.186 + reboot ;; 1.187 + halt) 1.188 + halt ;; 1.189 + quit) 1.190 + rm -rf ${tmpdir} && exit 0 ;; 1.191 + esac 1.192 +} 1.193 + 1.194 +# Progress bar testsuite 1.195 +gauge_box() { 1.196 + { for i in $(seq 1 100); do 1.197 + echo $i 1.198 + sleep 0.01 1.199 + done 1.200 + echo 100; } | dialog --title "{ TazBerry }" \ 1.201 + --gauge "Work in progress..." 6 ${width} 0 1.202 +} 1.203 + 1.204 +# 1.205 +# Handle commands 1.206 +# 1.207 + 1.208 +case "$1" in 1.209 + oclock) 1.210 + newline 1.211 + boldify "Overclocking modes:" 1.212 + rpi_oclock 1.213 + boldify "Current config.txt:" 1.214 + cat ${config} 1.215 + newline ;; 1.216 + 1.217 + ls-functions) 1.218 + newline 1.219 + boldify "$(gettext 'TazBerry functions list')" 1.220 + separator 1.221 + grep "^rpi_*" $0 | awk '{print " ", $1}' 1.222 + newline ;; 1.223 + 1.224 + testsuite) 1.225 + gauge_box 1.226 + msg_box "Testsuite" "Test message" 1.227 + rpi_stats 1.228 + newline ;; 1.229 + 1.230 + rpi_*) 1.231 + # Execute functions 1.232 + $@ ;; 1.233 + 1.234 + "") 1.235 + # No args: display Ncurses dialog 1.236 + while true; do 1.237 + main_box 1.238 + done ;; 1.239 + 1.240 + *|*help|-h) 1.241 + # Display help 1.242 + help ;; 1.243 +esac 1.244 + 1.245 +# Clean exit 1.246 +rm -rf ${tmpdir} 1.247 +exit 0