├── .gitignore ├── LICENSE.txt ├── README.md ├── documentation ├── bashref.py └── pythonref.py ├── images ├── pimoroni-dashboard.png └── terminal.jpg ├── installers ├── ads1015 ├── airdac ├── allthings ├── as7262 ├── audio ├── audiodac ├── automationhat ├── bh1745 ├── blinkt ├── bluetooth ├── bme680 ├── bmp280 ├── botlab ├── breakoutgarden ├── buttonshim ├── cleanshutdown ├── dashboard ├── debug ├── diagnostic ├── displayotron ├── dot3k ├── drumhat ├── envirophat ├── enviroplus ├── espiotphat ├── etcher ├── explorerhat ├── flotilla ├── flotilla-python ├── fourletterphat ├── getstarted ├── gfxhat ├── grow ├── hifidac ├── hyperpixel ├── hyperpixel4 ├── hyperpixel4-legacy ├── i2c ├── i2c0 ├── inky ├── inkyphat ├── iotphat ├── ledshim ├── lsm303d ├── ltr559 ├── matrix11x7 ├── max30105 ├── mcp9600 ├── microdotphat ├── mote ├── motephat ├── onoffshim ├── pantilthat ├── phatbeat ├── phatdac ├── pianohat ├── pibrella ├── picadefw ├── picadehat ├── piglow ├── plasma ├── propellerhat ├── propelleride ├── pulseaudio ├── rainbowhat ├── rgbmatrix5x5 ├── rockpool ├── scrollphat ├── scrollphateq ├── scrollphathd ├── skywriter ├── speakerphat ├── spi ├── spotipy ├── st7735 ├── template ├── touchphat ├── uartoff ├── uarton ├── ubercorn ├── undopulse ├── unicornhat ├── unicornhathd ├── uptodate ├── vlcradio ├── wifiapmode ├── wifiroaming └── zerolipo ├── learn └── getstarted.py ├── resources ├── github-repo-terminal.png ├── pimoroni_1.0.0_all.deb ├── pimoroni_1.0.1_all.deb ├── pimoroni_1.0.2_all.deb ├── pimoroni_1.0.3_all.deb ├── pimoroni_1.0.4_all.deb ├── pimoroni_1.0.5_all.deb └── python3-smbus1_1.1+35dbg-1_armhf.deb ├── support └── gethelp.py ├── update └── update_scripts /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | *.sql 27 | *.sqlite 28 | 29 | # OS generated files # 30 | ###################### 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | ehthumbs.db 37 | Thumbs.db 38 | 39 | output 40 | cache 41 | venv 42 | *.pyc 43 | 44 | 45 | *.orig 46 | *.rej 47 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | All scripts within get are licensed under the terms of the MIT license reproduced below. 2 | 3 | ##################################################### 4 | 5 | Copyright (c) 2014-2016 Pimoroni 6 | 7 | Permission is hereby granted, free of charge, to any person 8 | obtaining a copy of this software and associated documentation 9 | files (the "Software"), to deal in the Software without 10 | restriction, including without limitation the rights to use, 11 | copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following 14 | conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 | OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Get 2 | === 3 | 4 | Get is a collection of scripts, hosted at get.pimoroni.com, which facilitate easy installation of products, and easy automation of common tasks on the Raspberry Pi such as setting up i2c/spi and keeping up-to-date. 5 | 6 | In the interests of transparency and to invite contributions, these scripts are reproduced here. 7 | 8 | Using Get 9 | ========= 10 | 11 | You can run a get script like so: 12 | 13 | curl -sS https://get.pimoroni.com/getstarted | bash 14 | 15 | Note 16 | ==== 17 | 18 | All scripts within Get are supplied as-is without any warranty of any kind. They have been tested on recent versions of Raspbian and should generally work and not cause undue harm to your system. 19 | 20 | If you have trouble with any of the scripts, or tasks that they aim to solve, give us a shout at http://forums.pimoroni.com for help! 21 | 22 | -------------------------------------------------------------------------------- /documentation/bashref.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import webbrowser 4 | 5 | print("Launching Browser") 6 | webbrowser.open("https://www.gnu.org/software/bash/manual/", new=1, autoraise=True) 7 | -------------------------------------------------------------------------------- /documentation/pythonref.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import webbrowser 4 | 5 | print("Launching Browser") 6 | webbrowser.open("https://docs.python.org/3/", new=1, autoraise=True) 7 | -------------------------------------------------------------------------------- /images/pimoroni-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/images/pimoroni-dashboard.png -------------------------------------------------------------------------------- /images/terminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/images/terminal.jpg -------------------------------------------------------------------------------- /installers/ads1015: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="ADS1015 Breakout" # the name of the product to install 25 | scriptname="ads1015" # the name of this script 26 | spacereq=50 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="no" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="no" # whether to execute commands specified before exit 34 | gpioreq="no" # whether low-level gpio access is required 35 | i2creq="yes" # whether the i2c interface is required 36 | i2sreq="no" # whether the i2s interface is required 37 | spireq="no" # whether the spi interface is required 38 | uartreq="no" # whether uart communication is required 39 | armhfonly="yes" # whether the script is allowed to run on other arch 40 | armv6="yes" # whether armv6 processors are supported 41 | armv7="yes" # whether armv7 processors are supported 42 | armv8="yes" # whether armv8 processors are supported 43 | raspbianonly="no" # whether the script is allowed to run on other OSes 44 | osreleases=( "Raspbian" ) # list os-releases supported 45 | oswarning=( "Kano" "Mate" "PiTop" "RetroPie" ) # list experimental os-releases 46 | osdeny=( "Darwin" "Debian" "Kali" "Linaro" "OSMC" "Ubuntu" "Volumio" ) # list os-releases specifically disallowed 47 | debpackage="na" # the name of the package in apt repo 48 | piplibname="ads1015" # the name of the lib in pip repo 49 | pipoverride="yes" # whether the script should give priority to pip repo 50 | pip2support="no" # whether python2 is supported 51 | pip3support="yes" # whether python3 is supported 52 | topdir="Pimoroni" # the name of the top level directory 53 | localdir="ads1015" # the name of the dir for copy of resources 54 | gitreponame="ads1015-python" # the name of the git project repo 55 | gitusername="pimoroni" # the name of the git user to fetch repo from 56 | gitrepobranch="master" # repo branch to checkout 57 | gitrepotop="root" # the name of the dir to base repo from 58 | gitrepoclone="no" # whether the git repo is to be cloned locally 59 | gitclonedir="source" # the name of the local dir for repo 60 | repoclean="no" # whether any git repo clone found should be cleaned up 61 | repoinstall="no" # whether the library should be installed from repo 62 | libdir="library" # subdirectory of library in repo 63 | copydir=( "examples" ) # subdirectories to copy from repo 64 | copyhead="no" # whether to use the latest repo commit or release tag 65 | pkgremove=() # list of conflicting packages to remove 66 | coredeplist=() # list of core dependencies 67 | pythondep=() # list of python dependencies 68 | pipdeplist=() # list of dependencies to source from pypi 69 | examplesdep=() # list of python modules required by examples 70 | somemoredep=() # list of additional dependencies 71 | xdisplaydep=() # list of dependencies requiring X server 72 | 73 | # template 1712181300 74 | 75 | FORCE=$1 76 | ASK_TO_REBOOT=false 77 | CURRENT_SETTING=false 78 | MIN_INSTALL=false 79 | FAILED_PKG=false 80 | REMOVE_PKG=false 81 | UPDATE_DB=false 82 | 83 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 84 | BOOTCMD=/boot/cmdline.txt 85 | CONFIG=/boot/config.txt 86 | DTBODIR=/boot/overlays 87 | APTSRC=/etc/apt/sources.list 88 | INITABCONF=/etc/inittab 89 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 90 | LOADMOD=/etc/modules 91 | 92 | RASPOOL="http://mirrordirector.raspbian.org/raspbian/pool" 93 | RPIPOOL="http://archive.raspberrypi.org/debian/pool" 94 | DEBPOOL="http://ftp.debian.org/debian/pool" 95 | GETPOOL="https://get.pimoroni.com" 96 | 97 | SMBUS2="python-smbus_3.1.1+svn-2_armhf.deb" 98 | SMBUS3="python3-smbus_3.1.1+svn-2_armhf.deb" 99 | SMBUS35="python3-smbus1_1.1+35dbg-1_armhf.deb" 100 | 101 | SPIDEV2="python-spidev_2.0~git20150907_armhf.deb" 102 | SPIDEV3="python3-spidev_2.0~git20150907_armhf.deb" 103 | 104 | RPIGPIO1="raspi-gpio_0.20170105_armhf.deb" 105 | RPIGPIO2="python-rpi.gpio_0.6.3~jessie-1_armhf.deb" 106 | RPIGPIO3="python3-rpi.gpio_0.6.3~jessie-1_armhf.deb" 107 | 108 | export PIP_FORMAT=columns 109 | 110 | # function define 111 | 112 | confirm() { 113 | if [ "$FORCE" == '-y' ]; then 114 | true 115 | else 116 | read -r -p "$1 [y/N] " response < /dev/tty 117 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 118 | true 119 | else 120 | false 121 | fi 122 | fi 123 | } 124 | 125 | prompt() { 126 | read -r -p "$1 [y/N] " response < /dev/tty 127 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 128 | true 129 | else 130 | false 131 | fi 132 | } 133 | 134 | success() { 135 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 136 | } 137 | 138 | inform() { 139 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 140 | } 141 | 142 | warning() { 143 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 144 | } 145 | 146 | newline() { 147 | echo "" 148 | } 149 | 150 | progress() { 151 | count=0 152 | until [ $count -eq 7 ]; do 153 | echo -n "..." && sleep 1 154 | ((count++)) 155 | done; 156 | if ps -C $1 > /dev/null; then 157 | echo -en "\r\e[K" && progress $1 158 | fi 159 | } 160 | 161 | sudocheck() { 162 | if [ $(id -u) -ne 0 ]; then 163 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 164 | exit 1 165 | fi 166 | } 167 | 168 | sysclean() { 169 | sudo apt-get clean && sudo apt-get autoclean 170 | sudo apt-get -y autoremove &> /dev/null 171 | } 172 | 173 | sysupdate() { 174 | if ! $UPDATE_DB; then 175 | echo "Updating apt indexes..." && progress apt-get & 176 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 177 | sleep 3 && UPDATE_DB=true 178 | fi 179 | } 180 | 181 | sysupgrade() { 182 | sudo apt-get upgrade 183 | sudo apt-get clean && sudo apt-get autoclean 184 | sudo apt-get -y autoremove &> /dev/null 185 | } 186 | 187 | sysreboot() { 188 | warning "Some changes made to your system require" 189 | warning "your computer to reboot to take effect." 190 | echo 191 | if prompt "Would you like to reboot now?"; then 192 | sync && sudo reboot 193 | fi 194 | } 195 | 196 | home_dir() { 197 | if [ $EUID -ne 0 ]; then 198 | USER_HOME=$(getent passwd $USER | cut -d: -f6) 199 | else 200 | warning "Running as root, please log in as a regular user with sudo rights!" 201 | echo && exit 1 202 | fi 203 | } 204 | 205 | space_chk() { 206 | if command -v stat > /dev/null; then 207 | if [ $spacereq -gt $(($(stat -f -c "%a*%S" /)/10**6)) ];then 208 | echo 209 | warning "There is not enough space left to proceed with installation" 210 | if confirm "Would you like to attempt to expand your filesystem?"; then 211 | curl -sS $GETPOOL/expandfs | sudo bash && exit 1 212 | else 213 | echo && exit 1 214 | fi 215 | fi 216 | fi 217 | } 218 | 219 | timestamp() { 220 | date +%Y%m%d-%H%M 221 | } 222 | 223 | check_network() { 224 | sudo ping -q -w 10 -c 1 1.1.1.1 | grep "received, 0" &> /dev/null 225 | if [ $? -eq 0 ]; then 226 | return 0 227 | else 228 | sudo ping -q -w 10 -c 1 8.8.8.8 | grep "received, 0" &> /dev/null 229 | if [ $? -eq 0 ]; then 230 | return 0 231 | fi 232 | fi 233 | return 1 234 | } 235 | 236 | launch_url() { 237 | check_network || (error_box "You don't appear to be connected to the internet, please check your connection and try again!" && exit 1) 238 | if command -v xdg-open > /dev/null; then 239 | xdg-open "$1" && return 0 240 | else 241 | error_box "There was an error attempting to launch your browser!" 242 | fi 243 | } 244 | 245 | get_install() { 246 | check_network || (error_box "You don't appear to be connected to the internet, please check your connection and try again!" && exit 1) 247 | if [ "$1" != diagnostic ];then 248 | sysupdate && UPDATE_DB=true 249 | fi 250 | if ! command -v curl > /dev/null; then 251 | apt_pkg_install "curl" 252 | fi 253 | curl -sS https://get.pimoroni.com/$1 | bash -s - "-y" $2 254 | read -p "Press Enter to continue..." < /dev/tty 255 | } 256 | 257 | apt_pkg_req() { 258 | APT_CHK=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "install ok installed") 259 | 260 | if [ "" == "$APT_CHK" ]; then 261 | echo "$1 is required" 262 | true 263 | else 264 | echo "$1 is already installed" 265 | false 266 | fi 267 | } 268 | 269 | apt_pkg_install() { 270 | echo "Installing $1..." 271 | sudo apt-get --yes install "$1" 1> /dev/null || { inform "Apt failed to install $1!\nFalling back on pypi..." && return 1; } 272 | } 273 | 274 | apt_deb_chk() { 275 | BEFORE=$(dpkg-query -W "$1" 2> /dev/null) 276 | sudo apt-get --yes install "$1" &> /dev/null || return 1 277 | AFTER=$(dpkg-query -W "$1" 2> /dev/null) 278 | if [ "$BEFORE" == "$AFTER" ]; then 279 | echo "$1 is already the newest version" 280 | else 281 | echo "$1 was successfully upgraded" 282 | fi 283 | } 284 | 285 | apt_deb_install() { 286 | echo "Installing $1..." 287 | if [[ "$1" != *".deb"* ]]; then 288 | sudo apt-get --yes install "$1" &> /dev/null || inform "Apt failed to install $1!\nFalling back on pypi..." 289 | dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "install ok installed" 290 | else 291 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` 292 | cd $DEBDIR 293 | wget "$GETPOOL/resources/$1" &> /dev/null 294 | sudo dpkg -i "$DEBDIR/$1" | grep "Installing $1" 295 | fi 296 | } 297 | 298 | pip_cmd_chk() { 299 | if command -v pip2 > /dev/null; then 300 | PIP2_BIN="pip2" 301 | elif command -v pip-2.7 > /dev/null; then 302 | PIP2_BIN="pip-2.7" 303 | elif command -v pip-2.6 > /dev/null; then 304 | PIP2_BIN="pip-2.6" 305 | else 306 | PIP2_BIN="pip" 307 | fi 308 | if command -v pip3 > /dev/null; then 309 | PIP3_BIN="pip3" 310 | elif command -v pip-3.3 > /dev/null; then 311 | PIP3_BIN="pip-3.3" 312 | elif command -v pip-3.2 > /dev/null; then 313 | PIP3_BIN="pip-3.2" 314 | fi 315 | } 316 | 317 | pip2_lib_req() { 318 | PIP2_CHK=$($PIP2_BIN list 2> /dev/null | grep -i "$1") 319 | 320 | if [ -z "$PIP2_CHK" ]; then 321 | true 322 | else 323 | false 324 | fi 325 | } 326 | 327 | pip3_lib_req() { 328 | PIP3_CHK=$($PIP3_BIN list 2> /dev/null | grep -i "$1") 329 | 330 | if [ -z "$PIP3_CHK" ]; then 331 | true 332 | else 333 | false 334 | fi 335 | } 336 | 337 | usb_max_power() { 338 | if grep -q "^max_usb_current=1$" $CONFIG; then 339 | echo -e "\nMax USB current setting already active" 340 | else 341 | echo -e "\nAdjusting USB current setting in $CONFIG" 342 | echo "max_usb_current=1" | sudo tee -a $CONFIG &> /dev/null 343 | fi 344 | } 345 | 346 | add_dtoverlay() { 347 | if grep -q "^dtoverlay=$1" $CONFIG; then 348 | echo -e "\n$1 overlay already active" 349 | elif grep -q "^#dtoverlay=$1" $CONFIG; then 350 | sudo sed -i "/^#dtoverlay=$1$/ s|#||" $CONFIG 351 | echo -e "\nAdding $1 overlay to $CONFIG" 352 | ASK_TO_REBOOT=true 353 | else 354 | echo "dtoverlay=$1" | sudo tee -a $CONFIG &> /dev/null 355 | echo -e "\nAdding $1 overlay to $CONFIG" 356 | ASK_TO_REBOOT=true 357 | fi 358 | } 359 | 360 | remove_dtoverlay() { 361 | sudo sed -i "/^dtoverlay=$1$/ s|^|#|" $CONFIG 362 | ASK_TO_REBOOT=true 363 | } 364 | 365 | enable_pi_audio() { 366 | if grep -q "#dtparam=audio=on" $CONFIG; then 367 | sudo sed -i "/^#dtparam=audio=on$/ s|#||" $CONFIG 368 | echo -e "\nsnd_bcm2835 loaded (on-board audio enabled)" 369 | ASK_TO_REBOOT=true 370 | fi 371 | } 372 | 373 | disable_pi_audio() { 374 | if grep -q "^dtparam=audio=on" $CONFIG; then 375 | sudo sed -i "/^dtparam=audio=on$/ s|^|#|" $CONFIG 376 | echo -e "\nsnd_bcm2835 unloaded (on-board audio disabled)" 377 | ASK_TO_REBOOT=true 378 | fi 379 | } 380 | 381 | test_audio() { 382 | echo 383 | if confirm "Do you wish to test your system now?"; then 384 | echo -e "\nTesting..." 385 | speaker-test -l5 -c2 -t wav 386 | fi 387 | } 388 | 389 | disable_pulseaudio() { 390 | sudo mv /etc/xdg/autostart/pulseaudio.desktop /etc/xdg/autostart/pulseaudio.disabled &> /dev/null 391 | pulseaudio -k &> /dev/null 392 | } 393 | 394 | kill_volumealsa() { 395 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE/panels/panel &> /dev/null 396 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE-pi/panels/panel &> /dev/null 397 | } 398 | 399 | basic_asound() { 400 | sudo echo -e "pcm.\041default {\n type hw\n card 1\n}" > $HOME/.asoundrc 401 | sudo echo -e "ctl.\041default {\n type hw\n card 1\n}" >> $HOME/.asoundrc 402 | sudo mv $HOME/.asoundrc /etc/asound.conf 403 | } 404 | 405 | config_set() { 406 | if [ -n $defaultconf ]; then 407 | sudo sed -i "s|$1=.*$|$1=$2|" $defaultconf 408 | else 409 | sudo sed -i "s|$1=.*$|$1=$2|" $3 410 | fi 411 | } 412 | 413 | servd_trig() { 414 | if command -v service > /dev/null; then 415 | sudo service $1 $2 416 | fi 417 | } 418 | 419 | get_init_sys() { 420 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 421 | SYSTEMD=1 422 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 423 | SYSTEMD=0 424 | else 425 | echo "Unrecognised init system" && exit 1 426 | fi 427 | } 428 | 429 | i2c_vc_dtparam() { 430 | if [ -e $CONFIG ] && grep -q "^dtparam=i2c_vc=on$" $CONFIG; then 431 | echo -e "\ni2c0 bus already active" 432 | else 433 | echo -e "\nEnabling i2c0 bus in $CONFIG" 434 | echo "dtparam=i2c_vc=on" | sudo tee -a $CONFIG && echo 435 | fi 436 | } 437 | 438 | : <<'MAINSTART' 439 | 440 | Perform all variables declarations as well as function definition 441 | above this section for clarity, thanks! 442 | 443 | MAINSTART 444 | 445 | # intro message 446 | 447 | if [ $debugmode != "no" ]; then 448 | if [ $debuguser != "none" ]; then 449 | gitusername="$debuguser" 450 | fi 451 | if [ $debugpoint != "none" ]; then 452 | gitrepobranch="$debugpoint" 453 | fi 454 | inform "\nDEBUG MODE ENABLED" 455 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 456 | else 457 | echo -e "\nThis script will install everything needed to use\n$productname" 458 | if [ "$FORCE" != '-y' ]; then 459 | inform "\nAlways be careful when running scripts and commands copied" 460 | inform "from the internet. Ensure they are from a trusted source.\n" 461 | warning "This script should -- only be run on a Raspberry Pi with RPi OS --" 462 | warning "other systems and SBCs are not supported and may explode!\n" 463 | echo -e "If you want to see what this script does before running it," 464 | echo -e "you should run: 'curl $GETPOOL/$scriptname'\n" 465 | fi 466 | fi 467 | 468 | # checks and init 469 | space_chk 470 | home_dir 471 | 472 | if [ $debugmode != "no" ]; then 473 | echo "USER_HOME is $USER_HOME" 474 | echo "OS_NAME is $OS_NAME" 475 | echo 476 | fi 477 | 478 | if [ $forcesudo == "yes" ]; then 479 | sudocheck 480 | fi 481 | 482 | if [ $uartreq == "yes" ]; then 483 | echo "Note: $productname requires UART communication" 484 | warning "The serial console will be disabled if you proceed!" 485 | fi 486 | if [ $spireq == "yes" ]; then 487 | echo -e "Note: $productname requires SPI communication" 488 | fi 489 | if [ $i2creq == "yes" ]; then 490 | echo -e "Note: $productname requires I2C communication" 491 | fi 492 | if [ $i2sreq == "yes" ]; then 493 | echo -e "Note: $productname uses the I2S interface" 494 | if [ $OS_NAME != "Volumio" ]; then 495 | warning "The on-board audio chip will be disabled if you proceed!" 496 | fi 497 | fi 498 | 499 | newline 500 | if confirm "Do you wish to continue?"; then 501 | 502 | # basic environment preparation 503 | 504 | echo -e "\nChecking environment..." 505 | 506 | if [ "$FORCE" != '-y' ]; then 507 | if ! check_network; then 508 | warning "We can't connect to the Internet, check your network!" && exit 1 509 | fi 510 | sysupdate && newline 511 | fi 512 | 513 | if apt_pkg_req "apt-utils" &> /dev/null; then 514 | apt_pkg_install "apt-utils" 515 | fi 516 | if ! command -v curl > /dev/null; then 517 | apt_pkg_install "curl" 518 | fi 519 | if ! command -v wget > /dev/null; then 520 | apt_pkg_install "wget" 521 | fi 522 | 523 | if [ "$pip2support" == "yes" ]; then 524 | if ! [ -f "$(which python2)" ]; then 525 | if confirm "Python 2 is not installed. Would like to install it?"; then 526 | progress apt-get & 527 | apt_pkg_install "python-pip" 528 | else 529 | pip2support="na" 530 | fi 531 | elif apt_pkg_req "python-pip" &> /dev/null; then 532 | progress apt-get & 533 | apt_pkg_install "python-pip" 534 | fi 535 | fi 536 | if [ "$pip3support" == "yes" ]; then 537 | if ! [ -f "$(which python3)" ]; then 538 | if prompt "Python 3 is not installed. Would like to install it?"; then 539 | progress apt-get & 540 | apt_pkg_install "python3-pip" 541 | else 542 | pip3support="na" 543 | fi 544 | elif apt_pkg_req "python3-pip" &> /dev/null; then 545 | progress apt-get & 546 | apt_pkg_install "python3-pip" 547 | fi 548 | fi 549 | pip_cmd_chk 550 | 551 | # hardware setup 552 | 553 | echo -e "\nChecking hardware requirements..." 554 | 555 | if [ $uartreq == "yes" ]; then 556 | echo -e "\nThe serial console must be disabled for $productname to work" 557 | curl -sS $GETPOOL/uarton | sudo bash -s - "-y" && ASK_TO_REBOOT=true 558 | fi 559 | 560 | if [ $gpioreq == "yes" ]; then 561 | echo -e "\nChecking for packages required for GPIO control..." 562 | if ! apt_pkg_install "raspi-gpio" &> /dev/null; then 563 | echo "package raspi-gpio can't be found, fetching from alternative location..." 564 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 565 | wget $RPIPOOL/main/r/raspi-gpio/$RPIGPIO1 &> /dev/null 566 | sudo dpkg -i $DEBDIR/$RPIGPIO1 && FAILED_PKG=false 567 | fi 568 | if [ "$pip2support" == "yes" ] && ! apt_pkg_install "python-rpi.gpio" &> /dev/null; then 569 | if [ -n $(python --version 2>&1 | grep -q "2.7") ]; then 570 | echo "package python-rpi.gpio can't be found, fetching from alternative location..." 571 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 572 | wget $RPIPOOL/main/r/rpi.gpio/$RPIGPIO2 &> /dev/null 573 | sudo dpkg -i $DEBDIR/$RPIGPIO2 && FAILED_PKG=false 574 | else 575 | sudo $PIP2_BIN install RPi.GPIO && FAILED_PKG=false 576 | fi 577 | fi 578 | if [ "$pip3support" == "yes" ] && ! apt_pkg_install "python3-rpi.gpio" &> /dev/null; then 579 | if [ -n $(python3 --version 2>&1 | grep -q "3.4") ]; then 580 | echo "package python3-rpi.gpio can't be found, fetching from alternative location..." 581 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 582 | wget $RPIPOOL/main/r/rpi.gpio/$RPIGPIO3 &> /dev/null 583 | sudo dpkg -i $DEBDIR/$RPIGPIO3 && FAILED_PKG=false 584 | else 585 | sudo $PIP3_BIN install RPi.GPIO && FAILED_PKG=false 586 | fi 587 | fi 588 | if [ "$pip2support" == "yes" ] && [ -f "$(which python2)" ]; then 589 | if ! $PIP2_BIN list | grep "RPi.GPIO" &> /dev/null; then 590 | warning "Unable to install RPi.GPIO for python 2!" && FAILED_PKG=true 591 | else 592 | RPIGPIO2="install ok installed" 593 | fi 594 | fi 595 | if [ "$pip3support" == "yes" ] && [ -f "$(which python3)" ]; then 596 | if ! $PIP3_BIN list | grep "RPi.GPIO" &> /dev/null; then 597 | warning "Unable to install RPi.GPIO for python 3!" && FAILED_PKG=true 598 | else 599 | RPIGPIO3="install ok installed" 600 | fi 601 | fi 602 | if [ "$RPIGPIO2" == "install ok installed" ] || [ "$RPIGPIO3" == "install ok installed" ]; then 603 | if ! $FAILED_PKG; then 604 | echo -e "RPi.GPIO installed and up-to-date" 605 | fi 606 | fi 607 | fi 608 | 609 | if [ $spireq == "yes" ]; then 610 | newline 611 | if ls /dev/spi* &> /dev/null; then 612 | inform "SPI already enabled" 613 | else 614 | echo "SPI must be enabled for $productname to work" 615 | if command -v raspi-config > /dev/null && sudo raspi-config nonint get_spi | grep -q "1"; then 616 | sudo raspi-config nonint do_spi 0 617 | inform "SPI is now enabled" 618 | else 619 | curl -sS $GETPOOL/spi | sudo bash -s - "-y" && ASK_TO_REBOOT=true 620 | fi 621 | fi 622 | echo -e "\nChecking packages required by SPI interface..." 623 | if [ "$pip2support" == "yes" ] && ! apt_pkg_install "python-spidev" &> /dev/null; then 624 | if [ -n $(python --version 2>&1 | grep -q "2.7") ]; then 625 | echo "package python-spidev can't be found, fetching from alternative location..." 626 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 627 | wget $RPIPOOL/main/s/spidev/$SPIDEV2 &> /dev/null 628 | sudo dpkg -i $DEBDIR/$SPIDEV2 && FAILED_PKG=false 629 | else 630 | sudo $PIP2_BIN install spidev && FAILED_PKG=false 631 | fi 632 | fi 633 | if [ "$pip3support" == "yes" ] && ! apt_pkg_install "python3-spidev" &> /dev/null; then 634 | if [ -n $(python3 --version 2>&1 | grep -q "3.4") ]; then 635 | echo "package python3-spidev can't be found, fetching from alternative location..." 636 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 637 | wget $RPIPOOL/main/s/spidev/$SPIDEV3 &> /dev/null 638 | sudo dpkg -i $DEBDIR/$SPIDEV3 && FAILED_PKG=false 639 | else 640 | sudo $PIP3_BIN install spidev && FAILED_PKG=false 641 | fi 642 | fi 643 | if [ "$pip2support" == "yes" ] && [ -f "$(which python2)" ]; then 644 | if ! $PIP2_BIN list | grep "spidev" &> /dev/null; then 645 | warning "Unable to install spidev for python 2!" && FAILED_PKG=true 646 | else 647 | SPIDEV2="install ok installed" 648 | fi 649 | fi 650 | if [ "$pip3support" == "yes" ] && [ -f "$(which python3)" ]; then 651 | if ! $PIP3_BIN list | grep "spidev" &> /dev/null; then 652 | warning "Unable to install spidev for python 3!" && FAILED_PKG=true 653 | else 654 | SPIDEV3="install ok installed" 655 | fi 656 | fi 657 | if [ "$SPIDEV2" == "install ok installed" ] || [ "$SPIDEV3" == "install ok installed" ]; then 658 | if ! $FAILED_PKG; then 659 | echo -e "spidev installed and up-to-date" 660 | fi 661 | fi 662 | fi 663 | 664 | if [ $i2creq == "yes" ]; then 665 | newline 666 | if ls /dev/i2c* &> /dev/null; then 667 | inform "I2C already enabled" 668 | else 669 | echo "I2C must be enabled for $productname to work" 670 | if command -v raspi-config > /dev/null && sudo raspi-config nonint get_i2c | grep -q "1"; then 671 | sudo raspi-config nonint do_i2c 0 672 | inform "I2C is now enabled" 673 | else 674 | curl -sS $GETPOOL/i2c | sudo bash -s - "-y" && ASK_TO_REBOOT=true 675 | fi 676 | fi 677 | echo -e "\nChecking packages required by I2C interface..." 678 | if [ "$pip2support" == "yes" ] && ! apt_pkg_install "python-smbus" &> /dev/null; then 679 | FAILED_PKG=false 680 | if [ -n $(python --version 2>&1 | grep -q "2.7") ]; then 681 | echo "package python-smbus can't be found, fetching from alternative location..." 682 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 683 | wget $RPIPOOL/main/i/i2c-tools/$SMBUS2 &> /dev/null 684 | sudo dpkg -i $DEBDIR/$SMBUS2 || FAILED_PKG=true 685 | fi 686 | if $FAILED_PKG; then 687 | warning "Unable to install smbus for python 2!" 688 | else 689 | echo -e "Python 2 smbus installed and up-to-date" 690 | fi 691 | else 692 | echo -e "Python 2 smbus installed and up-to-date" 693 | fi 694 | if [ "$pip3support" == "yes" ] && ! apt_pkg_install "python3-smbus" &> /dev/null; then 695 | FAILED_PKG=false 696 | if [ -n $(python3 --version 2>&1 | grep -q "3.4") ]; then 697 | echo "package python3-smbus can't be found, fetching from alternative location..." 698 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 699 | wget $RPIPOOL/main/i/i2c-tools/$SMBUS3 &> /dev/null 700 | sudo dpkg -i $DEBDIR/$SMBUS3 || FAILED_PKG=true 701 | elif [ -n $(python3 --version 2>&1 | grep -q "3.5") ]; then 702 | if apt_pkg_req "python3-smbus1" &> /dev/null; then 703 | echo "package python3-smbus can't be found, fetching from alternative location..." 704 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 705 | wget $GETPOOL/resources/$SMBUS35 &> /dev/null 706 | sudo dpkg -i $DEBDIR/$SMBUS35 || FAILED_PKG=true 707 | fi 708 | fi 709 | if $FAILED_PKG; then 710 | warning "Unable to install smbus for python 3!" 711 | else 712 | echo -e "Python 3 smbus installed and up-to-date" 713 | fi 714 | else 715 | echo -e "Python 3 smbus installed and up-to-date" 716 | fi 717 | fi 718 | 719 | if [ $i2sreq == "yes" ]; then 720 | if [ -f /etc/asound.conf ]; then 721 | sudo rm -f /etc/asound.conf.backup &> /dev/null 722 | sudo mv /etc/asound.conf /etc/asound.conf.backup 723 | inform "existing config backed up to /etc/asound.conf.backup" 724 | fi 725 | if [ -f $HOME/.asoundrc ]; then 726 | sudo rm -f $HOME/.asoundrc.backup &> /dev/null 727 | sudo mv $HOME/.asoundrc $HOME/.asoundrc.backup 728 | inform "existing config backed up to ~/.asound.conf.backup" 729 | fi 730 | fi 731 | 732 | # minimum install routine 733 | 734 | if [ $mininstall != "yes" ] && [ $gitrepoclone != "yes" ]; then 735 | newline 736 | echo "$productname comes with examples and documentation that you may wish to install." 737 | echo "Performing a full install will ensure those resources are installed," 738 | echo "along with all required dependencies. It may however take a while!" 739 | newline 740 | if ! confirm "Do you wish to perform a full install?"; then 741 | MIN_INSTALL=true 742 | fi 743 | else 744 | MIN_INSTALL=true 745 | fi 746 | 747 | if [ $localdir != "na" ]; then 748 | installdir="$USER_HOME/$topdir/$localdir" 749 | else 750 | installdir="$USER_HOME/$topdir" 751 | fi 752 | 753 | if ! $MIN_INSTALL || [ $gitrepoclone == "yes" ]; then 754 | [ -d $installdir ] || mkdir -p $installdir 755 | fi 756 | 757 | if [ $debugmode != "no" ]; then 758 | echo "INSTALLDIR is $installdir" 759 | fi 760 | 761 | # apt repo install 762 | 763 | echo -e "\nChecking for dependencies..." 764 | 765 | if $REMOVE_PKG; then 766 | for pkgrm in ${pkgremove[@]}; do 767 | warning "Installed package conflicts with requirements" 768 | sudo apt-get remove "$pkgrm" 769 | done 770 | fi 771 | 772 | for pkgdep in ${coredeplist[@]}; do 773 | if apt_pkg_req "$pkgdep"; then 774 | apt_pkg_install "$pkgdep" 775 | fi 776 | done 777 | 778 | for pkgdep in ${pythondep[@]}; do 779 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ]; then 780 | if apt_pkg_req "python-$pkgdep"; then 781 | apt_pkg_install "python-$pkgdep" 782 | fi 783 | fi 784 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ]; then 785 | if apt_pkg_req "python3-$pkgdep"; then 786 | apt_pkg_install "python3-$pkgdep" 787 | fi 788 | fi 789 | done 790 | 791 | if [ $pipoverride != "yes" ] && [ $debpackage != "na" ]; then 792 | newline 793 | if [ $pip2support != "yes" ] && [ $pip3support != "yes" ]; then 794 | apt_deb_install "$debpackage" 795 | fi 796 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ]; then 797 | apt_deb_install "python-$debpackage" 798 | if ! apt_pkg_req "python-$debpackage" &> /dev/null; then 799 | sudo $PIP2_BIN uninstall -y "$piplibname" &> /dev/null 800 | fi 801 | fi 802 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ]; then 803 | apt_deb_install "python3-$debpackage" 804 | if ! apt_pkg_req "python3-$debpackage" &> /dev/null; then 805 | sudo $PIP3_BIN uninstall -y "$piplibname" &> /dev/null 806 | fi 807 | fi 808 | if apt_pkg_req "python-$debpackage" &> /dev/null || apt_pkg_req "python3-$debpackage" &> /dev/null; then 809 | debpackage="na" 810 | fi 811 | else 812 | debpackage="na" 813 | fi 814 | 815 | # pypi repo install 816 | 817 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ] && apt_pkg_req "python-$debpackage" &> /dev/null; then 818 | if [ $piplibname != "na" ] && [ $debpackage == "na" ]; then 819 | newline && echo "Installing $productname library for Python 2..." && newline 820 | if ! sudo -H $PIP2_BIN install --upgrade "$piplibname"; then 821 | warning "Python 2 library install failed!" 822 | echo "If problems persist, visit forums.pimoroni.com for support" 823 | exit 1 824 | fi 825 | fi 826 | fi 827 | 828 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ] && apt_pkg_req "python3-$debpackage" &> /dev/null; then 829 | if [ $piplibname != "na" ] && [ $debpackage == "na" ]; then 830 | newline && echo "Installing $productname library for Python 3..." && newline 831 | if ! sudo -H $PIP3_BIN install --upgrade "$piplibname"; then 832 | warning "Python 3 library install failed!" 833 | echo "If problems persist, visit forums.pimoroni.com for support" 834 | exit 1 835 | fi 836 | fi 837 | fi 838 | 839 | # git repo install 840 | 841 | if [ $gitrepoclone == "yes" ]; then 842 | if ! command -v git > /dev/null; then 843 | apt_pkg_install git 844 | fi 845 | if [ $gitclonedir == "source" ]; then 846 | gitclonedir=$gitreponame 847 | fi 848 | if [ $repoclean == "yes" ]; then 849 | rm -Rf $installdir/$gitclonedir 850 | fi 851 | if [ -d $installdir/$gitclonedir ]; then 852 | newline && echo "Github repo already present. Updating..." 853 | cd $installdir/$gitclonedir && git pull 854 | else 855 | newline && echo "Cloning Github repo locally..." 856 | cd $installdir 857 | if [ $debugmode != "no" ]; then 858 | echo "git user name is $gitusername" 859 | echo "git repo name is $gitreponame" 860 | fi 861 | if [ $gitrepobranch != "master" ]; then 862 | git clone https://github.com/$gitusername/$gitreponame $gitclonedir -b $gitrepobranch 863 | else 864 | git clone --depth=1 https://github.com/$gitusername/$gitreponame $gitclonedir 865 | fi 866 | fi 867 | fi 868 | 869 | if [ $repoinstall == "yes" ]; then 870 | newline && echo "Installing library..." && newline 871 | cd $installdir/$gitreponame/$libdir 872 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ]; then 873 | sudo python2 ./setup.py install 874 | fi 875 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ]; then 876 | sudo python3 ./setup.py install 877 | fi 878 | newline 879 | fi 880 | 881 | # additional install 882 | 883 | if ! $MIN_INSTALL; then 884 | echo -e "\nChecking for additional software..." 885 | for moredep in ${examplesdep[@]}; do 886 | if [ -f "$(which python2)" ] && apt_pkg_req "python-$moredep"; then 887 | if ! apt_pkg_install "python-$moredep"; then 888 | sudo -H $PIP2_BIN install "$moredep" 889 | if pip2_lib_req "$moredep"; then 890 | FAILED_PKG=true 891 | fi 892 | fi 893 | fi 894 | if [ -f "$(which python3)" ] && apt_pkg_req "python3-$moredep"; then 895 | if ! apt_pkg_install "python3-$moredep"; then 896 | sudo -H $PIP3_BIN install "$moredep" 897 | if pip3_lib_req "$moredep"; then 898 | FAILED_PKG=true 899 | fi 900 | fi 901 | fi 902 | done 903 | for pipdep in ${pipdeplist[@]}; do 904 | if [ -f "$(which python2)" ] && pip2_lib_req "$pipdep"; then 905 | sudo -H $PIP2_BIN install "$pipdep" 906 | fi 907 | if [ -f "$(which python3)" ] && pip3_lib_req "$pipdep"; then 908 | sudo -H $PIP3_BIN install "$pipdep" 909 | fi 910 | done 911 | for moredep in ${somemoredep[@]}; do 912 | if apt_pkg_req "$moredep"; then 913 | apt_pkg_install "$moredep" 914 | fi 915 | done 916 | if [ -n "$DISPLAY" ]; then 917 | for x11dep in ${xdisplaydep[@]}; do 918 | if apt_pkg_req "$x11dep"; then 919 | apt_pkg_install "$x11dep" 920 | fi 921 | done 922 | fi 923 | fi 924 | 925 | # resources install 926 | 927 | if ! $MIN_INSTALL && [ -n "$copydir" ]; then 928 | if ! command -v git > /dev/null; then 929 | apt_pkg_install git 930 | fi 931 | echo -e "\nDownloading examples and documentation..." 932 | TMPDIR=`mktemp -d /tmp/pimoroni.XXXXXX` 933 | cd $TMPDIR 934 | if [ $copyhead != "yes" ]; then 935 | GITTAG=$(git ls-remote -t https://github.com/$gitusername/$gitreponame v\?.?.? | tail -n 1 | rev | cut -c -6 | rev) 936 | fi 937 | if [ -n "$GITTAG" ]; then 938 | git clone https://github.com/$gitusername/$gitreponame -b $GITTAG &> /dev/null 939 | else 940 | git clone --depth=1 https://github.com/$gitusername/$gitreponame &> /dev/null 941 | fi 942 | cd $installdir 943 | for repodir in ${copydir[@]}; do 944 | if [ -d $repodir ] && [ $repodir != "documentation" ]; then 945 | newline 946 | if [ -d $installdir/$repodir-backup ]; then 947 | rm -R $installdir/$repodir-old &> /dev/null 948 | mv $installdir/$repodir-backup $installdir/$repodir-old &> /dev/null 949 | fi 950 | mv $installdir/$repodir $installdir/$repodir-backup &> /dev/null 951 | if [ $gitrepotop != "root" ]; then 952 | cp -R $TMPDIR/$gitreponame/$gitrepotop/$repodir $installdir/$repodir &> /dev/null 953 | else 954 | cp -R $TMPDIR/$gitreponame/$repodir $installdir/$repodir &> /dev/null 955 | fi 956 | inform "The $repodir directory already exists on your system!" 957 | echo -e "We've backed them up as $repodir-backup, just in case you've changed anything!\n" 958 | else 959 | rm -R $installdir/$repodir &> /dev/null 960 | if [ $gitrepotop != "root" ]; then 961 | cp -R $TMPDIR/$gitreponame/$gitrepotop/$repodir $installdir/$repodir &> /dev/null 962 | else 963 | cp -R $TMPDIR/$gitreponame/$repodir $installdir/$repodir &> /dev/null 964 | fi 965 | fi 966 | done 967 | echo "Resources for your $productname were copied to" 968 | inform "$installdir" 969 | rm -rf $TMPDIR 970 | fi 971 | 972 | # script custom routines 973 | 974 | if [ $customcmd == "no" ]; then 975 | if [ -n "$pkgremove" ]; then 976 | echo -e "\nFinalising Install...\n" 977 | sysclean && newline 978 | fi 979 | echo -e "\nAll done. Enjoy your $productname!\n" 980 | else # custom block starts here 981 | echo -e "\nFinalising Install...\n" 982 | # place all custom commands in this scope 983 | fi 984 | 985 | if $FAILED_PKG; then 986 | warning "\nSome packages could not be installed, review the output for details!\n" 987 | fi 988 | 989 | if [ "$FORCE" != '-y' ]; then 990 | if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then 991 | sysreboot && newline 992 | fi 993 | fi 994 | else 995 | echo -e "\nAborting...\n" 996 | fi 997 | 998 | exit 0 999 | -------------------------------------------------------------------------------- /installers/as7262: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="AS7262 Breakout" # the name of the product to install 25 | scriptname="as7262" # the name of this script 26 | spacereq=50 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="no" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="no" # whether to execute commands specified before exit 34 | gpioreq="no" # whether low-level gpio access is required 35 | i2creq="yes" # whether the i2c interface is required 36 | i2sreq="no" # whether the i2s interface is required 37 | spireq="no" # whether the spi interface is required 38 | uartreq="no" # whether uart communication is required 39 | armhfonly="yes" # whether the script is allowed to run on other arch 40 | armv6="yes" # whether armv6 processors are supported 41 | armv7="yes" # whether armv7 processors are supported 42 | armv8="yes" # whether armv8 processors are supported 43 | raspbianonly="no" # whether the script is allowed to run on other OSes 44 | osreleases=( "Raspbian" ) # list os-releases supported 45 | oswarning=( "Kano" "Mate" "PiTop" "RetroPie" ) # list experimental os-releases 46 | osdeny=( "Darwin" "Debian" "Kali" "Linaro" "OSMC" "Ubuntu" "Volumio" ) # list os-releases specifically disallowed 47 | debpackage="na" # the name of the package in apt repo 48 | piplibname="as7262" # the name of the lib in pip repo 49 | pipoverride="yes" # whether the script should give priority to pip repo 50 | pip2support="no" # whether python2 is supported 51 | pip3support="yes" # whether python3 is supported 52 | topdir="Pimoroni" # the name of the top level directory 53 | localdir="as7262" # the name of the dir for copy of resources 54 | gitreponame="as7262-python" # the name of the git project repo 55 | gitusername="pimoroni" # the name of the git user to fetch repo from 56 | gitrepobranch="master" # repo branch to checkout 57 | gitrepotop="root" # the name of the dir to base repo from 58 | gitrepoclone="no" # whether the git repo is to be cloned locally 59 | gitclonedir="source" # the name of the local dir for repo 60 | repoclean="no" # whether any git repo clone found should be cleaned up 61 | repoinstall="no" # whether the library should be installed from repo 62 | libdir="library" # subdirectory of library in repo 63 | copydir=( "examples" ) # subdirectories to copy from repo 64 | copyhead="no" # whether to use the latest repo commit or release tag 65 | pkgremove=() # list of conflicting packages to remove 66 | coredeplist=() # list of core dependencies 67 | pythondep=() # list of python dependencies 68 | pipdeplist=() # list of dependencies to source from pypi 69 | examplesdep=() # list of python modules required by examples 70 | somemoredep=() # list of additional dependencies 71 | xdisplaydep=() # list of dependencies requiring X server 72 | 73 | # template 1712181300 74 | 75 | FORCE=$1 76 | ASK_TO_REBOOT=false 77 | CURRENT_SETTING=false 78 | MIN_INSTALL=false 79 | FAILED_PKG=false 80 | REMOVE_PKG=false 81 | UPDATE_DB=false 82 | 83 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 84 | BOOTCMD=/boot/cmdline.txt 85 | CONFIG=/boot/config.txt 86 | DTBODIR=/boot/overlays 87 | APTSRC=/etc/apt/sources.list 88 | INITABCONF=/etc/inittab 89 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 90 | LOADMOD=/etc/modules 91 | 92 | RASPOOL="http://mirrordirector.raspbian.org/raspbian/pool" 93 | RPIPOOL="http://archive.raspberrypi.org/debian/pool" 94 | DEBPOOL="http://ftp.debian.org/debian/pool" 95 | GETPOOL="https://get.pimoroni.com" 96 | 97 | SMBUS2="python-smbus_3.1.1+svn-2_armhf.deb" 98 | SMBUS3="python3-smbus_3.1.1+svn-2_armhf.deb" 99 | SMBUS35="python3-smbus1_1.1+35dbg-1_armhf.deb" 100 | 101 | SPIDEV2="python-spidev_2.0~git20150907_armhf.deb" 102 | SPIDEV3="python3-spidev_2.0~git20150907_armhf.deb" 103 | 104 | RPIGPIO1="raspi-gpio_0.20170105_armhf.deb" 105 | RPIGPIO2="python-rpi.gpio_0.6.3~jessie-1_armhf.deb" 106 | RPIGPIO3="python3-rpi.gpio_0.6.3~jessie-1_armhf.deb" 107 | 108 | export PIP_FORMAT=columns 109 | 110 | # function define 111 | 112 | confirm() { 113 | if [ "$FORCE" == '-y' ]; then 114 | true 115 | else 116 | read -r -p "$1 [y/N] " response < /dev/tty 117 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 118 | true 119 | else 120 | false 121 | fi 122 | fi 123 | } 124 | 125 | prompt() { 126 | read -r -p "$1 [y/N] " response < /dev/tty 127 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 128 | true 129 | else 130 | false 131 | fi 132 | } 133 | 134 | success() { 135 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 136 | } 137 | 138 | inform() { 139 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 140 | } 141 | 142 | warning() { 143 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 144 | } 145 | 146 | newline() { 147 | echo "" 148 | } 149 | 150 | progress() { 151 | count=0 152 | until [ $count -eq 7 ]; do 153 | echo -n "..." && sleep 1 154 | ((count++)) 155 | done; 156 | if ps -C $1 > /dev/null; then 157 | echo -en "\r\e[K" && progress $1 158 | fi 159 | } 160 | 161 | sudocheck() { 162 | if [ $(id -u) -ne 0 ]; then 163 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 164 | exit 1 165 | fi 166 | } 167 | 168 | sysclean() { 169 | sudo apt-get clean && sudo apt-get autoclean 170 | sudo apt-get -y autoremove &> /dev/null 171 | } 172 | 173 | sysupdate() { 174 | if ! $UPDATE_DB; then 175 | echo "Updating apt indexes..." && progress apt-get & 176 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 177 | sleep 3 && UPDATE_DB=true 178 | fi 179 | } 180 | 181 | sysupgrade() { 182 | sudo apt-get upgrade 183 | sudo apt-get clean && sudo apt-get autoclean 184 | sudo apt-get -y autoremove &> /dev/null 185 | } 186 | 187 | sysreboot() { 188 | warning "Some changes made to your system require" 189 | warning "your computer to reboot to take effect." 190 | echo 191 | if prompt "Would you like to reboot now?"; then 192 | sync && sudo reboot 193 | fi 194 | } 195 | 196 | home_dir() { 197 | if [ $EUID -ne 0 ]; then 198 | USER_HOME=$(getent passwd $USER | cut -d: -f6) 199 | else 200 | warning "Running as root, please log in as a regular user with sudo rights!" 201 | echo && exit 1 202 | fi 203 | } 204 | 205 | space_chk() { 206 | if command -v stat > /dev/null; then 207 | if [ $spacereq -gt $(($(stat -f -c "%a*%S" /)/10**6)) ];then 208 | echo 209 | warning "There is not enough space left to proceed with installation" 210 | if confirm "Would you like to attempt to expand your filesystem?"; then 211 | curl -sS $GETPOOL/expandfs | sudo bash && exit 1 212 | else 213 | echo && exit 1 214 | fi 215 | fi 216 | fi 217 | } 218 | 219 | timestamp() { 220 | date +%Y%m%d-%H%M 221 | } 222 | 223 | check_network() { 224 | sudo ping -q -w 10 -c 1 1.1.1.1 | grep "received, 0" &> /dev/null 225 | if [ $? -eq 0 ]; then 226 | return 0 227 | else 228 | sudo ping -q -w 10 -c 1 8.8.8.8 | grep "received, 0" &> /dev/null 229 | if [ $? -eq 0 ]; then 230 | return 0 231 | fi 232 | fi 233 | return 1 234 | } 235 | 236 | launch_url() { 237 | check_network || (error_box "You don't appear to be connected to the internet, please check your connection and try again!" && exit 1) 238 | if command -v xdg-open > /dev/null; then 239 | xdg-open "$1" && return 0 240 | else 241 | error_box "There was an error attempting to launch your browser!" 242 | fi 243 | } 244 | 245 | get_install() { 246 | check_network || (error_box "You don't appear to be connected to the internet, please check your connection and try again!" && exit 1) 247 | if [ "$1" != diagnostic ];then 248 | sysupdate && UPDATE_DB=true 249 | fi 250 | if ! command -v curl > /dev/null; then 251 | apt_pkg_install "curl" 252 | fi 253 | curl -sS https://get.pimoroni.com/$1 | bash -s - "-y" $2 254 | read -p "Press Enter to continue..." < /dev/tty 255 | } 256 | 257 | apt_pkg_req() { 258 | APT_CHK=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "install ok installed") 259 | 260 | if [ "" == "$APT_CHK" ]; then 261 | echo "$1 is required" 262 | true 263 | else 264 | echo "$1 is already installed" 265 | false 266 | fi 267 | } 268 | 269 | apt_pkg_install() { 270 | echo "Installing $1..." 271 | sudo apt-get --yes install "$1" 1> /dev/null || { inform "Apt failed to install $1!\nFalling back on pypi..." && return 1; } 272 | } 273 | 274 | apt_deb_chk() { 275 | BEFORE=$(dpkg-query -W "$1" 2> /dev/null) 276 | sudo apt-get --yes install "$1" &> /dev/null || return 1 277 | AFTER=$(dpkg-query -W "$1" 2> /dev/null) 278 | if [ "$BEFORE" == "$AFTER" ]; then 279 | echo "$1 is already the newest version" 280 | else 281 | echo "$1 was successfully upgraded" 282 | fi 283 | } 284 | 285 | apt_deb_install() { 286 | echo "Installing $1..." 287 | if [[ "$1" != *".deb"* ]]; then 288 | sudo apt-get --yes install "$1" &> /dev/null || inform "Apt failed to install $1!\nFalling back on pypi..." 289 | dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "install ok installed" 290 | else 291 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` 292 | cd $DEBDIR 293 | wget "$GETPOOL/resources/$1" &> /dev/null 294 | sudo dpkg -i "$DEBDIR/$1" | grep "Installing $1" 295 | fi 296 | } 297 | 298 | pip_cmd_chk() { 299 | if command -v pip2 > /dev/null; then 300 | PIP2_BIN="pip2" 301 | elif command -v pip-2.7 > /dev/null; then 302 | PIP2_BIN="pip-2.7" 303 | elif command -v pip-2.6 > /dev/null; then 304 | PIP2_BIN="pip-2.6" 305 | else 306 | PIP2_BIN="pip" 307 | fi 308 | if command -v pip3 > /dev/null; then 309 | PIP3_BIN="pip3" 310 | elif command -v pip-3.3 > /dev/null; then 311 | PIP3_BIN="pip-3.3" 312 | elif command -v pip-3.2 > /dev/null; then 313 | PIP3_BIN="pip-3.2" 314 | fi 315 | } 316 | 317 | pip2_lib_req() { 318 | PIP2_CHK=$($PIP2_BIN list 2> /dev/null | grep -i "$1") 319 | 320 | if [ -z "$PIP2_CHK" ]; then 321 | true 322 | else 323 | false 324 | fi 325 | } 326 | 327 | pip3_lib_req() { 328 | PIP3_CHK=$($PIP3_BIN list 2> /dev/null | grep -i "$1") 329 | 330 | if [ -z "$PIP3_CHK" ]; then 331 | true 332 | else 333 | false 334 | fi 335 | } 336 | 337 | usb_max_power() { 338 | if grep -q "^max_usb_current=1$" $CONFIG; then 339 | echo -e "\nMax USB current setting already active" 340 | else 341 | echo -e "\nAdjusting USB current setting in $CONFIG" 342 | echo "max_usb_current=1" | sudo tee -a $CONFIG &> /dev/null 343 | fi 344 | } 345 | 346 | add_dtoverlay() { 347 | if grep -q "^dtoverlay=$1" $CONFIG; then 348 | echo -e "\n$1 overlay already active" 349 | elif grep -q "^#dtoverlay=$1" $CONFIG; then 350 | sudo sed -i "/^#dtoverlay=$1$/ s|#||" $CONFIG 351 | echo -e "\nAdding $1 overlay to $CONFIG" 352 | ASK_TO_REBOOT=true 353 | else 354 | echo "dtoverlay=$1" | sudo tee -a $CONFIG &> /dev/null 355 | echo -e "\nAdding $1 overlay to $CONFIG" 356 | ASK_TO_REBOOT=true 357 | fi 358 | } 359 | 360 | remove_dtoverlay() { 361 | sudo sed -i "/^dtoverlay=$1$/ s|^|#|" $CONFIG 362 | ASK_TO_REBOOT=true 363 | } 364 | 365 | enable_pi_audio() { 366 | if grep -q "#dtparam=audio=on" $CONFIG; then 367 | sudo sed -i "/^#dtparam=audio=on$/ s|#||" $CONFIG 368 | echo -e "\nsnd_bcm2835 loaded (on-board audio enabled)" 369 | ASK_TO_REBOOT=true 370 | fi 371 | } 372 | 373 | disable_pi_audio() { 374 | if grep -q "^dtparam=audio=on" $CONFIG; then 375 | sudo sed -i "/^dtparam=audio=on$/ s|^|#|" $CONFIG 376 | echo -e "\nsnd_bcm2835 unloaded (on-board audio disabled)" 377 | ASK_TO_REBOOT=true 378 | fi 379 | } 380 | 381 | test_audio() { 382 | echo 383 | if confirm "Do you wish to test your system now?"; then 384 | echo -e "\nTesting..." 385 | speaker-test -l5 -c2 -t wav 386 | fi 387 | } 388 | 389 | disable_pulseaudio() { 390 | sudo mv /etc/xdg/autostart/pulseaudio.desktop /etc/xdg/autostart/pulseaudio.disabled &> /dev/null 391 | pulseaudio -k &> /dev/null 392 | } 393 | 394 | kill_volumealsa() { 395 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE/panels/panel &> /dev/null 396 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE-pi/panels/panel &> /dev/null 397 | } 398 | 399 | basic_asound() { 400 | sudo echo -e "pcm.\041default {\n type hw\n card 1\n}" > $HOME/.asoundrc 401 | sudo echo -e "ctl.\041default {\n type hw\n card 1\n}" >> $HOME/.asoundrc 402 | sudo mv $HOME/.asoundrc /etc/asound.conf 403 | } 404 | 405 | config_set() { 406 | if [ -n $defaultconf ]; then 407 | sudo sed -i "s|$1=.*$|$1=$2|" $defaultconf 408 | else 409 | sudo sed -i "s|$1=.*$|$1=$2|" $3 410 | fi 411 | } 412 | 413 | servd_trig() { 414 | if command -v service > /dev/null; then 415 | sudo service $1 $2 416 | fi 417 | } 418 | 419 | get_init_sys() { 420 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 421 | SYSTEMD=1 422 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 423 | SYSTEMD=0 424 | else 425 | echo "Unrecognised init system" && exit 1 426 | fi 427 | } 428 | 429 | i2c_vc_dtparam() { 430 | if [ -e $CONFIG ] && grep -q "^dtparam=i2c_vc=on$" $CONFIG; then 431 | echo -e "\ni2c0 bus already active" 432 | else 433 | echo -e "\nEnabling i2c0 bus in $CONFIG" 434 | echo "dtparam=i2c_vc=on" | sudo tee -a $CONFIG && echo 435 | fi 436 | } 437 | 438 | : <<'MAINSTART' 439 | 440 | Perform all variables declarations as well as function definition 441 | above this section for clarity, thanks! 442 | 443 | MAINSTART 444 | 445 | # intro message 446 | 447 | if [ $debugmode != "no" ]; then 448 | if [ $debuguser != "none" ]; then 449 | gitusername="$debuguser" 450 | fi 451 | if [ $debugpoint != "none" ]; then 452 | gitrepobranch="$debugpoint" 453 | fi 454 | inform "\nDEBUG MODE ENABLED" 455 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 456 | else 457 | echo -e "\nThis script will install everything needed to use\n$productname" 458 | if [ "$FORCE" != '-y' ]; then 459 | inform "\nAlways be careful when running scripts and commands copied" 460 | inform "from the internet. Ensure they are from a trusted source.\n" 461 | warning "This script should -- only be run on a Raspberry Pi with RPi OS --" 462 | warning "other systems and SBCs are not supported and may explode!\n" 463 | echo -e "If you want to see what this script does before running it," 464 | echo -e "you should run: 'curl $GETPOOL/$scriptname'\n" 465 | fi 466 | fi 467 | 468 | # checks and init 469 | space_chk 470 | home_dir 471 | 472 | if [ $debugmode != "no" ]; then 473 | echo "USER_HOME is $USER_HOME" 474 | echo "OS_NAME is $OS_NAME" 475 | echo 476 | fi 477 | 478 | if [ $forcesudo == "yes" ]; then 479 | sudocheck 480 | fi 481 | 482 | if [ $uartreq == "yes" ]; then 483 | echo "Note: $productname requires UART communication" 484 | warning "The serial console will be disabled if you proceed!" 485 | fi 486 | if [ $spireq == "yes" ]; then 487 | echo -e "Note: $productname requires SPI communication" 488 | fi 489 | if [ $i2creq == "yes" ]; then 490 | echo -e "Note: $productname requires I2C communication" 491 | fi 492 | if [ $i2sreq == "yes" ]; then 493 | echo -e "Note: $productname uses the I2S interface" 494 | if [ $OS_NAME != "Volumio" ]; then 495 | warning "The on-board audio chip will be disabled if you proceed!" 496 | fi 497 | fi 498 | 499 | newline 500 | if confirm "Do you wish to continue?"; then 501 | 502 | # basic environment preparation 503 | 504 | echo -e "\nChecking environment..." 505 | 506 | if [ "$FORCE" != '-y' ]; then 507 | if ! check_network; then 508 | warning "We can't connect to the Internet, check your network!" && exit 1 509 | fi 510 | sysupdate && newline 511 | fi 512 | 513 | if apt_pkg_req "apt-utils" &> /dev/null; then 514 | apt_pkg_install "apt-utils" 515 | fi 516 | if ! command -v curl > /dev/null; then 517 | apt_pkg_install "curl" 518 | fi 519 | if ! command -v wget > /dev/null; then 520 | apt_pkg_install "wget" 521 | fi 522 | 523 | if [ "$pip2support" == "yes" ]; then 524 | if ! [ -f "$(which python2)" ]; then 525 | if confirm "Python 2 is not installed. Would like to install it?"; then 526 | progress apt-get & 527 | apt_pkg_install "python-pip" 528 | else 529 | pip2support="na" 530 | fi 531 | elif apt_pkg_req "python-pip" &> /dev/null; then 532 | progress apt-get & 533 | apt_pkg_install "python-pip" 534 | fi 535 | fi 536 | if [ "$pip3support" == "yes" ]; then 537 | if ! [ -f "$(which python3)" ]; then 538 | if prompt "Python 3 is not installed. Would like to install it?"; then 539 | progress apt-get & 540 | apt_pkg_install "python3-pip" 541 | else 542 | pip3support="na" 543 | fi 544 | elif apt_pkg_req "python3-pip" &> /dev/null; then 545 | progress apt-get & 546 | apt_pkg_install "python3-pip" 547 | fi 548 | fi 549 | pip_cmd_chk 550 | 551 | # hardware setup 552 | 553 | echo -e "\nChecking hardware requirements..." 554 | 555 | if [ $uartreq == "yes" ]; then 556 | echo -e "\nThe serial console must be disabled for $productname to work" 557 | curl -sS $GETPOOL/uarton | sudo bash -s - "-y" && ASK_TO_REBOOT=true 558 | fi 559 | 560 | if [ $gpioreq == "yes" ]; then 561 | echo -e "\nChecking for packages required for GPIO control..." 562 | if ! apt_pkg_install "raspi-gpio" &> /dev/null; then 563 | echo "package raspi-gpio can't be found, fetching from alternative location..." 564 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 565 | wget $RPIPOOL/main/r/raspi-gpio/$RPIGPIO1 &> /dev/null 566 | sudo dpkg -i $DEBDIR/$RPIGPIO1 && FAILED_PKG=false 567 | fi 568 | if [ "$pip2support" == "yes" ] && ! apt_pkg_install "python-rpi.gpio" &> /dev/null; then 569 | if [ -n $(python --version 2>&1 | grep -q "2.7") ]; then 570 | echo "package python-rpi.gpio can't be found, fetching from alternative location..." 571 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 572 | wget $RPIPOOL/main/r/rpi.gpio/$RPIGPIO2 &> /dev/null 573 | sudo dpkg -i $DEBDIR/$RPIGPIO2 && FAILED_PKG=false 574 | else 575 | sudo $PIP2_BIN install RPi.GPIO && FAILED_PKG=false 576 | fi 577 | fi 578 | if [ "$pip3support" == "yes" ] && ! apt_pkg_install "python3-rpi.gpio" &> /dev/null; then 579 | if [ -n $(python3 --version 2>&1 | grep -q "3.4") ]; then 580 | echo "package python3-rpi.gpio can't be found, fetching from alternative location..." 581 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 582 | wget $RPIPOOL/main/r/rpi.gpio/$RPIGPIO3 &> /dev/null 583 | sudo dpkg -i $DEBDIR/$RPIGPIO3 && FAILED_PKG=false 584 | else 585 | sudo $PIP3_BIN install RPi.GPIO && FAILED_PKG=false 586 | fi 587 | fi 588 | if [ "$pip2support" == "yes" ] && [ -f "$(which python2)" ]; then 589 | if ! $PIP2_BIN list | grep "RPi.GPIO" &> /dev/null; then 590 | warning "Unable to install RPi.GPIO for python 2!" && FAILED_PKG=true 591 | else 592 | RPIGPIO2="install ok installed" 593 | fi 594 | fi 595 | if [ "$pip3support" == "yes" ] && [ -f "$(which python3)" ]; then 596 | if ! $PIP3_BIN list | grep "RPi.GPIO" &> /dev/null; then 597 | warning "Unable to install RPi.GPIO for python 3!" && FAILED_PKG=true 598 | else 599 | RPIGPIO3="install ok installed" 600 | fi 601 | fi 602 | if [ "$RPIGPIO2" == "install ok installed" ] || [ "$RPIGPIO3" == "install ok installed" ]; then 603 | if ! $FAILED_PKG; then 604 | echo -e "RPi.GPIO installed and up-to-date" 605 | fi 606 | fi 607 | fi 608 | 609 | if [ $spireq == "yes" ]; then 610 | newline 611 | if ls /dev/spi* &> /dev/null; then 612 | inform "SPI already enabled" 613 | else 614 | echo "SPI must be enabled for $productname to work" 615 | if command -v raspi-config > /dev/null && sudo raspi-config nonint get_spi | grep -q "1"; then 616 | sudo raspi-config nonint do_spi 0 617 | inform "SPI is now enabled" 618 | else 619 | curl -sS $GETPOOL/spi | sudo bash -s - "-y" && ASK_TO_REBOOT=true 620 | fi 621 | fi 622 | echo -e "\nChecking packages required by SPI interface..." 623 | if [ "$pip2support" == "yes" ] && ! apt_pkg_install "python-spidev" &> /dev/null; then 624 | if [ -n $(python --version 2>&1 | grep -q "2.7") ]; then 625 | echo "package python-spidev can't be found, fetching from alternative location..." 626 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 627 | wget $RPIPOOL/main/s/spidev/$SPIDEV2 &> /dev/null 628 | sudo dpkg -i $DEBDIR/$SPIDEV2 && FAILED_PKG=false 629 | else 630 | sudo $PIP2_BIN install spidev && FAILED_PKG=false 631 | fi 632 | fi 633 | if [ "$pip3support" == "yes" ] && ! apt_pkg_install "python3-spidev" &> /dev/null; then 634 | if [ -n $(python3 --version 2>&1 | grep -q "3.4") ]; then 635 | echo "package python3-spidev can't be found, fetching from alternative location..." 636 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 637 | wget $RPIPOOL/main/s/spidev/$SPIDEV3 &> /dev/null 638 | sudo dpkg -i $DEBDIR/$SPIDEV3 && FAILED_PKG=false 639 | else 640 | sudo $PIP3_BIN install spidev && FAILED_PKG=false 641 | fi 642 | fi 643 | if [ "$pip2support" == "yes" ] && [ -f "$(which python2)" ]; then 644 | if ! $PIP2_BIN list | grep "spidev" &> /dev/null; then 645 | warning "Unable to install spidev for python 2!" && FAILED_PKG=true 646 | else 647 | SPIDEV2="install ok installed" 648 | fi 649 | fi 650 | if [ "$pip3support" == "yes" ] && [ -f "$(which python3)" ]; then 651 | if ! $PIP3_BIN list | grep "spidev" &> /dev/null; then 652 | warning "Unable to install spidev for python 3!" && FAILED_PKG=true 653 | else 654 | SPIDEV3="install ok installed" 655 | fi 656 | fi 657 | if [ "$SPIDEV2" == "install ok installed" ] || [ "$SPIDEV3" == "install ok installed" ]; then 658 | if ! $FAILED_PKG; then 659 | echo -e "spidev installed and up-to-date" 660 | fi 661 | fi 662 | fi 663 | 664 | if [ $i2creq == "yes" ]; then 665 | newline 666 | if ls /dev/i2c* &> /dev/null; then 667 | inform "I2C already enabled" 668 | else 669 | echo "I2C must be enabled for $productname to work" 670 | if command -v raspi-config > /dev/null && sudo raspi-config nonint get_i2c | grep -q "1"; then 671 | sudo raspi-config nonint do_i2c 0 672 | inform "I2C is now enabled" 673 | else 674 | curl -sS $GETPOOL/i2c | sudo bash -s - "-y" && ASK_TO_REBOOT=true 675 | fi 676 | fi 677 | echo -e "\nChecking packages required by I2C interface..." 678 | if [ "$pip2support" == "yes" ] && ! apt_pkg_install "python-smbus" &> /dev/null; then 679 | FAILED_PKG=false 680 | if [ -n $(python --version 2>&1 | grep -q "2.7") ]; then 681 | echo "package python-smbus can't be found, fetching from alternative location..." 682 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 683 | wget $RPIPOOL/main/i/i2c-tools/$SMBUS2 &> /dev/null 684 | sudo dpkg -i $DEBDIR/$SMBUS2 || FAILED_PKG=true 685 | fi 686 | if $FAILED_PKG; then 687 | warning "Unable to install smbus for python 2!" 688 | else 689 | echo -e "Python 2 smbus installed and up-to-date" 690 | fi 691 | else 692 | echo -e "Python 2 smbus installed and up-to-date" 693 | fi 694 | if [ "$pip3support" == "yes" ] && ! apt_pkg_install "python3-smbus" &> /dev/null; then 695 | FAILED_PKG=false 696 | if [ -n $(python3 --version 2>&1 | grep -q "3.4") ]; then 697 | echo "package python3-smbus can't be found, fetching from alternative location..." 698 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 699 | wget $RPIPOOL/main/i/i2c-tools/$SMBUS3 &> /dev/null 700 | sudo dpkg -i $DEBDIR/$SMBUS3 || FAILED_PKG=true 701 | elif [ -n $(python3 --version 2>&1 | grep -q "3.5") ]; then 702 | if apt_pkg_req "python3-smbus1" &> /dev/null; then 703 | echo "package python3-smbus can't be found, fetching from alternative location..." 704 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` && cd $DEBDIR 705 | wget $GETPOOL/resources/$SMBUS35 &> /dev/null 706 | sudo dpkg -i $DEBDIR/$SMBUS35 || FAILED_PKG=true 707 | fi 708 | fi 709 | if $FAILED_PKG; then 710 | warning "Unable to install smbus for python 3!" 711 | else 712 | echo -e "Python 3 smbus installed and up-to-date" 713 | fi 714 | else 715 | echo -e "Python 3 smbus installed and up-to-date" 716 | fi 717 | fi 718 | 719 | if [ $i2sreq == "yes" ]; then 720 | if [ -f /etc/asound.conf ]; then 721 | sudo rm -f /etc/asound.conf.backup &> /dev/null 722 | sudo mv /etc/asound.conf /etc/asound.conf.backup 723 | inform "existing config backed up to /etc/asound.conf.backup" 724 | fi 725 | if [ -f $HOME/.asoundrc ]; then 726 | sudo rm -f $HOME/.asoundrc.backup &> /dev/null 727 | sudo mv $HOME/.asoundrc $HOME/.asoundrc.backup 728 | inform "existing config backed up to ~/.asound.conf.backup" 729 | fi 730 | fi 731 | 732 | # minimum install routine 733 | 734 | if [ $mininstall != "yes" ] && [ $gitrepoclone != "yes" ]; then 735 | newline 736 | echo "$productname comes with examples and documentation that you may wish to install." 737 | echo "Performing a full install will ensure those resources are installed," 738 | echo "along with all required dependencies. It may however take a while!" 739 | newline 740 | if ! confirm "Do you wish to perform a full install?"; then 741 | MIN_INSTALL=true 742 | fi 743 | else 744 | MIN_INSTALL=true 745 | fi 746 | 747 | if [ $localdir != "na" ]; then 748 | installdir="$USER_HOME/$topdir/$localdir" 749 | else 750 | installdir="$USER_HOME/$topdir" 751 | fi 752 | 753 | if ! $MIN_INSTALL || [ $gitrepoclone == "yes" ]; then 754 | [ -d $installdir ] || mkdir -p $installdir 755 | fi 756 | 757 | if [ $debugmode != "no" ]; then 758 | echo "INSTALLDIR is $installdir" 759 | fi 760 | 761 | # apt repo install 762 | 763 | echo -e "\nChecking for dependencies..." 764 | 765 | if $REMOVE_PKG; then 766 | for pkgrm in ${pkgremove[@]}; do 767 | warning "Installed package conflicts with requirements" 768 | sudo apt-get remove "$pkgrm" 769 | done 770 | fi 771 | 772 | for pkgdep in ${coredeplist[@]}; do 773 | if apt_pkg_req "$pkgdep"; then 774 | apt_pkg_install "$pkgdep" 775 | fi 776 | done 777 | 778 | for pkgdep in ${pythondep[@]}; do 779 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ]; then 780 | if apt_pkg_req "python-$pkgdep"; then 781 | apt_pkg_install "python-$pkgdep" 782 | fi 783 | fi 784 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ]; then 785 | if apt_pkg_req "python3-$pkgdep"; then 786 | apt_pkg_install "python3-$pkgdep" 787 | fi 788 | fi 789 | done 790 | 791 | if [ $pipoverride != "yes" ] && [ $debpackage != "na" ]; then 792 | newline 793 | if [ $pip2support != "yes" ] && [ $pip3support != "yes" ]; then 794 | apt_deb_install "$debpackage" 795 | fi 796 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ]; then 797 | apt_deb_install "python-$debpackage" 798 | if ! apt_pkg_req "python-$debpackage" &> /dev/null; then 799 | sudo $PIP2_BIN uninstall -y "$piplibname" &> /dev/null 800 | fi 801 | fi 802 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ]; then 803 | apt_deb_install "python3-$debpackage" 804 | if ! apt_pkg_req "python3-$debpackage" &> /dev/null; then 805 | sudo $PIP3_BIN uninstall -y "$piplibname" &> /dev/null 806 | fi 807 | fi 808 | if apt_pkg_req "python-$debpackage" &> /dev/null || apt_pkg_req "python3-$debpackage" &> /dev/null; then 809 | debpackage="na" 810 | fi 811 | else 812 | debpackage="na" 813 | fi 814 | 815 | # pypi repo install 816 | 817 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ] && apt_pkg_req "python-$debpackage" &> /dev/null; then 818 | if [ $piplibname != "na" ] && [ $debpackage == "na" ]; then 819 | newline && echo "Installing $productname library for Python 2..." && newline 820 | if ! sudo -H $PIP2_BIN install --upgrade "$piplibname"; then 821 | warning "Python 2 library install failed!" 822 | echo "If problems persist, visit forums.pimoroni.com for support" 823 | exit 1 824 | fi 825 | fi 826 | fi 827 | 828 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ] && apt_pkg_req "python3-$debpackage" &> /dev/null; then 829 | if [ $piplibname != "na" ] && [ $debpackage == "na" ]; then 830 | newline && echo "Installing $productname library for Python 3..." && newline 831 | if ! sudo -H $PIP3_BIN install --upgrade "$piplibname"; then 832 | warning "Python 3 library install failed!" 833 | echo "If problems persist, visit forums.pimoroni.com for support" 834 | exit 1 835 | fi 836 | fi 837 | fi 838 | 839 | # git repo install 840 | 841 | if [ $gitrepoclone == "yes" ]; then 842 | if ! command -v git > /dev/null; then 843 | apt_pkg_install git 844 | fi 845 | if [ $gitclonedir == "source" ]; then 846 | gitclonedir=$gitreponame 847 | fi 848 | if [ $repoclean == "yes" ]; then 849 | rm -Rf $installdir/$gitclonedir 850 | fi 851 | if [ -d $installdir/$gitclonedir ]; then 852 | newline && echo "Github repo already present. Updating..." 853 | cd $installdir/$gitclonedir && git pull 854 | else 855 | newline && echo "Cloning Github repo locally..." 856 | cd $installdir 857 | if [ $debugmode != "no" ]; then 858 | echo "git user name is $gitusername" 859 | echo "git repo name is $gitreponame" 860 | fi 861 | if [ $gitrepobranch != "master" ]; then 862 | git clone https://github.com/$gitusername/$gitreponame $gitclonedir -b $gitrepobranch 863 | else 864 | git clone --depth=1 https://github.com/$gitusername/$gitreponame $gitclonedir 865 | fi 866 | fi 867 | fi 868 | 869 | if [ $repoinstall == "yes" ]; then 870 | newline && echo "Installing library..." && newline 871 | cd $installdir/$gitreponame/$libdir 872 | if [ -f "$(which python2)" ] && [ $pip2support == "yes" ]; then 873 | sudo python2 ./setup.py install 874 | fi 875 | if [ -f "$(which python3)" ] && [ $pip3support == "yes" ]; then 876 | sudo python3 ./setup.py install 877 | fi 878 | newline 879 | fi 880 | 881 | # additional install 882 | 883 | if ! $MIN_INSTALL; then 884 | echo -e "\nChecking for additional software..." 885 | for moredep in ${examplesdep[@]}; do 886 | if [ -f "$(which python2)" ] && apt_pkg_req "python-$moredep"; then 887 | if ! apt_pkg_install "python-$moredep"; then 888 | sudo -H $PIP2_BIN install "$moredep" 889 | if pip2_lib_req "$moredep"; then 890 | FAILED_PKG=true 891 | fi 892 | fi 893 | fi 894 | if [ -f "$(which python3)" ] && apt_pkg_req "python3-$moredep"; then 895 | if ! apt_pkg_install "python3-$moredep"; then 896 | sudo -H $PIP3_BIN install "$moredep" 897 | if pip3_lib_req "$moredep"; then 898 | FAILED_PKG=true 899 | fi 900 | fi 901 | fi 902 | done 903 | for pipdep in ${pipdeplist[@]}; do 904 | if [ -f "$(which python2)" ] && pip2_lib_req "$pipdep"; then 905 | sudo -H $PIP2_BIN install "$pipdep" 906 | fi 907 | if [ -f "$(which python3)" ] && pip3_lib_req "$pipdep"; then 908 | sudo -H $PIP3_BIN install "$pipdep" 909 | fi 910 | done 911 | for moredep in ${somemoredep[@]}; do 912 | if apt_pkg_req "$moredep"; then 913 | apt_pkg_install "$moredep" 914 | fi 915 | done 916 | if [ -n "$DISPLAY" ]; then 917 | for x11dep in ${xdisplaydep[@]}; do 918 | if apt_pkg_req "$x11dep"; then 919 | apt_pkg_install "$x11dep" 920 | fi 921 | done 922 | fi 923 | fi 924 | 925 | # resources install 926 | 927 | if ! $MIN_INSTALL && [ -n "$copydir" ]; then 928 | if ! command -v git > /dev/null; then 929 | apt_pkg_install git 930 | fi 931 | echo -e "\nDownloading examples and documentation..." 932 | TMPDIR=`mktemp -d /tmp/pimoroni.XXXXXX` 933 | cd $TMPDIR 934 | if [ $copyhead != "yes" ]; then 935 | GITTAG=$(git ls-remote -t https://github.com/$gitusername/$gitreponame v\?.?.? | tail -n 1 | rev | cut -c -6 | rev) 936 | fi 937 | if [ -n "$GITTAG" ]; then 938 | git clone https://github.com/$gitusername/$gitreponame -b $GITTAG &> /dev/null 939 | else 940 | git clone --depth=1 https://github.com/$gitusername/$gitreponame &> /dev/null 941 | fi 942 | cd $installdir 943 | for repodir in ${copydir[@]}; do 944 | if [ -d $repodir ] && [ $repodir != "documentation" ]; then 945 | newline 946 | if [ -d $installdir/$repodir-backup ]; then 947 | rm -R $installdir/$repodir-old &> /dev/null 948 | mv $installdir/$repodir-backup $installdir/$repodir-old &> /dev/null 949 | fi 950 | mv $installdir/$repodir $installdir/$repodir-backup &> /dev/null 951 | if [ $gitrepotop != "root" ]; then 952 | cp -R $TMPDIR/$gitreponame/$gitrepotop/$repodir $installdir/$repodir &> /dev/null 953 | else 954 | cp -R $TMPDIR/$gitreponame/$repodir $installdir/$repodir &> /dev/null 955 | fi 956 | inform "The $repodir directory already exists on your system!" 957 | echo -e "We've backed them up as $repodir-backup, just in case you've changed anything!\n" 958 | else 959 | rm -R $installdir/$repodir &> /dev/null 960 | if [ $gitrepotop != "root" ]; then 961 | cp -R $TMPDIR/$gitreponame/$gitrepotop/$repodir $installdir/$repodir &> /dev/null 962 | else 963 | cp -R $TMPDIR/$gitreponame/$repodir $installdir/$repodir &> /dev/null 964 | fi 965 | fi 966 | done 967 | echo "Resources for your $productname were copied to" 968 | inform "$installdir" 969 | rm -rf $TMPDIR 970 | fi 971 | 972 | # script custom routines 973 | 974 | if [ $customcmd == "no" ]; then 975 | if [ -n "$pkgremove" ]; then 976 | echo -e "\nFinalising Install...\n" 977 | sysclean && newline 978 | fi 979 | echo -e "\nAll done. Enjoy your $productname!\n" 980 | else # custom block starts here 981 | echo -e "\nFinalising Install...\n" 982 | # place all custom commands in this scope 983 | fi 984 | 985 | if $FAILED_PKG; then 986 | warning "\nSome packages could not be installed, review the output for details!\n" 987 | fi 988 | 989 | if [ "$FORCE" != '-y' ]; then 990 | if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then 991 | sysreboot && newline 992 | fi 993 | fi 994 | else 995 | echo -e "\nAborting...\n" 996 | fi 997 | 998 | exit 0 999 | -------------------------------------------------------------------------------- /installers/audio: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="na" # the name of the product to install 25 | scriptname="audio" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="no" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | gpioreq="no" # whether low-level gpio access is required 35 | i2creq="no" # whether the i2c interface is required 36 | i2sreq="no" # whether the i2s interface is required 37 | spireq="no" # whether the spi interface is required 38 | uartreq="no" # whether uart communication is required 39 | armhfonly="yes" # whether the script is allowed to run on other arch 40 | armv6="yes" # whether armv6 processors are supported 41 | armv7="yes" # whether armv7 processors are supported 42 | armv8="yes" # whether armv8 processors are supported 43 | raspbianonly="no" # whether the script is allowed to run on other OSes 44 | osreleases=( "Raspbian" "Kano" "Mate" "PiTop" "RetroPie" ) # list os-releases supported 45 | oswarning=( "Debian" "Ubuntu" ) # list experimental os-releases 46 | osdeny=( "Darwin" "Kali" "Linaro" "Volumio" ) # list os-releases specifically disallowed 47 | 48 | FORCE=$1 49 | ASK_TO_REBOOT=false 50 | CURRENT_SETTING=false 51 | MIN_INSTALL=false 52 | FAILED_PKG=false 53 | REMOVE_PKG=false 54 | UPDATE_DB=false 55 | 56 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 57 | BOOTCMD=/boot/cmdline.txt 58 | CONFIG=/boot/config.txt 59 | APTSRC=/etc/apt/sources.list 60 | INITABCONF=/etc/inittab 61 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 62 | LOADMOD=/etc/modules 63 | 64 | RASPOOL="http://mirrordirector.raspbian.org/raspbian/pool" 65 | RPIPOOL="http://archive.raspberrypi.org/debian/pool" 66 | DEBPOOL="http://ftp.debian.org/debian/pool" 67 | GETPOOL="https://get.pimoroni.com" 68 | 69 | # function define 70 | 71 | confirm() { 72 | if [ "$FORCE" == '-y' ]; then 73 | true 74 | else 75 | read -r -p "$1 [y/N] " response < /dev/tty 76 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 77 | true 78 | else 79 | false 80 | fi 81 | fi 82 | } 83 | 84 | prompt() { 85 | read -r -p "$1 [y/N] " response < /dev/tty 86 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 87 | true 88 | else 89 | false 90 | fi 91 | } 92 | 93 | success() { 94 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 95 | } 96 | 97 | inform() { 98 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 99 | } 100 | 101 | warning() { 102 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 103 | } 104 | 105 | newline() { 106 | echo "" 107 | } 108 | 109 | progress() { 110 | count=0 111 | until [ $count -eq 7 ]; do 112 | echo -n "..." && sleep 1 113 | ((count++)) 114 | done; 115 | if ps -C $1 > /dev/null; then 116 | echo -en "\r\e[K" && progress $1 117 | fi 118 | } 119 | 120 | sudocheck() { 121 | if [ $(id -u) -ne 0 ]; then 122 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 123 | exit 1 124 | fi 125 | } 126 | 127 | sysclean() { 128 | sudo apt-get clean && sudo apt-get autoclean 129 | sudo apt-get -y autoremove &> /dev/null 130 | } 131 | 132 | sysupdate() { 133 | if ! $UPDATE_DB; then 134 | echo "Updating apt indexes..." && progress apt-get & 135 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 136 | sleep 3 && UPDATE_DB=true 137 | fi 138 | } 139 | 140 | sysupgrade() { 141 | sudo apt-get upgrade 142 | sudo apt-get clean && sudo apt-get autoclean 143 | sudo apt-get -y autoremove &> /dev/null 144 | } 145 | 146 | sysreboot() { 147 | warning "Some changes made to your system require" 148 | warning "your computer to reboot to take effect." 149 | echo 150 | if prompt "Would you like to reboot now?"; then 151 | sync && sudo reboot 152 | fi 153 | } 154 | 155 | arch_check() { 156 | IS_ARMHF=false 157 | IS_ARMv6=false 158 | 159 | if uname -m | grep -q "armv.l"; then 160 | IS_ARMHF=true 161 | if uname -m | grep -q "armv6l"; then 162 | IS_ARMv6=true 163 | fi 164 | fi 165 | } 166 | 167 | os_check() { 168 | IS_MACOSX=false 169 | IS_RASPBIAN=false 170 | IS_SUPPORTED=false 171 | IS_EXPERIMENTAL=false 172 | OS_NAME="Unknown" 173 | 174 | if uname -s | grep -q "Darwin"; then 175 | OS_NAME="Darwin" && IS_MACOSX=true 176 | elif cat /etc/os-release | grep -q "Kali"; then 177 | OS_NAME="Kali" 178 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 179 | OS_NAME="Kano" 180 | elif whoami | grep -q "linaro"; then 181 | OS_NAME="Linaro" 182 | elif [ -d ~/.config/ubuntu-mate ];then 183 | OS_NAME="Mate" 184 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 185 | OS_NAME="PiTop" 186 | elif command -v emulationstation > /dev/null; then 187 | OS_NAME="RetroPie" 188 | elif cat /etc/os-release | grep -q "volumio"; then 189 | OS_NAME="Volumio" 190 | elif cat /etc/os-release | grep -q "Raspbian"; then 191 | OS_NAME="Raspbian" && IS_RASPBIAN=true 192 | elif cat /etc/os-release | grep -q "Debian"; then 193 | OS_NAME="Debian" 194 | elif cat /etc/os-release | grep -q "Ubuntu"; then 195 | OS_NAME="Ubuntu" 196 | fi 197 | 198 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 199 | IS_SUPPORTED=true 200 | fi 201 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 202 | IS_EXPERIMENTAL=true 203 | fi 204 | } 205 | 206 | raspbian_check() { 207 | IS_SUPPORTED=false 208 | IS_EXPERIMENTAL=false 209 | 210 | if [ -f /etc/os-release ]; then 211 | if cat /etc/os-release | grep -q "/sid"; then 212 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 213 | elif cat /etc/os-release | grep -q "bullseye"; then 214 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 215 | elif cat /etc/os-release | grep -q "buster"; then 216 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 217 | elif cat /etc/os-release | grep -q "stretch"; then 218 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 219 | elif cat /etc/os-release | grep -q "jessie"; then 220 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 221 | elif cat /etc/os-release | grep -q "wheezy"; then 222 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 223 | else 224 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 225 | fi 226 | fi 227 | } 228 | 229 | home_dir() { 230 | if [ $EUID -ne 0 ]; then 231 | if $IS_MACOSX; then 232 | USER_HOME=$(dscl . -read /Users/$USER NFSHomeDirectory | cut -d: -f2) 233 | else 234 | USER_HOME=$(getent passwd $USER | cut -d: -f6) 235 | fi 236 | else 237 | warning "Running as root, please log in as a regular user with sudo rights!" 238 | echo && exit 1 239 | fi 240 | } 241 | 242 | space_chk() { 243 | if command -v stat > /dev/null; then 244 | if [ $spacereq -gt $(($(stat -f -c "%a*%S" /)/10**6)) ];then 245 | echo 246 | warning "There is not enough space left to proceed with installation" 247 | if confirm "Would you like to attempt to expand your filesystem?"; then 248 | curl -sS $GETPOOL/expandfs | sudo bash && exit 1 249 | else 250 | echo && exit 1 251 | fi 252 | fi 253 | fi 254 | } 255 | 256 | timestamp() { 257 | date +%Y%m%d-%H%M 258 | } 259 | 260 | check_network() { 261 | sudo ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3 | head -n 1` &> /dev/null && return 0 || return 1 262 | } 263 | 264 | force_hdmi() { 265 | if [ -e $CONFIG ] && ! grep -q "^hdmi_force_hotplug=1$" $CONFIG; then 266 | if grep -q "^#hdmi_force_hotplug=1$" $CONFIG; then 267 | sudo sed -i "s|^#hdmi_force_hotplug=1|hdmi_force_hotplug=1|" $CONFIG &> /dev/null 268 | else 269 | echo "hdmi_force_hotplug=1" | sudo tee -a $CONFIG &> /dev/null 270 | fi 271 | fi 272 | } 273 | 274 | hotplug_hdmi() { 275 | if [ -e $CONFIG ] && grep -q "^hdmi_force_hotplug=1$" $CONFIG; then 276 | sudo sed -i "s|^hdmi_force_hotplug=1|#hdmi_force_hotplug=1|" $CONFIG &> /dev/null 277 | fi 278 | } 279 | 280 | add_dtoverlay() { 281 | if grep -q "^dtoverlay=$1" $CONFIG; then 282 | echo -e "\n$1 overlay already active" 283 | elif grep -q "^#dtoverlay=$1" $CONFIG; then 284 | sudo sed -i "/^#dtoverlay=$1$/ s|#||" $CONFIG 285 | echo -e "\nAdding $1 overlay to $CONFIG" 286 | ASK_TO_REBOOT=true 287 | else 288 | echo "dtoverlay=$1" | sudo tee -a $CONFIG &> /dev/null 289 | echo -e "\nAdding $1 overlay to $CONFIG" 290 | ASK_TO_REBOOT=true 291 | fi 292 | } 293 | 294 | remove_dtoverlay() { 295 | sudo sed -i "/^dtoverlay=$1$/ s|^|#|" $CONFIG 296 | ASK_TO_REBOOT=true 297 | } 298 | 299 | enable_pi_audio() { 300 | if grep -q "#dtparam=audio=on" $CONFIG; then 301 | sudo sed -i "/^#dtparam=audio=on$/ s|#||" $CONFIG 302 | echo -e "\nsnd_bcm2835 loaded (on-board audio enabled)" 303 | ASK_TO_REBOOT=true 304 | fi 305 | } 306 | 307 | disable_pi_audio() { 308 | if grep -q "^dtparam=audio=on" $CONFIG; then 309 | sudo sed -i "/^dtparam=audio=on$/ s|^|#|" $CONFIG 310 | echo -e "\nsnd_bcm2835 unloaded (on-board audio disabled)" 311 | ASK_TO_REBOOT=true 312 | fi 313 | } 314 | 315 | test_audio() { 316 | newline 317 | if confirm "Do you wish to test your system now?"; then 318 | echo -e "\nTesting..." 319 | speaker-test -l5 -c2 -t wav 320 | fi 321 | } 322 | 323 | disable_pulseaudio() { 324 | sudo mv /etc/xdg/autostart/pulseaudio.desktop /etc/xdg/autostart/pulseaudio.disabled &> /dev/null 325 | pulseaudio -k &> /dev/null 326 | } 327 | 328 | kill_volumealsa() { 329 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE/panels/panel &> /dev/null 330 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE-pi/panels/panel &> /dev/null 331 | } 332 | 333 | basic_asound() { 334 | sudo echo -e "pcm.\041default {\n type hw\n card 1\n}" > $HOME/.asoundrc 335 | sudo echo -e "ctl.\041default {\n type hw\n card 1\n}" >> $HOME/.asoundrc 336 | sudo mv $HOME/.asoundrc /etc/asound.conf 337 | } 338 | 339 | route_audio() { 340 | if [ $debugmode == "yes" ]; then 341 | warning "passed parameter is $FORCE" 342 | fi 343 | if [ "$FORCE" == '1' ]; then 344 | amixer cset numid=3 1 > /dev/null 345 | success "Audio output mode changed to Analog!" 346 | hotplug_hdmi 347 | elif [ "$FORCE" == '2' ]; then 348 | amixer cset numid=3 2 > /dev/null 349 | success "Audio output mode changed to HDMI!" 350 | hotplug_hdmi 351 | elif [ "$FORCE" == '3' ]; then 352 | amixer cset numid=3 2 > /dev/null 353 | success "Audio signal will be forcefully sent to HDMI!" 354 | force_hdmi 355 | else 356 | newline 357 | echo "Please choose an audio output mode:" && newline 358 | echo "0 : Automatic signal detection" 359 | echo "1 : Output to analogue (headphone/speaker jack)" 360 | echo "2 : Output to digital (HDMI port)" 361 | echo "3 : Force route to digital (HDMI hotplug disabled)" 362 | newline 363 | read -r -p "Enter an option [0-3]:" choice < /dev/tty 364 | if [ $debugmode == "yes" ]; then 365 | echo "User chose option $choice" 366 | fi 367 | if [[ $choice =~ ^(0|1|2)$ ]]; then 368 | amixer cset numid=3 $choice > /dev/null 369 | success "Audio output mode changed!" 370 | hotplug_hdmi 371 | elif [[ $choice =~ ^(3)$ ]]; then 372 | amixer cset numid=3 $choice > /dev/null 373 | success "Audio signal will be forcefully sent to HDMI!" 374 | force_hdmi 375 | else 376 | warning "Invalid option!" 377 | route_audio 378 | fi 379 | fi 380 | } 381 | 382 | : <<'MAINSTART' 383 | 384 | Perform all global variables declarations as well as function definition 385 | above this section for clarity, thanks! 386 | 387 | MAINSTART 388 | 389 | # intro message 390 | 391 | if [ $debugmode != "no" ]; then 392 | if [ $debuguser != "none" ]; then 393 | gitusername="$debuguser" 394 | fi 395 | if [ $debugpoint != "none" ]; then 396 | gitrepobranch="$debugpoint" 397 | fi 398 | inform "\nDEBUG MODE ENABLED" 399 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 400 | else 401 | echo -e "\nThis script will configure your Pi audio output!" 402 | if [ "$FORCE" != '-y' ]; then 403 | inform "\nAlways be careful when running scripts and commands copied" 404 | inform "from the internet. Ensure they are from a trusted source.\n" 405 | echo -e "If you want to see what this script does before running it," 406 | echo -e "you should run: 'curl $GETPOOL/$scriptname'\n" 407 | fi 408 | fi 409 | 410 | # checks and init 411 | 412 | arch_check 413 | os_check 414 | space_chk 415 | home_dir 416 | 417 | if [ $debugmode != "no" ]; then 418 | echo "USER_HOME is $USER_HOME" 419 | echo "OS_NAME is $OS_NAME" 420 | echo "IS_SUPPORTED is $IS_SUPPORTED" 421 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 422 | echo 423 | fi 424 | 425 | if ! $IS_ARMHF; then 426 | warning "This hardware is not supported, sorry!" 427 | warning "Config files have been left untouched\n" 428 | exit 1 429 | fi 430 | 431 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 432 | warning "Sorry, your CPU is not supported by this installer\n" 433 | exit 1 434 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 435 | warning "Sorry, your CPU is not supported by this installer\n" 436 | exit 1 437 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 438 | warning "Sorry, your CPU is not supported by this installer\n" 439 | exit 1 440 | fi 441 | 442 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 443 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 444 | exit 1 445 | fi 446 | 447 | if $IS_RASPBIAN; then 448 | raspbian_check 449 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 450 | warning "\n--- Warning ---\n" 451 | echo "The $productname installer" 452 | echo "does not work on this version of Raspbian." 453 | echo "Check https://github.com/$gitusername/$gitreponame" 454 | echo "for additional information and support" && echo 455 | exit 1 456 | fi 457 | fi 458 | 459 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 460 | warning "Your operating system is not supported, sorry!\n" 461 | exit 1 462 | fi 463 | 464 | if $IS_EXPERIMENTAL; then 465 | warning "Support for your operating system is experimental. Please visit" 466 | warning "forums.pimoroni.com if you experience issues with this product.\n" 467 | fi 468 | 469 | if [ $forcesudo == "yes" ]; then 470 | sudocheck 471 | fi 472 | 473 | if [ $uartreq == "yes" ]; then 474 | echo "Note: $productname requires UART communication" 475 | warning "The serial console will be disabled if you proceed!" 476 | fi 477 | if [ $spireq == "yes" ]; then 478 | echo -e "Note: $productname requires SPI communication" 479 | fi 480 | if [ $i2creq == "yes" ]; then 481 | echo -e "Note: $productname requires I2C communication" 482 | fi 483 | if [ $i2sreq == "yes" ]; then 484 | echo -e "Note: $productname uses the I2S interface" 485 | warning "The on-board audio chip will be disabled if you proceed!" 486 | fi 487 | 488 | newline 489 | if confirm "Do you wish to continue?"; then 490 | 491 | # environment preparation 492 | 493 | if [ -e $CONFIG ] && grep -q -E "^dtparam=audio=on$" $CONFIG; then 494 | bcm2835off="no" 495 | elif [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then 496 | bcm2835off="no" 497 | else 498 | bcm2835off="yes" 499 | fi 500 | 501 | if [ $bcm2835off == "no" ]; then 502 | newline 503 | route_audio 504 | if [ "$FORCE" != '-y' ] && [ "$FORCE" != '3' ]; then 505 | test_audio 506 | fi 507 | newline 508 | else 509 | newline 510 | warning "Default sound driver currently not loaded!" 511 | if confirm "Do you wish to re-enable the on-board audio?"; then 512 | enable_pi_audio 513 | remove_dtoverlay i2s-mmap 514 | remove_dtoverlay hifiberry-dac 515 | sudo rm /etc/asound.conf &> /dev/null 516 | sudo rm ~/.asound.rc &> /dev/null 517 | newline 518 | else 519 | exit 1 520 | fi 521 | fi 522 | 523 | if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then 524 | sysreboot && newline 525 | fi 526 | else 527 | newline && echo "Aborting..." && newline 528 | fi 529 | 530 | exit 0 531 | -------------------------------------------------------------------------------- /installers/diagnostic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="na" # the name of the product to install 25 | scriptname="rpihwinfo" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="no" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="no" # whether the script is allowed to run on other OSes 39 | osreleases=( "Debian" "Kali" "Linaro" "Mate" "PiTop" "OSMC" "Raspbian" "RetroPie" "Ubuntu" ) # list os-releases supported 40 | oswarning=() # list experimental os-releases 41 | osdeny=( "Darwin" ) # list os-releases specifically disallowed 42 | 43 | # setup variables 44 | 45 | FORCE=$1 46 | ASK_TO_REBOOT=false 47 | CURRENT_SETTING=false 48 | MIN_INSTALL=false 49 | FAILED_PKG=false 50 | REMOVE_PKG=false 51 | UPDATE_DB=false 52 | 53 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 54 | BOOTCMD=/boot/cmdline.txt 55 | CONFIG=/boot/config.txt 56 | APTSRC=/etc/apt/sources.list 57 | INITABCONF=/etc/inittab 58 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 59 | LOADMOD=/etc/modules 60 | 61 | # function define 62 | 63 | confirm() { 64 | if [ "$FORCE" == '-y' ]; then 65 | true 66 | else 67 | read -r -p "$1 [y/N] " response < /dev/tty 68 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 69 | true 70 | else 71 | false 72 | fi 73 | fi 74 | } 75 | 76 | prompt() { 77 | read -r -p "$1 [y/N] " response < /dev/tty 78 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 79 | true 80 | else 81 | false 82 | fi 83 | } 84 | 85 | success() { 86 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 87 | } 88 | 89 | inform() { 90 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 91 | } 92 | 93 | warning() { 94 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 95 | } 96 | 97 | newline() { 98 | echo "" 99 | } 100 | 101 | progress() { 102 | count=0 103 | until [ $count -eq 7 ]; do 104 | echo -n "..." && sleep 1 105 | ((count++)) 106 | done; 107 | if ps -C $1 > /dev/null; then 108 | echo -en "\r\e[K" && progress $1 109 | fi 110 | } 111 | 112 | sudocheck() { 113 | if [ $(id -u) -ne 0 ]; then 114 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 115 | exit 1 116 | fi 117 | } 118 | 119 | sysclean() { 120 | sudo apt-get clean && sudo apt-get autoclean 121 | sudo apt-get -y autoremove &> /dev/null 122 | } 123 | 124 | sysupdate() { 125 | if ! $UPDATE_DB; then 126 | echo "Updating apt indexes..." && progress apt-get & 127 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 128 | sleep 3 && UPDATE_DB=true 129 | fi 130 | } 131 | 132 | sysupgrade() { 133 | sudo apt-get upgrade 134 | sudo apt-get clean && sudo apt-get autoclean 135 | sudo apt-get -y autoremove &> /dev/null 136 | } 137 | 138 | sysreboot() { 139 | warning "Some changes made to your system require" 140 | warning "your computer to reboot to take effect." 141 | echo 142 | if prompt "Would you like to reboot now?"; then 143 | sync && sudo reboot 144 | fi 145 | } 146 | 147 | arch_check() { 148 | IS_ARMHF=false 149 | IS_ARMv6=false 150 | 151 | if uname -m | grep -q "armv.l"; then 152 | IS_ARMHF=true 153 | if uname -m | grep -q "armv6l"; then 154 | IS_ARMv6=true 155 | fi 156 | fi 157 | } 158 | 159 | os_check() { 160 | IS_MACOSX=false 161 | IS_RASPBIAN=false 162 | IS_SUPPORTED=false 163 | IS_EXPERIMENTAL=false 164 | OS_NAME="Unknown" 165 | 166 | if uname -s | grep -q "Darwin"; then 167 | OS_NAME="Darwin" && IS_MACOSX=true 168 | elif cat /etc/os-release | grep -q "Kali"; then 169 | OS_NAME="Kali" 170 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 171 | OS_NAME="Kano" 172 | elif whoami | grep -q "linaro"; then 173 | OS_NAME="Linaro" 174 | elif [ -d ~/.config/ubuntu-mate ];then 175 | OS_NAME="Mate" 176 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 177 | OS_NAME="PiTop" 178 | elif command -v emulationstation > /dev/null; then 179 | OS_NAME="RetroPie" 180 | elif cat /etc/os-release | grep -q "OSMC"; then 181 | OS_NAME="OSMC" 182 | elif cat /etc/os-release | grep -q "volumio"; then 183 | OS_NAME="Volumio" 184 | elif cat /etc/os-release | grep -q "Raspbian"; then 185 | OS_NAME="Raspbian" && IS_RASPBIAN=true 186 | elif cat /etc/os-release | grep -q "Debian"; then 187 | OS_NAME="Debian" 188 | elif cat /etc/os-release | grep -q "Ubuntu"; then 189 | OS_NAME="Ubuntu" 190 | fi 191 | 192 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 193 | IS_SUPPORTED=true 194 | fi 195 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 196 | IS_EXPERIMENTAL=true 197 | fi 198 | } 199 | 200 | raspbian_check() { 201 | IS_SUPPORTED=false 202 | IS_EXPERIMENTAL=false 203 | 204 | if [ -f /etc/os-release ]; then 205 | if cat /etc/os-release | grep -q "/sid"; then 206 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 207 | elif cat /etc/os-release | grep -q "bullseye"; then 208 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 209 | elif cat /etc/os-release | grep -q "buster"; then 210 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 211 | elif cat /etc/os-release | grep -q "stretch"; then 212 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 213 | elif cat /etc/os-release | grep -q "jessie"; then 214 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 215 | elif cat /etc/os-release | grep -q "wheezy"; then 216 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 217 | else 218 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 219 | fi 220 | fi 221 | } 222 | 223 | dt_check() { 224 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 225 | DEVICE_TREE=false 226 | fi 227 | } 228 | 229 | i2c_check() { 230 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 231 | CURRENT_SETTING=true 232 | else 233 | CURRENT_SETTING=false 234 | fi 235 | } 236 | 237 | spi_check() { 238 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 239 | CURRENT_SETTING=true 240 | else 241 | CURRENT_SETTING=false 242 | fi 243 | } 244 | 245 | get_init_sys() { 246 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 247 | SYSTEMD=1 248 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 249 | SYSTEMD=0 250 | else 251 | echo "Unrecognised init system" && exit 1 252 | fi 253 | } 254 | 255 | get_hw_rev() { 256 | hwrid=$(grep "^Revision" /proc/cpuinfo | rev | cut -c 2-3 | rev) 257 | if [ "$hwrid" == "00" ] || [ "$hwrid" == "01" ];then # Pi 1 258 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-4 | rev)" 259 | if [ "$hwrid" == "00" ];then 260 | hwgen="1260" # P1 261 | elif [ "$hwrid" == "01" ];then 262 | hwgen="1400" # J8 263 | fi 264 | else 265 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-6 | rev)" 266 | if [ "$hwrid" == "04" ];then # Pi 2 267 | hwgen="2400" 268 | elif [ "$hwrid" == "08" ];then # Pi 3 269 | hwgen="3401" 270 | elif [ "$hwrid" == "09" ];then # Pi 0 271 | hwgen="0400" 272 | elif [ "$hwrid" == "0c" ];then # Pi 0 W 273 | hwgen="0401" 274 | else # Unknown 275 | hwgen="0000" 276 | fi 277 | fi 278 | } 279 | 280 | : <<'MAINSTART' 281 | 282 | Perform all global variables declarations as well as function definition 283 | above this section for clarity, thanks! 284 | 285 | MAINSTART 286 | 287 | # checks and init 288 | 289 | dt_check 290 | arch_check 291 | os_check 292 | get_hw_rev 293 | 294 | if [ $debugmode != "no" ]; then 295 | echo "USER_HOME is $USER_HOME" 296 | echo "OS_NAME is $OS_NAME" 297 | echo "IS_SUPPORTED is $IS_SUPPORTED" 298 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 299 | echo 300 | fi 301 | 302 | if ! $IS_ARMHF; then 303 | warning "This hardware is not supported, sorry!" 304 | warning "Config files have been left untouched\n" 305 | exit 1 306 | fi 307 | 308 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 309 | warning "Sorry, your CPU is not supported by this installer\n" 310 | exit 1 311 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 312 | warning "Sorry, your CPU is not supported by this installer\n" 313 | exit 1 314 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 315 | warning "Sorry, your CPU is not supported by this installer\n" 316 | exit 1 317 | fi 318 | 319 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 320 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 321 | exit 1 322 | fi 323 | 324 | if $IS_RASPBIAN; then 325 | raspbian_check 326 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 327 | warning "\n--- Warning ---\n" 328 | echo "The $productname installer" 329 | echo "does not work on this version of Raspbian." 330 | echo "Check https://github.com/$gitusername/$gitreponame" 331 | echo "for additional information and support" && echo 332 | exit 1 333 | fi 334 | fi 335 | 336 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 337 | warning "Your operating system is not supported, sorry!\n" 338 | exit 1 339 | fi 340 | 341 | if $IS_EXPERIMENTAL; then 342 | warning "Support for your operating system is experimental. Please visit" 343 | warning "forums.pimoroni.com if you experience issues with this product.\n" 344 | fi 345 | 346 | if [ $forcesudo == "yes" ]; then 347 | sudocheck 348 | fi 349 | 350 | # Main routine 351 | 352 | newline 353 | 354 | if [ -f /etc/os-release ]; then 355 | cat /etc/os-release | grep "PRETTY_NAME" | cut -c14- | rev | cut -c2- | rev 356 | fi 357 | 358 | if command -v uname > /dev/null; then 359 | echo "$(uname -s) kernel $(uname -r) on $(uname -m)" 360 | fi 361 | 362 | if [ -n $hwver ] && [ $hwver != "0000" ];then 363 | case $hwver in 364 | "0002"|"0003") echo "Revision match: Pi 1 Model B Rev 1.0";; 365 | "0004"|"0005"|"0006") echo "Revision match: Pi 1 Model B Rev 2.0";; 366 | "0007"|"0008"|"0009") echo "Revision match: Pi 1 Model A 256MB";; 367 | "000d"|"000e"|"000f") echo "Revision match: Pi 1 Model B 512MB";; 368 | "0010") echo "Revision match: Pi 1 Model B+ Rev 1.0";; 369 | "0011"|"0014") echo "Revision match: Compute Module 1";; 370 | "0012"|"0015") echo "Revision match: Pi 1 Model A+";; 371 | "0013") echo "Revision match: Pi 1 Model B+ Rev 1.2";; 372 | "a01040") echo "Revision match: Pi 2 Model B Rev 1.0";; 373 | "a01041"|"a21041") echo "Revision match: Pi 2 Model B Rev 1.1";; 374 | "a22042") echo "Revision match: Pi 2 Model B Rev 1.2";; 375 | "a02082"|"a22082"|"a32082") echo "Revision match: Pi 3 Model B Rev 1.2";; 376 | "a020a0") echo "Revision match: Compute Module 3";; 377 | "900092") echo "Revision match: Pi Zero Rev 1.2";; 378 | "900093"|"920093") echo "Revision match: Pi Zero Rev 1.3";; 379 | "9000c1"|"9200c1") echo "Revision match: Pi Zero W Rev 1.1";; 380 | *) warning "Revision unmatched";; 381 | esac 382 | fi 383 | 384 | if command -v aplay > /dev/null; then 385 | newline && aplay -l | grep "card" 386 | newline 387 | fi 388 | 389 | if lsusb | grep -v "hub" &> /dev/null; then 390 | echo "Devices on $(lsusb | grep "Bus 001 Device 001" | cut -c34-)" 391 | lsusb | grep -v "hub" 392 | maxpower=$(lsusb -v 2> /dev/null | grep "MaxPower" | grep "[0-9]0mA" | cut -c13- | tr -d "[:space:]" | sed "s|mA|mA +|") 393 | if [ -n "$maxpower" ]; then 394 | echo "Estimated MaxPower $maxpower 0mA" 395 | fi 396 | if [ -e $CONFIG ] && grep -q "^max_usb_current=1$" $CONFIG; then 397 | echo "Max USB current setting is active" 398 | fi 399 | newline 400 | else 401 | echo "No USB devices found..." && newline 402 | fi 403 | 404 | if ls /dev/spi* &> /dev/null; then 405 | echo "SPI appears to be enabled" 406 | fi 407 | 408 | if ls /dev/i2c* &> /dev/null; then 409 | echo "I2C appears to be enabled" 410 | if lsmod | grep "i2c_dev" &> /dev/null && lsmod | grep "i2c_bcm2708" &> /dev/null; then 411 | echo "i2c_dev and i2c_bcm2708 loaded" 412 | fi 413 | if command -v i2cdetect > /dev/null; then 414 | newline && echo "I2C devices detected:" 415 | i2cdetect -y 1 | grep -e "--" | cut -c5- | grep -o -e "[0-z][0-z]" | sed "s|^|0x|" 416 | fi 417 | fi 418 | 419 | if [ -f /proc/device-tree/hat/product ]; then 420 | newline && echo "$(cat /proc/device-tree/hat/product) detected" 421 | fi 422 | 423 | newline 424 | 425 | exit 0 426 | -------------------------------------------------------------------------------- /installers/hifidac: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="pHAT DAC" # the name of the product to install 25 | scriptname="phatdac" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="no" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | gpioreq="no" # whether low-level gpio access is required 35 | i2creq="no" # whether the i2c interface is required 36 | i2sreq="yes" # whether the i2s interface is required 37 | spireq="no" # whether the spi interface is required 38 | uartreq="no" # whether uart communication is required 39 | armhfonly="yes" # whether the script is allowed to run on other arch 40 | armv6="yes" # whether armv6 processors are supported 41 | armv7="yes" # whether armv7 processors are supported 42 | armv8="yes" # whether armv8 processors are supported 43 | raspbianonly="no" # whether the script is allowed to run on other OSes 44 | osreleases=( "Raspbian" ) # list os-releases supported 45 | oswarning=( "Debian" "Kano" "Mate" "PiTop" "RetroPie" "Ubuntu" ) # list experimental os-releases 46 | osdeny=( "Darwin" "Kali" "Linaro" "Volumio" ) # list os-releases specifically disallowed 47 | 48 | FORCE=$1 49 | ASK_TO_REBOOT=false 50 | CURRENT_SETTING=false 51 | MIN_INSTALL=false 52 | FAILED_PKG=false 53 | REMOVE_PKG=false 54 | UPDATE_DB=false 55 | 56 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 57 | BOOTCMD=/boot/cmdline.txt 58 | CONFIG=/boot/config.txt 59 | APTSRC=/etc/apt/sources.list 60 | INITABCONF=/etc/inittab 61 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 62 | LOADMOD=/etc/modules 63 | 64 | # function define 65 | 66 | confirm() { 67 | if [ "$FORCE" == '-y' ]; then 68 | true 69 | else 70 | read -r -p "$1 [y/N] " response < /dev/tty 71 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 72 | true 73 | else 74 | false 75 | fi 76 | fi 77 | } 78 | 79 | prompt() { 80 | read -r -p "$1 [y/N] " response < /dev/tty 81 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 82 | true 83 | else 84 | false 85 | fi 86 | } 87 | 88 | success() { 89 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 90 | } 91 | 92 | inform() { 93 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 94 | } 95 | 96 | warning() { 97 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 98 | } 99 | 100 | newline() { 101 | echo "" 102 | } 103 | 104 | progress() { 105 | count=0 106 | until [ $count -eq 7 ]; do 107 | echo -n "..." && sleep 1 108 | ((count++)) 109 | done; 110 | if ps -C $1 > /dev/null; then 111 | echo -en "\r\e[K" && progress $1 112 | fi 113 | } 114 | 115 | sudocheck() { 116 | if [ $(id -u) -ne 0 ]; then 117 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 118 | exit 1 119 | fi 120 | } 121 | 122 | sysclean() { 123 | sudo apt-get clean && sudo apt-get autoclean 124 | sudo apt-get -y autoremove &> /dev/null 125 | } 126 | 127 | sysupdate() { 128 | if ! $UPDATE_DB; then 129 | echo "Updating apt indexes..." && progress apt-get & 130 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 131 | sleep 3 && UPDATE_DB=true 132 | fi 133 | } 134 | 135 | sysupgrade() { 136 | sudo apt-get upgrade 137 | sudo apt-get clean && sudo apt-get autoclean 138 | sudo apt-get -y autoremove &> /dev/null 139 | } 140 | 141 | sysreboot() { 142 | warning "Some changes made to your system require" 143 | warning "your computer to reboot to take effect." 144 | echo 145 | if prompt "Would you like to reboot now?"; then 146 | sync && sudo reboot 147 | fi 148 | } 149 | 150 | arch_check() { 151 | IS_ARMHF=false 152 | IS_ARMv6=false 153 | 154 | if uname -m | grep -q "armv.l"; then 155 | IS_ARMHF=true 156 | if uname -m | grep -q "armv6l"; then 157 | IS_ARMv6=true 158 | fi 159 | fi 160 | } 161 | 162 | os_check() { 163 | IS_MACOSX=false 164 | IS_RASPBIAN=false 165 | IS_SUPPORTED=false 166 | IS_EXPERIMENTAL=false 167 | OS_NAME="Unknown" 168 | 169 | if uname -s | grep -q "Darwin"; then 170 | OS_NAME="Darwin" && IS_MACOSX=true 171 | elif cat /etc/os-release | grep -q "Kali"; then 172 | OS_NAME="Kali" 173 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 174 | OS_NAME="Kano" 175 | elif whoami | grep -q "linaro"; then 176 | OS_NAME="Linaro" 177 | elif [ -d ~/.config/ubuntu-mate ];then 178 | OS_NAME="Mate" 179 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 180 | OS_NAME="PiTop" 181 | elif command -v emulationstation > /dev/null; then 182 | OS_NAME="RetroPie" 183 | elif cat /etc/os-release | grep -q "volumio"; then 184 | OS_NAME="Volumio" 185 | elif cat /etc/os-release | grep -q "Raspbian"; then 186 | OS_NAME="Raspbian" && IS_RASPBIAN=true 187 | elif cat /etc/os-release | grep -q "Debian"; then 188 | OS_NAME="Debian" 189 | elif cat /etc/os-release | grep -q "Ubuntu"; then 190 | OS_NAME="Ubuntu" 191 | fi 192 | 193 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 194 | IS_SUPPORTED=true 195 | fi 196 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 197 | IS_EXPERIMENTAL=true 198 | fi 199 | } 200 | 201 | raspbian_check() { 202 | IS_SUPPORTED=false 203 | IS_EXPERIMENTAL=false 204 | 205 | if [ -f /etc/os-release ]; then 206 | if cat /etc/os-release | grep -q "/sid"; then 207 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 208 | elif cat /etc/os-release | grep -q "bullseye"; then 209 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 210 | elif cat /etc/os-release | grep -q "buster"; then 211 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 212 | elif cat /etc/os-release | grep -q "stretch"; then 213 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 214 | elif cat /etc/os-release | grep -q "jessie"; then 215 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 216 | elif cat /etc/os-release | grep -q "wheezy"; then 217 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 218 | else 219 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 220 | fi 221 | fi 222 | } 223 | 224 | home_dir() { 225 | if [ $EUID -ne 0 ]; then 226 | if $IS_MACOSX; then 227 | USER_HOME=$(dscl . -read /Users/$USER NFSHomeDirectory | cut -d: -f2) 228 | else 229 | USER_HOME=$(getent passwd $USER | cut -d: -f6) 230 | fi 231 | else 232 | warning "Running as root, please log in as a regular user with sudo rights!" 233 | echo && exit 1 234 | fi 235 | } 236 | 237 | space_chk() { 238 | if command -v stat > /dev/null; then 239 | if [ $spacereq -gt $(($(stat -f -c "%a*%S" /)/10**6)) ];then 240 | echo 241 | warning "There is not enough space left to proceed with installation" 242 | if confirm "Would you like to attempt to expand your filesystem?"; then 243 | curl -sS $GETPOOL/expandfs | sudo bash && exit 1 244 | else 245 | echo && exit 1 246 | fi 247 | fi 248 | fi 249 | } 250 | 251 | timestamp() { 252 | date +%Y%m%d-%H%M 253 | } 254 | 255 | check_network() { 256 | sudo ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3 | head -n 1` &> /dev/null && return 0 || return 1 257 | } 258 | 259 | add_dtoverlay() { 260 | if grep -q "^dtoverlay=$1" $CONFIG; then 261 | echo -e "\n$1 overlay already active" 262 | elif grep -q "^#dtoverlay=$1" $CONFIG; then 263 | sudo sed -i "/^#dtoverlay=$1$/ s|#||" $CONFIG 264 | echo -e "\nAdding $1 overlay to $CONFIG" 265 | ASK_TO_REBOOT=true 266 | else 267 | echo "dtoverlay=$1" | sudo tee -a $CONFIG &> /dev/null 268 | echo -e "\nAdding $1 overlay to $CONFIG" 269 | ASK_TO_REBOOT=true 270 | fi 271 | } 272 | 273 | remove_dtoverlay() { 274 | sudo sed -i "/^dtoverlay=$1$/ s|^|#|" $CONFIG 275 | ASK_TO_REBOOT=true 276 | } 277 | 278 | enable_pi_audio() { 279 | if grep -q "#dtparam=audio=on" $CONFIG; then 280 | sudo sed -i "/^#dtparam=audio=on$/ s|#||" $CONFIG 281 | echo -e "\nsnd_bcm2835 loaded (on-board audio enabled)" 282 | ASK_TO_REBOOT=true 283 | fi 284 | } 285 | 286 | disable_pi_audio() { 287 | if grep -q "^dtparam=audio=on" $CONFIG; then 288 | sudo sed -i "/^dtparam=audio=on$/ s|^|#|" $CONFIG 289 | echo -e "\nsnd_bcm2835 unloaded (on-board audio disabled)" 290 | ASK_TO_REBOOT=true 291 | fi 292 | } 293 | 294 | test_audio() { 295 | newline 296 | if confirm "Do you wish to test your system now?"; then 297 | echo -e "\nTesting..." 298 | speaker-test -l5 -c2 -t wav 299 | fi 300 | } 301 | 302 | disable_pulseaudio() { 303 | sudo mv /etc/xdg/autostart/pulseaudio.desktop /etc/xdg/autostart/pulseaudio.disabled &> /dev/null 304 | pulseaudio -k &> /dev/null 305 | } 306 | 307 | kill_volumealsa() { 308 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE/panels/panel &> /dev/null 309 | sed -i "s|type=volumealsa|type=space|" $HOME/.config/lxpanel/LXDE-pi/panels/panel &> /dev/null 310 | } 311 | 312 | basic_asound() { 313 | sudo echo -e "pcm.\041default {\n type hw\n card 1\n}" > $HOME/.asoundrc 314 | sudo echo -e "ctl.\041default {\n type hw\n card 1\n}" >> $HOME/.asoundrc 315 | sudo mv $HOME/.asoundrc /etc/asound.conf 316 | } 317 | 318 | : <<'MAINSTART' 319 | 320 | Perform all variables declarations as well as function definition 321 | above this section for clarity, thanks! 322 | 323 | MAINSTART 324 | 325 | # intro message 326 | 327 | if [ $debugmode != "no" ]; then 328 | inform "\nDEBUG MODE ENABLED" 329 | else 330 | echo -e "\nThis script will install everything needed to use $productname" 331 | if [ "$FORCE" != '-y' ]; then 332 | inform "\nAlways be careful when running scripts and commands" 333 | inform "copied from the internet. Ensure they are from a" 334 | inform "trusted source.\n" 335 | echo "If you want to see what this script does before" 336 | echo -e "running it, you should run:\ncurl -sS $GETPOOL/$scriptname\n" 337 | fi 338 | fi 339 | 340 | # checks and init 341 | 342 | arch_check 343 | os_check 344 | space_chk 345 | home_dir 346 | 347 | if [ $debugmode != "no" ]; then 348 | echo "USER_HOME is $USER_HOME" 349 | echo "OS_NAME is $OS_NAME" 350 | echo "IS_SUPPORTED is $IS_SUPPORTED" 351 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 352 | echo 353 | fi 354 | 355 | if ! $IS_ARMHF; then 356 | warning "This hardware is not supported, sorry!" 357 | warning "Config files have been left untouched\n" 358 | exit 1 359 | fi 360 | 361 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 362 | warning "Sorry, your CPU is not supported by this installer\n" 363 | exit 1 364 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 365 | warning "Sorry, your CPU is not supported by this installer\n" 366 | exit 1 367 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 368 | warning "Sorry, your CPU is not supported by this installer\n" 369 | exit 1 370 | fi 371 | 372 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 373 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 374 | exit 1 375 | fi 376 | 377 | if $IS_RASPBIAN; then 378 | raspbian_check 379 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 380 | warning "\n--- Warning ---\n" 381 | echo "The $productname installer" 382 | echo "does not work on this version of Raspbian." 383 | echo "Check https://github.com/$gitusername/$gitreponame" 384 | echo "for additional information and support" && echo 385 | exit 1 386 | fi 387 | fi 388 | 389 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 390 | warning "Your operating system is not supported, sorry!\n" 391 | exit 1 392 | fi 393 | 394 | if $IS_EXPERIMENTAL; then 395 | warning "Support for your operating system is experimental. Please visit" 396 | warning "forums.pimoroni.com if you experience issues with this product.\n" 397 | fi 398 | 399 | if [ $forcesudo == "yes" ]; then 400 | sudocheck 401 | fi 402 | 403 | if [ $uartreq == "yes" ]; then 404 | echo "Note: $productname requires UART communication" 405 | warning "The serial console will be disabled if you proceed!" 406 | fi 407 | if [ $spireq == "yes" ]; then 408 | echo -e "Note: $productname requires SPI communication" 409 | fi 410 | if [ $i2creq == "yes" ]; then 411 | echo -e "Note: $productname requires I2C communication" 412 | fi 413 | if [ $i2sreq == "yes" ]; then 414 | echo -e "Note: $productname uses the I2S interface" 415 | warning "The on-board audio chip will be disabled if you proceed!" 416 | fi 417 | 418 | newline 419 | if confirm "Do you wish to continue?"; then 420 | 421 | # environment preparation 422 | 423 | echo -e "\nChecking hardware requirements..." 424 | 425 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 426 | DEVICE_TREE=false 427 | fi 428 | 429 | if $DEVICE_TREE; then 430 | add_dtoverlay hifiberry-dac 431 | if [ -e $BLACKLIST ]; then 432 | sudo sed -i -e "s|^blacklist[[:space:]]*i2c-bcm2708.*|#blacklist i2c-bcm2708|" \ 433 | -e "s|^blacklist[[:space:]]*snd-soc-pcm512x.*|#blacklist snd-soc-pcm512x|" \ 434 | -e "s|^blacklist[[:space:]]*snd-soc-wm8804.*|#blacklist snd-soc-wm8804|" $BLACKLIST &> /dev/null 435 | fi 436 | else 437 | echo -e "\nNo Device Tree Detected, not supported\n" && exit 1 438 | fi 439 | 440 | if [ -e $CONFIG ] && grep -q -E "^dtparam=audio=on$" $CONFIG; then 441 | bcm2835off="no" 442 | echo -e "\nDisabling default sound driver" 443 | disable_pi_audio && kill_volumealsa 444 | if [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then 445 | sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $LOADMOD &> /dev/null 446 | fi 447 | ASK_TO_REBOOT=true 448 | elif [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then 449 | bcm2835off="no" 450 | echo -e "\nDisabling default sound module" 451 | sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $LOADMOD &> /dev/null 452 | ASK_TO_REBOOT=true 453 | else 454 | echo -e "\nDefault sound driver currently not loaded" 455 | bcm2835off="yes" 456 | fi 457 | 458 | if [ $bcm2835off == "yes" ]; then 459 | echo -e "\nWe can now test your $productname" 460 | warning "Set your speakers at a low volume!\n" 461 | test_audio 462 | fi 463 | success "\nAll done!\n" 464 | echo -e "Enjoy your new $productname!\n" 465 | 466 | if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then 467 | sysreboot 468 | fi 469 | else 470 | echo -e "\nAborting...\n" 471 | fi 472 | 473 | exit 0 474 | -------------------------------------------------------------------------------- /installers/hyperpixel4: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | success() { 23 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 24 | } 25 | 26 | inform() { 27 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 28 | } 29 | 30 | warning() { 31 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 32 | } 33 | 34 | newline() { 35 | echo "" 36 | } 37 | 38 | newline 39 | warning "---------------------------------------------------------" 40 | inform "PSA: The install process has changed!" 41 | newline 42 | echo "Pi 4 and Pi 3B+ users should read this:" 43 | echo "https://github.com/pimoroni/hyperpixel4/issues/177" 44 | newline 45 | echo "If you're sure you want to install the legacy drivers, use:" 46 | echo "curl -sSL get.pimoroni.com/hyperpixel4-legacy | bash" 47 | warning "---------------------------------------------------------" 48 | newline 49 | 50 | exit 0 51 | -------------------------------------------------------------------------------- /installers/i2c: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="I2C bus" # the name of the product to install 25 | scriptname="i2c" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="yes" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="no" # whether the script is allowed to run on other OSes 39 | osreleases=( "Raspbian" "Kano" "Mate" "OSMC" "PiTop" "RetroPie" "Volumio" ) # list os-releases supported 40 | oswarning=( "Debian" "Ubuntu" ) # list experimental os-releases 41 | osdeny=( "Darwin" "Kali" "Linaro" ) # list os-releases specifically disallowed 42 | 43 | # setup variables 44 | 45 | FORCE=$1 46 | ASK_TO_REBOOT=false 47 | CURRENT_SETTING=false 48 | MIN_INSTALL=false 49 | FAILED_PKG=false 50 | REMOVE_PKG=false 51 | UPDATE_DB=false 52 | 53 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 54 | BOOTCMD=/boot/cmdline.txt 55 | CONFIG=/boot/config.txt 56 | DTBODIR=/boot/overlays 57 | APTSRC=/etc/apt/sources.list 58 | INITABCONF=/etc/inittab 59 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 60 | LOADMOD=/etc/modules 61 | 62 | # function define 63 | 64 | confirm() { 65 | if [ "$FORCE" == '-y' ]; then 66 | true 67 | else 68 | read -r -p "$1 [y/N] " response < /dev/tty 69 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 70 | true 71 | else 72 | false 73 | fi 74 | fi 75 | } 76 | 77 | prompt() { 78 | read -r -p "$1 [y/N] " response < /dev/tty 79 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 80 | true 81 | else 82 | false 83 | fi 84 | } 85 | 86 | success() { 87 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 88 | } 89 | 90 | inform() { 91 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 92 | } 93 | 94 | warning() { 95 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 96 | } 97 | 98 | newline() { 99 | echo "" 100 | } 101 | 102 | progress() { 103 | count=0 104 | until [ $count -eq 7 ]; do 105 | echo -n "..." && sleep 1 106 | ((count++)) 107 | done; 108 | if ps -C $1 > /dev/null; then 109 | echo -en "\r\e[K" && progress $1 110 | fi 111 | } 112 | 113 | sudocheck() { 114 | if [ $(id -u) -ne 0 ]; then 115 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 116 | exit 1 117 | fi 118 | } 119 | 120 | sysclean() { 121 | sudo apt-get clean && sudo apt-get autoclean 122 | sudo apt-get -y autoremove &> /dev/null 123 | } 124 | 125 | sysupdate() { 126 | if ! $UPDATE_DB; then 127 | echo "Updating apt indexes..." && progress apt-get & 128 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 129 | sleep 3 && UPDATE_DB=true 130 | fi 131 | } 132 | 133 | sysupgrade() { 134 | sudo apt-get upgrade 135 | sudo apt-get clean && sudo apt-get autoclean 136 | sudo apt-get -y autoremove &> /dev/null 137 | } 138 | 139 | sysreboot() { 140 | warning "Some changes made to your system require" 141 | warning "your computer to reboot to take effect." 142 | echo 143 | if prompt "Would you like to reboot now?"; then 144 | sync && sudo reboot 145 | fi 146 | } 147 | 148 | dt_check() { 149 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 150 | DEVICE_TREE=false 151 | fi 152 | } 153 | 154 | i2c_check() { 155 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 156 | CURRENT_SETTING=true 157 | else 158 | CURRENT_SETTING=false 159 | fi 160 | } 161 | 162 | spi_check() { 163 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 164 | CURRENT_SETTING=true 165 | else 166 | CURRENT_SETTING=false 167 | fi 168 | } 169 | 170 | get_init_sys() { 171 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 172 | SYSTEMD=1 173 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 174 | SYSTEMD=0 175 | else 176 | echo "Unrecognised init system" && exit 1 177 | fi 178 | } 179 | 180 | get_hw_rev() { 181 | hwrid=$(grep "^Revision" /proc/cpuinfo | rev | cut -c 2-3 | rev) 182 | if [ "$hwrid" == "00" ] || [ "$hwrid" == "01" ];then # Pi 1 183 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-4 | rev)" 184 | if [ "$hwrid" == "00" ];then 185 | hwgen="1260" # P1 186 | elif [ "$hwrid" == "01" ];then 187 | hwgen="1400" # J8 188 | fi 189 | else 190 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-6 | rev)" 191 | if [ "$hwrid" == "04" ];then # Pi 2 192 | hwgen="2400" 193 | elif [ "$hwrid" == "08" ];then # Pi 3 194 | hwgen="3401" 195 | elif [ "$hwrid" == "09" ];then # Pi 0 196 | hwgen="0400" 197 | elif [ "$hwrid" == "0c" ];then # Pi 0 W 198 | hwgen="0401" 199 | else # Unknown 200 | hwgen="0000" 201 | fi 202 | fi 203 | } 204 | 205 | : <<'MAINSTART' 206 | 207 | Perform all global variables declarations as well as function definition 208 | above this section for clarity, thanks! 209 | 210 | MAINSTART 211 | 212 | # intro message 213 | 214 | if [ $debugmode != "no" ]; then 215 | if [ $debuguser != "none" ]; then 216 | gitusername="$debuguser" 217 | fi 218 | if [ $debugpoint != "none" ]; then 219 | gitrepobranch="$debugpoint" 220 | fi 221 | inform "\nDEBUG MODE ENABLED" 222 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 223 | else 224 | warning "This script should only be run on a Raspberry Pi\n" 225 | echo "This script will enable the I2C bus" 226 | fi 227 | 228 | # checks and init 229 | 230 | dt_check 231 | 232 | if [ $forcesudo == "yes" ]; then 233 | sudocheck 234 | fi 235 | 236 | if confirm "Do you wish to continue?"; then 237 | 238 | # environment preparation 239 | 240 | i2c_check 241 | 242 | if $DEVICE_TREE && ! $CURRENT_SETTING; then 243 | echo -e "\nDevice Tree Detected" 244 | echo -e "Enabling I2C...\n" 245 | if grep -q "^dtparam=i2c_arm=off" $CONFIG; then 246 | sudo sed -i "s|^dtparam=i2c_arm=off|dtparam=i2c_arm=on|" $CONFIG &> /dev/null 247 | elif grep -q "^#dtparam=i2c_arm=on" $CONFIG; then 248 | sudo sed -i "s|^#dtparam=i2c_arm=on|dtparam=i2c_arm=on|" $CONFIG &> /dev/null 249 | else 250 | echo "dtparam=i2c_arm=on" | sudo tee -a $CONFIG &> /dev/null 251 | fi 252 | if ! [ -e $BLACKLIST ]; then 253 | touch $BLACKLIST 254 | fi 255 | sudo sed -i "s|^\(blacklist[[:space:]]*i2c[-_]bcm2708\)|#\1|" $BLACKLIST &> /dev/null 256 | dtparam i2c_arm=on &> /dev/null 257 | inform "\nI2C Enabled" 258 | warning "Reboot required!\n" 259 | ASK_TO_REBOOT=true 260 | elif ! $DEVICE_TREE && [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*i2c-bcm2708" $BLACKLIST; then 261 | echo -e "\nNo Device Tree Detected" 262 | echo -e "Enabling I2C..." 263 | echo -e "\nCommenting out Blacklist entry in\n$BLACKLIST" 264 | sudo sed -i "s|^blacklist[[:space:]]*i2c-bcm2708.*|#blacklist i2c-bcm2708|" $BLACKLIST &> /dev/null 265 | inform "\nI2C Enabled\n" 266 | else 267 | inform "I2C Already Enabled\n" 268 | fi 269 | if ! [ -e $LOADMOD ]; then 270 | touch $LOADMOD 271 | fi 272 | if ! grep -q "^i2c[-_]dev" $LOADMOD; then 273 | echo "i2c-dev" | sudo tee -a $LOADMOD &> /dev/null 274 | fi 275 | if ! grep -qe "i2c[-_]bcm2708" $LOADMOD; then 276 | echo "i2c-bcm2708" | sudo tee -a $LOADMOD &> /dev/null 277 | fi 278 | sudo modprobe -a i2c-bcm2708 i2c-dev 279 | else 280 | echo -e "\nAborting...\n" 281 | fi 282 | 283 | exit 0 284 | -------------------------------------------------------------------------------- /installers/i2c0: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="I2C0 bus" # the name of the product to install 25 | scriptname="i2c0" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="yes" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="yes" # whether the script is allowed to run on other OSes 39 | osreleases=( "Raspbian" ) # list os-releases supported 40 | oswarning=( "Debian" "Kano" "Mate" "OSMC" "PiTop" "RetroPie" "Ubuntu" "Volumio" ) # list experimental os-releases 41 | osdeny=( "Darwin" "Kali" "Linaro" ) # list os-releases specifically disallowed 42 | 43 | # setup variables 44 | 45 | FORCE=$1 46 | ASK_TO_REBOOT=false 47 | CURRENT_SETTING=false 48 | MIN_INSTALL=false 49 | FAILED_PKG=false 50 | REMOVE_PKG=false 51 | UPDATE_DB=false 52 | 53 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 54 | BOOTCMD=/boot/cmdline.txt 55 | CONFIG=/boot/config.txt 56 | DTBODIR=/boot/overlays 57 | APTSRC=/etc/apt/sources.list 58 | INITABCONF=/etc/inittab 59 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 60 | LOADMOD=/etc/modules 61 | 62 | # function define 63 | 64 | confirm() { 65 | if [ "$FORCE" == '-y' ]; then 66 | true 67 | else 68 | read -r -p "$1 [y/N] " response < /dev/tty 69 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 70 | true 71 | else 72 | false 73 | fi 74 | fi 75 | } 76 | 77 | prompt() { 78 | read -r -p "$1 [y/N] " response < /dev/tty 79 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 80 | true 81 | else 82 | false 83 | fi 84 | } 85 | 86 | success() { 87 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 88 | } 89 | 90 | inform() { 91 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 92 | } 93 | 94 | warning() { 95 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 96 | } 97 | 98 | newline() { 99 | echo "" 100 | } 101 | 102 | progress() { 103 | count=0 104 | until [ $count -eq 7 ]; do 105 | echo -n "..." && sleep 1 106 | ((count++)) 107 | done; 108 | if ps -C $1 > /dev/null; then 109 | echo -en "\r\e[K" && progress $1 110 | fi 111 | } 112 | 113 | sudocheck() { 114 | if [ $(id -u) -ne 0 ]; then 115 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 116 | exit 1 117 | fi 118 | } 119 | 120 | sysclean() { 121 | sudo apt-get clean && sudo apt-get autoclean 122 | sudo apt-get -y autoremove &> /dev/null 123 | } 124 | 125 | sysupdate() { 126 | if ! $UPDATE_DB; then 127 | echo "Updating apt indexes..." && progress apt-get & 128 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 129 | sleep 3 && UPDATE_DB=true 130 | fi 131 | } 132 | 133 | sysupgrade() { 134 | sudo apt-get upgrade 135 | sudo apt-get clean && sudo apt-get autoclean 136 | sudo apt-get -y autoremove &> /dev/null 137 | } 138 | 139 | sysreboot() { 140 | warning "Some changes made to your system require" 141 | warning "your computer to reboot to take effect." 142 | echo 143 | if prompt "Would you like to reboot now?"; then 144 | sync && sudo reboot 145 | fi 146 | } 147 | 148 | arch_check() { 149 | IS_ARMHF=false 150 | IS_ARMv6=false 151 | 152 | if uname -m | grep -q "armv.l"; then 153 | IS_ARMHF=true 154 | if uname -m | grep -q "armv6l"; then 155 | IS_ARMv6=true 156 | fi 157 | fi 158 | } 159 | 160 | os_check() { 161 | IS_MACOSX=false 162 | IS_RASPBIAN=false 163 | IS_SUPPORTED=false 164 | IS_EXPERIMENTAL=false 165 | OS_NAME="Unknown" 166 | 167 | if uname -s | grep -q "Darwin"; then 168 | OS_NAME="Darwin" && IS_MACOSX=true 169 | elif cat /etc/os-release | grep -q "Kali"; then 170 | OS_NAME="Kali" 171 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 172 | OS_NAME="Kano" 173 | elif whoami | grep -q "linaro"; then 174 | OS_NAME="Linaro" 175 | elif [ -d ~/.config/ubuntu-mate ];then 176 | OS_NAME="Mate" 177 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 178 | OS_NAME="PiTop" 179 | elif command -v emulationstation > /dev/null; then 180 | OS_NAME="RetroPie" 181 | elif cat /etc/os-release | grep -q "OSMC"; then 182 | OS_NAME="OSMC" 183 | elif cat /etc/os-release | grep -q "volumio"; then 184 | OS_NAME="Volumio" 185 | elif cat /etc/os-release | grep -q "Raspbian"; then 186 | OS_NAME="Raspbian" && IS_RASPBIAN=true 187 | elif cat /etc/os-release | grep -q "Debian"; then 188 | OS_NAME="Debian" 189 | elif cat /etc/os-release | grep -q "Ubuntu"; then 190 | OS_NAME="Ubuntu" 191 | fi 192 | 193 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 194 | IS_SUPPORTED=true 195 | fi 196 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 197 | IS_EXPERIMENTAL=true 198 | fi 199 | } 200 | 201 | raspbian_check() { 202 | IS_SUPPORTED=false 203 | IS_EXPERIMENTAL=false 204 | 205 | if [ -f /etc/os-release ]; then 206 | if cat /etc/os-release | grep -q "/sid"; then 207 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 208 | elif cat /etc/os-release | grep -q "bullseye"; then 209 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 210 | elif cat /etc/os-release | grep -q "buster"; then 211 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 212 | elif cat /etc/os-release | grep -q "stretch"; then 213 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 214 | elif cat /etc/os-release | grep -q "jessie"; then 215 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 216 | elif cat /etc/os-release | grep -q "wheezy"; then 217 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 218 | else 219 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 220 | fi 221 | fi 222 | } 223 | 224 | dt_check() { 225 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 226 | DEVICE_TREE=false 227 | fi 228 | } 229 | 230 | i2c_check() { 231 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 232 | CURRENT_SETTING=true 233 | else 234 | CURRENT_SETTING=false 235 | fi 236 | } 237 | 238 | spi_check() { 239 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 240 | CURRENT_SETTING=true 241 | else 242 | CURRENT_SETTING=false 243 | fi 244 | } 245 | 246 | get_init_sys() { 247 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 248 | SYSTEMD=1 249 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 250 | SYSTEMD=0 251 | else 252 | echo "Unrecognised init system" && exit 1 253 | fi 254 | } 255 | 256 | get_hw_rev() { 257 | hwrid=$(grep "^Revision" /proc/cpuinfo | rev | cut -c 2-3 | rev) 258 | if [ "$hwrid" == "00" ] || [ "$hwrid" == "01" ];then # Pi 1 259 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-4 | rev)" 260 | if [ "$hwrid" == "00" ];then 261 | hwgen="1260" # P1 262 | elif [ "$hwrid" == "01" ];then 263 | hwgen="1400" # J8 264 | fi 265 | else 266 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-6 | rev)" 267 | if [ "$hwrid" == "04" ];then # Pi 2 268 | hwgen="2400" 269 | elif [ "$hwrid" == "08" ];then # Pi 3 270 | hwgen="3401" 271 | elif [ "$hwrid" == "09" ];then # Pi 0 272 | hwgen="0400" 273 | elif [ "$hwrid" == "0c" ];then # Pi 0 W 274 | hwgen="0401" 275 | else # Unknown 276 | hwgen="0000" 277 | fi 278 | fi 279 | } 280 | 281 | : <<'MAINSTART' 282 | 283 | Perform all global variables declarations as well as function definition 284 | above this section for clarity, thanks! 285 | 286 | MAINSTART 287 | 288 | # intro message 289 | 290 | if [ $debugmode != "no" ]; then 291 | if [ $debuguser != "none" ]; then 292 | gitusername="$debuguser" 293 | fi 294 | if [ $debugpoint != "none" ]; then 295 | gitrepobranch="$debugpoint" 296 | fi 297 | inform "\nDEBUG MODE ENABLED" 298 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 299 | else 300 | echo "This script will enable the I2C0 bus on your Raspberry Pi" 301 | fi 302 | 303 | # checks and init 304 | 305 | dt_check 306 | arch_check 307 | os_check 308 | 309 | 310 | if [ $debugmode != "no" ]; then 311 | echo "USER_HOME is $USER_HOME" 312 | echo "OS_NAME is $OS_NAME" 313 | echo "IS_SUPPORTED is $IS_SUPPORTED" 314 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 315 | echo 316 | fi 317 | 318 | if ! $IS_ARMHF; then 319 | warning "This hardware is not supported, sorry!" 320 | warning "Config files have been left untouched\n" 321 | exit 1 322 | fi 323 | 324 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 325 | warning "Sorry, your CPU is not supported by this installer\n" 326 | exit 1 327 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 328 | warning "Sorry, your CPU is not supported by this installer\n" 329 | exit 1 330 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 331 | warning "Sorry, your CPU is not supported by this installer\n" 332 | exit 1 333 | fi 334 | 335 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 336 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 337 | exit 1 338 | fi 339 | 340 | if $IS_RASPBIAN; then 341 | raspbian_check 342 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 343 | warning "\n--- Warning ---\n" 344 | echo "The $productname installer" 345 | echo "does not work on this version of Raspbian." 346 | echo "Check https://github.com/$gitusername/$gitreponame" 347 | echo "for additional information and support\n" 348 | exit 1 349 | fi 350 | fi 351 | 352 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 353 | warning "Your operating system is not supported, sorry!\n" 354 | exit 1 355 | fi 356 | 357 | if $IS_EXPERIMENTAL; then 358 | warning "Support for your operating system is experimental. Please visit" 359 | warning "forums.pimoroni.com if you experience issues with this product.\n" 360 | fi 361 | 362 | if [ $forcesudo == "yes" ]; then 363 | sudocheck 364 | fi 365 | 366 | if confirm "Do you wish to continue?"; then 367 | 368 | # environment preparation 369 | 370 | i2c_check 371 | 372 | if $DEVICE_TREE && ! $CURRENT_SETTING; then 373 | echo -e "\nDevice Tree Detected" 374 | echo -e "Enabling I2C...\n" 375 | if grep -q "^dtparam=i2c_arm=off" $CONFIG; then 376 | sudo sed -i "s|^dtparam=i2c_arm=off|dtparam=i2c_arm=on|" $CONFIG &> /dev/null 377 | elif grep -q "^#dtparam=i2c_arm=on" $CONFIG; then 378 | sudo sed -i "s|^#dtparam=i2c_arm=on|dtparam=i2c_arm=on|" $CONFIG &> /dev/null 379 | else 380 | echo "dtparam=i2c_arm=on" | sudo tee -a $CONFIG &> /dev/null 381 | fi 382 | if ! [ -e $BLACKLIST ]; then 383 | touch $BLACKLIST 384 | fi 385 | sudo sed -i "s|^\(blacklist[[:space:]]*i2c[-_]bcm2708\)|#\1|" $BLACKLIST &> /dev/null 386 | dtparam i2c_arm=on &> /dev/null 387 | inform "\nI2C Enabled" 388 | warning "Reboot required\n!" 389 | ASK_TO_REBOOT=true 390 | elif ! $DEVICE_TREE && [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*i2c-bcm2708" $BLACKLIST; then 391 | echo -e "\nNo Device Tree Detected" 392 | echo "Enabling I2C..." 393 | echo -e "\nCommenting out Blacklist entry in\n$BLACKLIST" 394 | sudo sed -i "s|^blacklist[[:space:]]*i2c-bcm2708.*|#blacklist i2c-bcm2708|" $BLACKLIST &> /dev/null 395 | inform "\nI2C Enabled\n" 396 | else 397 | success "I2C Already Enabled" && newline 398 | fi 399 | if ! [ -e $LOADMOD ]; then 400 | touch $LOADMOD 401 | fi 402 | if ! grep -q "^i2c[-_]dev" $LOADMOD; then 403 | echo "i2c-dev" | sudo tee -a $LOADMOD &> /dev/null 404 | fi 405 | if ! grep -qe "i2c[-_]bcm2708" $LOADMOD; then 406 | echo "i2c-bcm2708" | sudo tee -a $LOADMOD &> /dev/null 407 | fi 408 | sudo modprobe -a i2c-bcm2708 i2c-dev 409 | 410 | if [ -e $CONFIG ] && grep -q "^dtparam=i2c_vc=on$" $CONFIG; then 411 | echo -e "\ni2c0 bus is active" 412 | if confirm "Do you wish to disable it?"; then 413 | sudo sed -i "s|^dtparam=i2c_vc=on|#dtparam=i2c_vc=on|" $CONFIG &> /dev/null 414 | fi 415 | else 416 | echo -e "\nEnabling i2c0 bus in $CONFIG" 417 | if [ -e $CONFIG ] && grep -q "^#dtparam=i2c_vc=on$" $CONFIG; then 418 | sudo sed -i "s|^#dtparam=i2c_vc=on|dtparam=i2c_vc=on|" $CONFIG &> /dev/null 419 | else 420 | echo "dtparam=i2c_vc=on" | sudo tee -a $CONFIG && newline 421 | fi 422 | fi 423 | else 424 | echo -e "\nAborting...\n" 425 | fi 426 | 427 | exit 0 428 | -------------------------------------------------------------------------------- /installers/spi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="SPI bus" # the name of the product to install 25 | scriptname="spi" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="yes" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="no" # whether the script is allowed to run on other OSes 39 | osreleases=( "Raspbian" "Kano" "Mate" "PiTop" "OSMC" "RetroPie" "Volumio" ) # list os-releases supported 40 | oswarning=( "Debian" "Ubuntu" ) # list experimental os-releases 41 | osdeny=( "Darwin" "Kali" "Linaro" ) # list os-releases specifically disallowed 42 | 43 | # setup variables 44 | 45 | FORCE=$1 46 | ASK_TO_REBOOT=false 47 | CURRENT_SETTING=false 48 | MIN_INSTALL=false 49 | FAILED_PKG=false 50 | REMOVE_PKG=false 51 | UPDATE_DB=false 52 | 53 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 54 | BOOTCMD=/boot/cmdline.txt 55 | CONFIG=/boot/config.txt 56 | DTBODIR=/boot/overlays 57 | APTSRC=/etc/apt/sources.list 58 | INITABCONF=/etc/inittab 59 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 60 | LOADMOD=/etc/modules 61 | 62 | # function define 63 | 64 | confirm() { 65 | if [ "$FORCE" == '-y' ]; then 66 | true 67 | else 68 | read -r -p "$1 [y/N] " response < /dev/tty 69 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 70 | true 71 | else 72 | false 73 | fi 74 | fi 75 | } 76 | 77 | prompt() { 78 | read -r -p "$1 [y/N] " response < /dev/tty 79 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 80 | true 81 | else 82 | false 83 | fi 84 | } 85 | 86 | success() { 87 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 88 | } 89 | 90 | inform() { 91 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 92 | } 93 | 94 | warning() { 95 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 96 | } 97 | 98 | newline() { 99 | echo "" 100 | } 101 | 102 | progress() { 103 | count=0 104 | until [ $count -eq 7 ]; do 105 | echo -n "..." && sleep 1 106 | ((count++)) 107 | done; 108 | if ps -C $1 > /dev/null; then 109 | echo -en "\r\e[K" && progress $1 110 | fi 111 | } 112 | 113 | sudocheck() { 114 | if [ $(id -u) -ne 0 ]; then 115 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 116 | exit 1 117 | fi 118 | } 119 | 120 | sysclean() { 121 | sudo apt-get clean && sudo apt-get autoclean 122 | sudo apt-get -y autoremove &> /dev/null 123 | } 124 | 125 | sysupdate() { 126 | if ! $UPDATE_DB; then 127 | echo "Updating apt indexes..." && progress apt-get & 128 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 129 | sleep 3 && UPDATE_DB=true 130 | fi 131 | } 132 | 133 | sysupgrade() { 134 | sudo apt-get upgrade 135 | sudo apt-get clean && sudo apt-get autoclean 136 | sudo apt-get -y autoremove &> /dev/null 137 | } 138 | 139 | sysreboot() { 140 | warning "Some changes made to your system require" 141 | warning "your computer to reboot to take effect." 142 | echo 143 | if prompt "Would you like to reboot now?"; then 144 | sync && sudo reboot 145 | fi 146 | } 147 | 148 | dt_check() { 149 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 150 | DEVICE_TREE=false 151 | fi 152 | } 153 | 154 | i2c_check() { 155 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 156 | CURRENT_SETTING=true 157 | else 158 | CURRENT_SETTING=false 159 | fi 160 | } 161 | 162 | spi_check() { 163 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 164 | CURRENT_SETTING=true 165 | else 166 | CURRENT_SETTING=false 167 | fi 168 | } 169 | 170 | get_init_sys() { 171 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 172 | SYSTEMD=1 173 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 174 | SYSTEMD=0 175 | else 176 | echo "Unrecognised init system" && exit 1 177 | fi 178 | } 179 | 180 | get_hw_rev() { 181 | hwrid=$(grep "^Revision" /proc/cpuinfo | rev | cut -c 2-3 | rev) 182 | if [ "$hwrid" == "00" ] || [ "$hwrid" == "01" ];then # Pi 1 183 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-4 | rev)" 184 | if [ "$hwrid" == "00" ];then 185 | hwgen="1260" # P1 186 | elif [ "$hwrid" == "01" ];then 187 | hwgen="1400" # J8 188 | fi 189 | else 190 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-6 | rev)" 191 | if [ "$hwrid" == "04" ];then # Pi 2 192 | hwgen="2400" 193 | elif [ "$hwrid" == "08" ];then # Pi 3 194 | hwgen="3401" 195 | elif [ "$hwrid" == "09" ];then # Pi 0 196 | hwgen="0400" 197 | elif [ "$hwrid" == "0c" ];then # Pi 0 W 198 | hwgen="0401" 199 | else # Unknown 200 | hwgen="0000" 201 | fi 202 | fi 203 | } 204 | 205 | : <<'MAINSTART' 206 | 207 | Perform all global variables declarations as well as function definition 208 | above this section for clarity, thanks! 209 | 210 | MAINSTART 211 | 212 | # intro message 213 | 214 | if [ $debugmode != "no" ]; then 215 | if [ $debuguser != "none" ]; then 216 | gitusername="$debuguser" 217 | fi 218 | if [ $debugpoint != "none" ]; then 219 | gitrepobranch="$debugpoint" 220 | fi 221 | inform "\nDEBUG MODE ENABLED" 222 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 223 | else 224 | warning "This script should only be run on a Raspberry Pi!\n" 225 | echo "This script will enable the SPI bus." 226 | fi 227 | 228 | # checks and init 229 | 230 | dt_check 231 | 232 | if [ $forcesudo == "yes" ]; then 233 | sudocheck 234 | fi 235 | 236 | if confirm "Do you wish to continue?"; then 237 | 238 | # environment preparation 239 | 240 | spi_check 241 | 242 | if $DEVICE_TREE && ! $CURRENT_SETTING; then 243 | echo -e "\nDevice Tree Detected" 244 | echo -e "Enabling SPI...\n" 245 | echo -e "Adding Device Tree Entry to $CONFIG" 246 | if grep -q "^dtparam=spi=off" $CONFIG; then 247 | sudo sed -i "s|^dtparam=spi=off|dtparam=spi=on|" $CONFIG &> /dev/null 248 | elif grep -q "^#dtparam=spi=on" $CONFIG; then 249 | sudo sed -i "s|^#dtparam=spi=on|dtparam=spi=on|" $CONFIG &> /dev/null 250 | else 251 | echo "dtparam=spi=on" | sudo tee -a $CONFIG &> /dev/null 252 | fi 253 | echo -e "Commenting out Blacklist entry in\n$BLACKLIST" 254 | if ! [ -e $BLACKLIST ]; then 255 | touch $BLACKLIST 256 | fi 257 | sudo sed -i "s|^\(blacklist[[:space:]]*spi[-_]bcm2708\)|#\1|" $BLACKLIST &> /dev/null 258 | dtparam spi=on &> /dev/null 259 | inform "\nSPI enabled" 260 | warning "Reboot required!\n" 261 | ASK_TO_REBOOT=true 262 | elif ! $DEVICE_TREE && [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*spi-bcm2708" $BLACKLIST; then 263 | echo -e "\nNo Device Tree Detected" 264 | echo -e "Enabling SPI..." 265 | echo -e "\nCommenting out Blacklist entry in\n$BLACKLIST" 266 | sudo sed -i "s|^blacklist[[:space:]]*spi-bcm2708.*|#blacklist spi-bcm2708|" $BLACKLIST &> /dev/null 267 | inform "\nSPI enabled\n" 268 | else 269 | inform "SPI Already Enabled\n" 270 | fi 271 | if ! [ -e $LOADMOD ]; then 272 | touch $LOADMOD 273 | fi 274 | if ! grep -qe "spi-bcm2708" $LOADMOD; then 275 | echo "spi-bcm2708" | sudo tee -a $LOADMOD &> /dev/null 276 | fi 277 | sudo modprobe -q spi-bcm2708 278 | else 279 | echo -e "\nAborting...\n" 280 | fi 281 | 282 | exit 0 283 | -------------------------------------------------------------------------------- /installers/uartoff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="Serial Console" # the name of the product to install 25 | scriptname="uartoff" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="yes" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="no" # whether the script is allowed to run on other OSes 39 | osreleases=( "Raspbian" "Kano" "Mate" "PiTop" "RetroPie" "Volumio" ) # list os-releases supported 40 | oswarning=( "Debian" "Ubuntu" ) # list experimental os-releases 41 | osdeny=( "Darwin" "Kali" "Linaro" ) # list os-releases specifically disallowed 42 | 43 | # setup variables 44 | 45 | FORCE=$1 46 | ASK_TO_REBOOT=false 47 | CURRENT_SETTING=false 48 | MIN_INSTALL=false 49 | FAILED_PKG=false 50 | REMOVE_PKG=false 51 | UPDATE_DB=false 52 | 53 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 54 | BOOTCMD=/boot/cmdline.txt 55 | CONFIG=/boot/config.txt 56 | DTBODIR=/boot/overlays 57 | APTSRC=/etc/apt/sources.list 58 | INITABCONF=/etc/inittab 59 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 60 | LOADMOD=/etc/modules 61 | 62 | # function define 63 | 64 | confirm() { 65 | if [ "$FORCE" == '-y' ]; then 66 | true 67 | else 68 | read -r -p "$1 [y/N] " response < /dev/tty 69 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 70 | true 71 | else 72 | false 73 | fi 74 | fi 75 | } 76 | 77 | prompt() { 78 | read -r -p "$1 [y/N] " response < /dev/tty 79 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 80 | true 81 | else 82 | false 83 | fi 84 | } 85 | 86 | success() { 87 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 88 | } 89 | 90 | inform() { 91 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 92 | } 93 | 94 | warning() { 95 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 96 | } 97 | 98 | newline() { 99 | echo "" 100 | } 101 | 102 | progress() { 103 | count=0 104 | until [ $count -eq 7 ]; do 105 | echo -n "..." && sleep 1 106 | ((count++)) 107 | done; 108 | if ps -C $1 > /dev/null; then 109 | echo -en "\r\e[K" && progress $1 110 | fi 111 | } 112 | 113 | sudocheck() { 114 | if [ $(id -u) -ne 0 ]; then 115 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 116 | exit 1 117 | fi 118 | } 119 | 120 | sysclean() { 121 | sudo apt-get clean && sudo apt-get autoclean 122 | sudo apt-get -y autoremove &> /dev/null 123 | } 124 | 125 | sysupdate() { 126 | if ! $UPDATE_DB; then 127 | echo "Updating apt indexes..." && progress apt-get & 128 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 129 | sleep 3 && UPDATE_DB=true 130 | fi 131 | } 132 | 133 | sysupgrade() { 134 | sudo apt-get upgrade 135 | sudo apt-get clean && sudo apt-get autoclean 136 | sudo apt-get -y autoremove &> /dev/null 137 | } 138 | 139 | sysreboot() { 140 | warning "Some changes made to your system require" 141 | warning "your computer to reboot to take effect." 142 | echo 143 | if prompt "Would you like to reboot now?"; then 144 | sync && sudo reboot 145 | fi 146 | } 147 | 148 | arch_check() { 149 | IS_ARMHF=false 150 | IS_ARMv6=false 151 | 152 | if uname -m | grep -q "armv.l"; then 153 | IS_ARMHF=true 154 | if uname -m | grep -q "armv6l"; then 155 | IS_ARMv6=true 156 | fi 157 | fi 158 | } 159 | 160 | os_check() { 161 | IS_MACOSX=false 162 | IS_RASPBIAN=false 163 | IS_SUPPORTED=false 164 | IS_EXPERIMENTAL=false 165 | OS_NAME="Unknown" 166 | 167 | if uname -s | grep -q "Darwin"; then 168 | OS_NAME="Darwin" && IS_MACOSX=true 169 | elif cat /etc/os-release | grep -q "Kali"; then 170 | OS_NAME="Kali" 171 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 172 | OS_NAME="Kano" 173 | elif whoami | grep -q "linaro"; then 174 | OS_NAME="Linaro" 175 | elif [ -d ~/.config/ubuntu-mate ];then 176 | OS_NAME="Mate" 177 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 178 | OS_NAME="PiTop" 179 | elif command -v emulationstation > /dev/null; then 180 | OS_NAME="RetroPie" 181 | elif cat /etc/os-release | grep -q "volumio"; then 182 | OS_NAME="Volumio" 183 | elif cat /etc/os-release | grep -q "Raspbian"; then 184 | OS_NAME="Raspbian" && IS_RASPBIAN=true 185 | elif cat /etc/os-release | grep -q "Debian"; then 186 | OS_NAME="Debian" 187 | elif cat /etc/os-release | grep -q "Ubuntu"; then 188 | OS_NAME="Ubuntu" 189 | fi 190 | 191 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 192 | IS_SUPPORTED=true 193 | fi 194 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 195 | IS_EXPERIMENTAL=true 196 | fi 197 | } 198 | 199 | raspbian_check() { 200 | IS_SUPPORTED=false 201 | IS_EXPERIMENTAL=false 202 | 203 | if [ -f /etc/os-release ]; then 204 | if cat /etc/os-release | grep -q "/sid"; then 205 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 206 | elif cat /etc/os-release | grep -q "bullseye"; then 207 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 208 | elif cat /etc/os-release | grep -q "buster"; then 209 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 210 | elif cat /etc/os-release | grep -q "stretch"; then 211 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 212 | elif cat /etc/os-release | grep -q "jessie"; then 213 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 214 | elif cat /etc/os-release | grep -q "wheezy"; then 215 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 216 | else 217 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 218 | fi 219 | fi 220 | } 221 | 222 | dt_check() { 223 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 224 | DEVICE_TREE=false 225 | fi 226 | } 227 | 228 | i2c_check() { 229 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 230 | CURRENT_SETTING=true 231 | else 232 | CURRENT_SETTING=false 233 | fi 234 | } 235 | 236 | spi_check() { 237 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 238 | CURRENT_SETTING=true 239 | else 240 | CURRENT_SETTING=false 241 | fi 242 | } 243 | 244 | get_init_sys() { 245 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 246 | SYSTEMD=1 247 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 248 | SYSTEMD=0 249 | else 250 | echo "Unrecognised init system" && exit 1 251 | fi 252 | } 253 | 254 | get_hw_rev() { 255 | hwrid=$(grep "^Revision" /proc/cpuinfo | rev | cut -c 2-3 | rev) 256 | if [ "$hwrid" == "00" ] || [ "$hwrid" == "01" ];then # Pi 1 257 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-4 | rev)" 258 | if [ "$hwrid" == "00" ];then 259 | hwgen="1260" # P1 260 | elif [ "$hwrid" == "01" ];then 261 | hwgen="1400" # J8 262 | fi 263 | else 264 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-6 | rev)" 265 | if [ "$hwrid" == "04" ];then # Pi 2 266 | hwgen="2400" 267 | elif [ "$hwrid" == "08" ];then # Pi 3 268 | hwgen="3401" 269 | elif [ "$hwrid" == "09" ];then # Pi 0 270 | hwgen="0400" 271 | elif [ "$hwrid" == "0c" ];then # Pi 0 W 272 | hwgen="0401" 273 | else # Unknown 274 | hwgen="0000" 275 | fi 276 | fi 277 | } 278 | 279 | : <<'MAINSTART' 280 | 281 | Perform all global variables declarations as well as function definition 282 | above this section for clarity, thanks! 283 | 284 | MAINSTART 285 | 286 | # intro message 287 | 288 | if [ $debugmode != "no" ]; then 289 | if [ $debuguser != "none" ]; then 290 | gitusername="$debuguser" 291 | fi 292 | if [ $debugpoint != "none" ]; then 293 | gitrepobranch="$debugpoint" 294 | fi 295 | inform "\nDEBUG MODE ENABLED" 296 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 297 | else 298 | echo "This script will enable the serial console login on your Raspberry Pi" 299 | fi 300 | 301 | # checks and init 302 | 303 | dt_check 304 | arch_check 305 | os_check 306 | 307 | 308 | if [ $debugmode != "no" ]; then 309 | echo "USER_HOME is $USER_HOME" 310 | echo "OS_NAME is $OS_NAME" 311 | echo "IS_SUPPORTED is $IS_SUPPORTED" 312 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 313 | echo 314 | fi 315 | 316 | if ! $IS_ARMHF; then 317 | warning "This hardware is not supported, sorry!" 318 | warning "Config files have been left untouched\n" 319 | exit 1 320 | fi 321 | 322 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 323 | warning "Sorry, your CPU is not supported by this installer\n" 324 | exit 1 325 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 326 | warning "Sorry, your CPU is not supported by this installer\n" 327 | exit 1 328 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 329 | warning "Sorry, your CPU is not supported by this installer\n" 330 | exit 1 331 | fi 332 | 333 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 334 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 335 | exit 1 336 | fi 337 | 338 | if $IS_RASPBIAN; then 339 | raspbian_check 340 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 341 | warning "\n--- Warning ---\n" 342 | echo "The $productname installer" 343 | echo "does not work on this version of Raspbian." 344 | echo "Check https://github.com/$gitusername/$gitreponame" 345 | echo "for additional information and support\n" 346 | exit 1 347 | fi 348 | fi 349 | 350 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 351 | warning "Your operating system is not supported, sorry!\n" 352 | exit 1 353 | fi 354 | 355 | if $IS_EXPERIMENTAL; then 356 | warning "Support for your operating system is experimental. Please visit" 357 | warning "forums.pimoroni.com if you experience issues with this product.\n" 358 | fi 359 | 360 | if [ $forcesudo == "yes" ]; then 361 | sudocheck 362 | fi 363 | 364 | if confirm "Do you wish to continue?"; then 365 | 366 | # environment preparation 367 | 368 | get_init_sys 369 | get_hw_rev 370 | 371 | if [ $SYSTEMD -eq 0 ]; then 372 | sed -i "s|^#\(.*:.*:respawn:.*ttyAMA0\)|\1|" $INITABCONF &> /dev/null 373 | if ! grep -q "^T.*:.*:respawn:.*ttyAMA0" $INITABCONF; then 374 | echo -e "T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100\n" >> $INITABCONF 375 | fi 376 | fi 377 | if grep -q "console=ttyAMA0" $BOOTCMD ; then 378 | if [ -e /proc/device-tree/aliases/serial0 ]; then 379 | sed -i "s|console=ttyAMA0|console=serial0|" $BOOTCMD &> /dev/null 380 | fi 381 | elif ! grep -q "console=ttyAMA0" $BOOTCMD && ! grep -q "console=serial0" $BOOTCMD ; then 382 | if [ -e /proc/device-tree/aliases/serial0 ]; then 383 | sed -i "s|root=|console=serial0,115200 root=|" $BOOTCMD &> /dev/null 384 | else 385 | sed -i "s|root=|console=ttyAMA0,115200 root=|" $BOOTCMD &> /dev/null 386 | fi 387 | fi 388 | inform "\nSerial console enabled\n" 389 | ASK_TO_REBOOT=true 390 | else 391 | echo -e "\nAborting...\n" 392 | fi 393 | 394 | exit 0 395 | -------------------------------------------------------------------------------- /installers/uarton: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="UART bus" # the name of the product to install 25 | scriptname="uarton" # the name of this script 26 | spacereq=1 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="yes" # whether the script requires to be ran with root privileges 31 | promptreboot="no" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="no" # whether the script is allowed to run on other OSes 39 | osreleases=( "Raspbian" "Kano" "Mate" "OSMC" "PiTop" "RetroPie" "Volumio" ) # list os-releases supported 40 | oswarning=( "Debian" "Ubuntu" ) # list experimental os-releases 41 | osdeny=( "Darwin" "Kali" "Linaro" ) # list os-releases specifically disallowed 42 | 43 | # setup variables 44 | 45 | FORCE=$1 46 | ASK_TO_REBOOT=false 47 | CURRENT_SETTING=false 48 | MIN_INSTALL=false 49 | FAILED_PKG=false 50 | REMOVE_PKG=false 51 | UPDATE_DB=false 52 | 53 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 54 | BOOTCMD=/boot/cmdline.txt 55 | CONFIG=/boot/config.txt 56 | DTBODIR=/boot/overlays 57 | APTSRC=/etc/apt/sources.list 58 | INITABCONF=/etc/inittab 59 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 60 | LOADMOD=/etc/modules 61 | 62 | # function define 63 | 64 | confirm() { 65 | if [ "$FORCE" == '-y' ]; then 66 | true 67 | else 68 | read -r -p "$1 [y/N] " response < /dev/tty 69 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 70 | true 71 | else 72 | false 73 | fi 74 | fi 75 | } 76 | 77 | prompt() { 78 | read -r -p "$1 [y/N] " response < /dev/tty 79 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 80 | true 81 | else 82 | false 83 | fi 84 | } 85 | 86 | success() { 87 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 88 | } 89 | 90 | inform() { 91 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 92 | } 93 | 94 | warning() { 95 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 96 | } 97 | 98 | newline() { 99 | echo "" 100 | } 101 | 102 | progress() { 103 | count=0 104 | until [ $count -eq 7 ]; do 105 | echo -n "..." && sleep 1 106 | ((count++)) 107 | done; 108 | if ps -C $1 > /dev/null; then 109 | echo -en "\r\e[K" && progress $1 110 | fi 111 | } 112 | 113 | sudocheck() { 114 | if [ $(id -u) -ne 0 ]; then 115 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 116 | exit 1 117 | fi 118 | } 119 | 120 | sysclean() { 121 | sudo apt-get clean && sudo apt-get autoclean 122 | sudo apt-get -y autoremove &> /dev/null 123 | } 124 | 125 | sysupdate() { 126 | if ! $UPDATE_DB; then 127 | echo "Updating apt indexes..." && progress apt-get & 128 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 129 | sleep 3 && UPDATE_DB=true 130 | fi 131 | } 132 | 133 | sysupgrade() { 134 | sudo apt-get upgrade 135 | sudo apt-get clean && sudo apt-get autoclean 136 | sudo apt-get -y autoremove &> /dev/null 137 | } 138 | 139 | sysreboot() { 140 | warning "Some changes made to your system require" 141 | warning "your computer to reboot to take effect." 142 | echo 143 | if prompt "Would you like to reboot now?"; then 144 | sync && sudo reboot 145 | fi 146 | } 147 | 148 | arch_check() { 149 | IS_ARMHF=false 150 | IS_ARMv6=false 151 | 152 | if uname -m | grep -q "armv.l"; then 153 | IS_ARMHF=true 154 | if uname -m | grep -q "armv6l"; then 155 | IS_ARMv6=true 156 | fi 157 | fi 158 | } 159 | 160 | os_check() { 161 | IS_MACOSX=false 162 | IS_RASPBIAN=false 163 | IS_SUPPORTED=false 164 | IS_EXPERIMENTAL=false 165 | OS_NAME="Unknown" 166 | 167 | if uname -s | grep -q "Darwin"; then 168 | OS_NAME="Darwin" && IS_MACOSX=true 169 | elif cat /etc/os-release | grep -q "Kali"; then 170 | OS_NAME="Kali" 171 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 172 | OS_NAME="Kano" 173 | elif whoami | grep -q "linaro"; then 174 | OS_NAME="Linaro" 175 | elif [ -d ~/.config/ubuntu-mate ];then 176 | OS_NAME="Mate" 177 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 178 | OS_NAME="PiTop" 179 | elif command -v emulationstation > /dev/null; then 180 | OS_NAME="RetroPie" 181 | elif cat /etc/os-release | grep -q "OSMC"; then 182 | OS_NAME="OSMC" 183 | elif cat /etc/os-release | grep -q "volumio"; then 184 | OS_NAME="Volumio" 185 | elif cat /etc/os-release | grep -q "Raspbian"; then 186 | OS_NAME="Raspbian" && IS_RASPBIAN=true 187 | elif cat /etc/os-release | grep -q "Debian"; then 188 | OS_NAME="Debian" 189 | elif cat /etc/os-release | grep -q "Ubuntu"; then 190 | OS_NAME="Ubuntu" 191 | fi 192 | 193 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 194 | IS_SUPPORTED=true 195 | fi 196 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 197 | IS_EXPERIMENTAL=true 198 | fi 199 | } 200 | 201 | raspbian_check() { 202 | IS_SUPPORTED=false 203 | IS_EXPERIMENTAL=false 204 | 205 | if [ -f /etc/os-release ]; then 206 | if cat /etc/os-release | grep -q "/sid"; then 207 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 208 | elif cat /etc/os-release | grep -q "bullseye"; then 209 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 210 | elif cat /etc/os-release | grep -q "buster"; then 211 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 212 | elif cat /etc/os-release | grep -q "stretch"; then 213 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 214 | elif cat /etc/os-release | grep -q "jessie"; then 215 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 216 | elif cat /etc/os-release | grep -q "wheezy"; then 217 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 218 | else 219 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 220 | fi 221 | fi 222 | } 223 | 224 | dt_check() { 225 | if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then 226 | DEVICE_TREE=false 227 | fi 228 | } 229 | 230 | i2c_check() { 231 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 232 | CURRENT_SETTING=true 233 | else 234 | CURRENT_SETTING=false 235 | fi 236 | } 237 | 238 | spi_check() { 239 | if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then 240 | CURRENT_SETTING=true 241 | else 242 | CURRENT_SETTING=false 243 | fi 244 | } 245 | 246 | get_init_sys() { 247 | if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then 248 | SYSTEMD=1 249 | elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then 250 | SYSTEMD=0 251 | else 252 | echo "Unrecognised init system" && exit 1 253 | fi 254 | } 255 | 256 | get_hw_rev() { 257 | hwrid=$(grep "^Revision" /proc/cpuinfo | rev | cut -c 2-3 | rev) 258 | if [ "$hwrid" == "00" ] || [ "$hwrid" == "01" ];then # Pi 1 259 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-4 | rev)" 260 | if [ "$hwrid" == "00" ];then 261 | hwgen="1260" # P1 262 | elif [ "$hwrid" == "01" ];then 263 | hwgen="1400" # J8 264 | fi 265 | else 266 | hwver="$(grep "^Revision" /proc/cpuinfo | rev | cut -c 1-6 | rev)" 267 | if [ "$hwrid" == "04" ];then # Pi 2 268 | hwgen="2400" 269 | elif [ "$hwrid" == "08" ];then # Pi 3 270 | hwgen="3401" 271 | elif [ "$hwrid" == "09" ];then # Pi 0 272 | hwgen="0400" 273 | elif [ "$hwrid" == "0c" ];then # Pi 0 W 274 | hwgen="0401" 275 | else # Unknown 276 | hwgen="0000" 277 | fi 278 | fi 279 | } 280 | 281 | : <<'MAINSTART' 282 | 283 | Perform all global variables declarations as well as function definition 284 | above this section for clarity, thanks! 285 | 286 | MAINSTART 287 | 288 | # intro message 289 | 290 | if [ $debugmode != "no" ]; then 291 | if [ $debuguser != "none" ]; then 292 | gitusername="$debuguser" 293 | fi 294 | if [ $debugpoint != "none" ]; then 295 | gitrepobranch="$debugpoint" 296 | fi 297 | inform "\nDEBUG MODE ENABLED" 298 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 299 | else 300 | echo "This script will disable the serial console so that" 301 | echo "serial communication with devices is operational" 302 | fi 303 | 304 | # checks and init 305 | 306 | dt_check 307 | arch_check 308 | os_check 309 | 310 | 311 | if [ $debugmode != "no" ]; then 312 | echo "USER_HOME is $USER_HOME" 313 | echo "OS_NAME is $OS_NAME" 314 | echo "IS_SUPPORTED is $IS_SUPPORTED" 315 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 316 | echo 317 | fi 318 | 319 | if ! $IS_ARMHF; then 320 | warning "This hardware is not supported, sorry!" 321 | warning "Config files have been left untouched\n" 322 | exit 1 323 | fi 324 | 325 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 326 | warning "Sorry, your CPU is not supported by this installer\n" 327 | exit 1 328 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 329 | warning "Sorry, your CPU is not supported by this installer\n" 330 | exit 1 331 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 332 | warning "Sorry, your CPU is not supported by this installer\n" 333 | exit 1 334 | fi 335 | 336 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 337 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 338 | exit 1 339 | fi 340 | 341 | if $IS_RASPBIAN; then 342 | raspbian_check 343 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 344 | warning "\n--- Warning ---\n" 345 | echo "The $productname installer" 346 | echo "does not work on this version of Raspbian." 347 | echo "Check https://github.com/$gitusername/$gitreponame" 348 | echo "for additional information and support\n" 349 | exit 1 350 | fi 351 | fi 352 | 353 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 354 | warning "Your operating system is not supported, sorry!\n" 355 | exit 1 356 | fi 357 | 358 | if $IS_EXPERIMENTAL; then 359 | warning "Support for your operating system is experimental. Please visit" 360 | warning "forums.pimoroni.com if you experience issues with this product.\n" 361 | fi 362 | 363 | if [ $forcesudo == "yes" ]; then 364 | sudocheck 365 | fi 366 | 367 | if confirm "Do you wish to continue?"; then 368 | 369 | # environment preparation 370 | 371 | get_init_sys 372 | get_hw_rev 373 | 374 | if [ $hwgen == "3401" ] || [ $hwgen == "0401" ]; then 375 | if [ -f $DTBODIR/pi3-disable-bt.dtbo ]; then 376 | if ! grep -q "^dtoverlay=pi3-disable-bt$" $CONFIG && ! grep -q "^dtoverlay=pi3-miniuart-bt$" $CONFIG; then 377 | warning "\nCommunication needs to run on UART0 for reliable operation!\n" 378 | echo "Disabling the on-board Bluetooth adapter can achieve this result." 379 | echo "We can do this for you now by loading a dedicated overlay." 380 | if confirm "Would you like the pi3-disable-bt device tree overlay to load on boot?"; then 381 | echo -e "\ndtoverlay=pi3-disable-bt" | sudo tee -a $CONFIG &> /dev/null 382 | warning "The on-board Bluetooth adapter has been disabled.\n" 383 | echo "If you wish to re-enable it, you may do so by commenting out" 384 | echo "the line starting with 'dtoverlay=pi3-disable-bt' in $CONFIG" 385 | fi 386 | fi 387 | fi 388 | fi 389 | 390 | if [ $SYSTEMD -eq 0 ]; then 391 | sed -i "s|^.*:.*:respawn:.*ttyAMA0|#&|" $INITABCONF &> /dev/null 392 | fi 393 | sed -i -e "s|console=ttyAMA0,[0-9]\+ ||" -e "s|console=serial0,[0-9]\+ ||" $BOOTCMD &> /dev/null 394 | sed -i -e "/^enable_uart=0/d" -e "/^enable_uart=1/d" $CONFIG &> /dev/null 395 | echo -e "\nYour Raspberry Pi is ready for UART communication" 396 | warning "A reboot is required before this change takes effect.\n" 397 | ASK_TO_REBOOT=true 398 | else 399 | echo -e "\nAborting...\n" 400 | fi 401 | 402 | exit 0 403 | -------------------------------------------------------------------------------- /installers/undopulse: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt purge pulseaudio 3 | sudo rm -rf /etc/pulse 4 | sudo rm /etc/systemd/system/pulseaudio.service 5 | -------------------------------------------------------------------------------- /installers/uptodate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : <<'DISCLAIMER' 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | This script is licensed under the terms of the MIT license. 15 | Unless otherwise noted, code reproduced herein 16 | was written for this script. 17 | 18 | - The Pimoroni Crew - 19 | 20 | DISCLAIMER 21 | 22 | # script control variables 23 | 24 | productname="na" # the name of the product to install 25 | scriptname="uptodate" # the name of this script 26 | spacereq=50 # minimum size required on root partition in MB 27 | debugmode="no" # whether the script should use debug routines 28 | debuguser="none" # optional test git user to use in debug mode 29 | debugpoint="none" # optional git repo branch or tag to checkout 30 | forcesudo="no" # whether the script requires to be ran with root privileges 31 | promptreboot="yes" # whether the script should always prompt user to reboot 32 | mininstall="no" # whether the script enforces minimum install routine 33 | customcmd="yes" # whether to execute commands specified before exit 34 | armhfonly="yes" # whether the script is allowed to run on other arch 35 | armv6="yes" # whether armv6 processors are supported 36 | armv7="yes" # whether armv7 processors are supported 37 | armv8="yes" # whether armv8 processors are supported 38 | raspbianonly="no" # whether the script is allowed to run on other OSes 39 | osreleases=( "Raspbian" "Kano" "Mate" "PiTop" "RetroPie" ) # list os-releases supported 40 | oswarning=() # list experimental os-releases 41 | osdeny=( "Darwin" "Debian" "Kali" "Linaro" "Ubuntu" ) # list os-releases specifically disallowed 42 | 43 | declare -A deblibpairs=( \ 44 | ["automationhat"]="automationhat" \ 45 | ["blinkt"]="blinkt" \ 46 | ["displayotron"]="dot3k" \ 47 | ["drumhat"]="drumhat" \ 48 | ["envirophat"]="envirophat" \ 49 | ["explorerhat"]="explorerhat" \ 50 | ["microdotphat"]="microdotphat" \ 51 | ["mote"]="mote" \ 52 | ["motephat"]="motephat" \ 53 | ["pantilthat"]="pantilthat" \ 54 | ["phatbeat"]="phatbeat" \ 55 | ["pianohat"]="pianohat" \ 56 | ["pibrella"]="pibrella" \ 57 | ["piglow"]="piglow" \ 58 | ["propellerhat"]="p1" \ 59 | ["rainbowhat"]="rainbowhat" \ 60 | ["scrollphat"]="scrollphat" \ 61 | ["scrollphathd"]="scrollphathd" \ 62 | ["skywriterhat"]="skywriter" \ 63 | ["unicornhat"]="unicornhat" ) 64 | 65 | # setup variables 66 | 67 | FORCE=$1 68 | ASK_TO_REBOOT=false 69 | CURRENT_SETTING=false 70 | MIN_INSTALL=false 71 | FAILED_PKG=false 72 | REMOVE_PKG=false 73 | UPDATE_DB=false 74 | 75 | AUTOSTART=~/.config/lxsession/LXDE-pi/autostart 76 | BOOTCMD=/boot/cmdline.txt 77 | CONFIG=/boot/config.txt 78 | APTSRC=/etc/apt/sources.list 79 | INITABCONF=/etc/inittab 80 | BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf 81 | LOADMOD=/etc/modules 82 | 83 | RASPOOL="http://mirrordirector.raspbian.org/raspbian/pool" 84 | RPIPOOL="http://archive.raspberrypi.org/debian/pool" 85 | DEBPOOL="http://ftp.debian.org/debian/pool" 86 | GETPOOL="https://get.pimoroni.com" 87 | 88 | # function define 89 | 90 | confirm() { 91 | if [ "$FORCE" == '-y' ]; then 92 | true 93 | else 94 | read -r -p "$1 [y/N] " response < /dev/tty 95 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 96 | true 97 | else 98 | false 99 | fi 100 | fi 101 | } 102 | 103 | prompt() { 104 | read -r -p "$1 [y/N] " response < /dev/tty 105 | if [[ $response =~ ^(yes|y|Y)$ ]]; then 106 | true 107 | else 108 | false 109 | fi 110 | } 111 | 112 | success() { 113 | echo -e "$(tput setaf 2)$1$(tput sgr0)" 114 | } 115 | 116 | inform() { 117 | echo -e "$(tput setaf 6)$1$(tput sgr0)" 118 | } 119 | 120 | warning() { 121 | echo -e "$(tput setaf 1)$1$(tput sgr0)" 122 | } 123 | 124 | newline() { 125 | echo "" 126 | } 127 | 128 | progress() { 129 | count=0 130 | until [ $count -eq 7 ]; do 131 | echo -n "..." && sleep 1 132 | ((count++)) 133 | done; 134 | if ps -C $1 > /dev/null; then 135 | echo -en "\r\e[K" && progress $1 136 | fi 137 | } 138 | 139 | sudocheck() { 140 | if [ $(id -u) -ne 0 ]; then 141 | echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" 142 | exit 1 143 | fi 144 | } 145 | 146 | sysclean() { 147 | sudo apt-get clean && sudo apt-get autoclean 148 | sudo apt-get -y autoremove &> /dev/null 149 | } 150 | 151 | sysupdate() { 152 | if ! $UPDATE_DB; then 153 | echo "Updating apt indexes..." && progress apt-get & 154 | sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } 155 | sleep 3 && UPDATE_DB=true 156 | fi 157 | } 158 | 159 | sysupgrade() { 160 | sudo apt-get upgrade 161 | sudo apt-get clean && sudo apt-get autoclean 162 | sudo apt-get -y autoremove &> /dev/null 163 | } 164 | 165 | sysreboot() { 166 | warning "Some changes made to your system require" 167 | warning "your computer to reboot to take effect." 168 | echo 169 | if prompt "Would you like to reboot now?"; then 170 | sync && sudo reboot 171 | fi 172 | } 173 | 174 | arch_check() { 175 | IS_ARMHF=false 176 | IS_ARMv6=false 177 | 178 | if uname -m | grep -q "armv.l"; then 179 | IS_ARMHF=true 180 | if uname -m | grep -q "armv6l"; then 181 | IS_ARMv6=true 182 | fi 183 | fi 184 | } 185 | 186 | os_check() { 187 | IS_MACOSX=false 188 | IS_RASPBIAN=false 189 | IS_SUPPORTED=false 190 | IS_EXPERIMENTAL=false 191 | OS_NAME="Unknown" 192 | 193 | if uname -s | grep -q "Darwin"; then 194 | OS_NAME="Darwin" && IS_MACOSX=true 195 | elif cat /etc/os-release | grep -q "Kali"; then 196 | OS_NAME="Kali" 197 | elif [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then 198 | OS_NAME="Kano" 199 | elif whoami | grep -q "linaro"; then 200 | OS_NAME="Linaro" 201 | elif [ -d ~/.config/ubuntu-mate ];then 202 | OS_NAME="Mate" 203 | elif [ -d ~/.pt-os-dashboard ] || [ -d ~/.pt-dashboard ] || [ -f ~/.pt-dashboard-config ]; then 204 | OS_NAME="PiTop" 205 | elif command -v emulationstation > /dev/null; then 206 | OS_NAME="RetroPie" 207 | elif cat /etc/os-release | grep -q "volumio"; then 208 | OS_NAME="Volumio" 209 | elif cat /etc/os-release | grep -q "Raspbian"; then 210 | OS_NAME="Raspbian" && IS_RASPBIAN=true 211 | elif cat /etc/os-release | grep -q "Debian"; then 212 | OS_NAME="Debian" 213 | elif cat /etc/os-release | grep -q "Ubuntu"; then 214 | OS_NAME="Ubuntu" 215 | fi 216 | 217 | if [[ " ${osreleases[@]} " =~ " ${OS_NAME} " ]]; then 218 | IS_SUPPORTED=true 219 | fi 220 | if [[ " ${oswarning[@]} " =~ " ${OS_NAME} " ]]; then 221 | IS_EXPERIMENTAL=true 222 | fi 223 | } 224 | 225 | raspbian_check() { 226 | IS_SUPPORTED=false 227 | IS_EXPERIMENTAL=false 228 | 229 | if [ -f /etc/os-release ]; then 230 | if cat /etc/os-release | grep -q "/sid"; then 231 | IS_SUPPORTED=false && IS_EXPERIMENTAL=true 232 | elif cat /etc/os-release | grep -q "bullseye"; then 233 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 234 | elif cat /etc/os-release | grep -q "buster"; then 235 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 236 | elif cat /etc/os-release | grep -q "stretch"; then 237 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 238 | elif cat /etc/os-release | grep -q "jessie"; then 239 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 240 | elif cat /etc/os-release | grep -q "wheezy"; then 241 | IS_SUPPORTED=true && IS_EXPERIMENTAL=false 242 | else 243 | IS_SUPPORTED=false && IS_EXPERIMENTAL=false 244 | fi 245 | fi 246 | } 247 | 248 | home_dir() { 249 | if [ $EUID -ne 0 ]; then 250 | if $IS_MACOSX; then 251 | USER_HOME=$(dscl . -read /Users/$USER NFSHomeDirectory | cut -d: -f2) 252 | else 253 | USER_HOME=$(getent passwd $USER | cut -d: -f6) 254 | fi 255 | else 256 | warning "Running as root, please log in as a regular user with sudo rights!" 257 | echo && exit 1 258 | fi 259 | } 260 | 261 | space_chk() { 262 | if command -v stat > /dev/null; then 263 | if [ $spacereq -gt $(($(stat -f -c "%a*%S" /)/10**6)) ];then 264 | echo 265 | warning "There is not enough space left to proceed with installation" 266 | if confirm "Would you like to attempt to expand your filesystem?"; then 267 | curl -sS $GETPOOL/expandfs | sudo bash && exit 1 268 | else 269 | echo && exit 1 270 | fi 271 | fi 272 | fi 273 | } 274 | 275 | timestamp() { 276 | date +%Y%m%d-%H%M 277 | } 278 | 279 | check_network() { 280 | sudo ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3 | head -n 1` &> /dev/null && return 0 || return 1 281 | } 282 | 283 | launch_url() { 284 | check_network || (error_box "You don't appear to be connected to the internet, please check your connection and try again!" && exit 1) 285 | if command -v xdg-open > /dev/null; then 286 | xdg-open "$1" && return 0 287 | else 288 | error_box "There was an error attempting to launch your browser!" 289 | fi 290 | } 291 | 292 | get_install() { 293 | check_network || (error_box "You don't appear to be connected to the internet, please check your connection and try again!" && exit 1) 294 | if [ "$1" != diagnostic ];then 295 | sysupdate && UPDATE_DB=true 296 | fi 297 | if ! command -v curl > /dev/null; then 298 | apt_pkg_install "curl" 299 | fi 300 | curl -sS https://get.pimoroni.com/$1 | bash -s - "-y" 301 | read -p "Press Enter to continue..." < /dev/tty 302 | } 303 | 304 | apt_pkg_req() { 305 | APT_CHK=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "install ok installed") 306 | 307 | if [ "" == "$APT_CHK" ]; then 308 | echo "$1 is required" 309 | true 310 | else 311 | echo "$1 is already installed" 312 | false 313 | fi 314 | } 315 | 316 | apt_pkg_install() { 317 | echo "Installing $1..." 318 | sudo apt-get --yes install "$1" 1> /dev/null || { inform "Apt failed to install $1!\nFalling back on pypi..." && return 1; } 319 | } 320 | 321 | apt_deb_chk() { 322 | BEFORE=$(dpkg-query -W "$1" 2> /dev/null) 323 | sudo apt-get --yes install "$1" &> /dev/null || return 1 324 | AFTER=$(dpkg-query -W "$1" 2> /dev/null) 325 | if [ "$BEFORE" == "$AFTER" ]; then 326 | echo "$1 is already the newest version" 327 | else 328 | echo "$1 was successfully upgraded" 329 | fi 330 | } 331 | 332 | apt_deb_install() { 333 | echo "Installing $1..." 334 | if [[ "$1" != *".deb"* ]]; then 335 | sudo apt-get --yes install "$1" &> /dev/null || inform "Apt failed to install $1!\nFalling back on pypi..." 336 | dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "install ok installed" 337 | else 338 | DEBDIR=`mktemp -d /tmp/pimoroni.XXXXXX` 339 | cd $DEBDIR 340 | wget "$GETPOOL/resources/$1" &> /dev/null 341 | sudo dpkg -i "$DEBDIR/$1" | grep "Installing $1" 342 | fi 343 | } 344 | 345 | pip_cmd_chk() { 346 | if command -v pip2 > /dev/null; then 347 | PIP2_BIN="pip2" 348 | elif command -v pip-2.7 > /dev/null; then 349 | PIP2_BIN="pip-2.7" 350 | elif command -v pip-2.6 > /dev/null; then 351 | PIP2_BIN="pip-2.6" 352 | else 353 | PIP2_BIN="pip" 354 | fi 355 | if command -v pip3 > /dev/null; then 356 | PIP3_BIN="pip3" 357 | elif command -v pip-3.3 > /dev/null; then 358 | PIP3_BIN="pip-3.3" 359 | elif command -v pip-3.2 > /dev/null; then 360 | PIP3_BIN="pip-3.2" 361 | fi 362 | } 363 | 364 | pip2_lib_req() { 365 | PIP2_CHK=$($PIP2_BIN list 2> /dev/null | grep -i "$1") 366 | 367 | if [ -z "$PIP2_CHK" ]; then 368 | true 369 | else 370 | false 371 | fi 372 | } 373 | 374 | pip3_lib_req() { 375 | PIP3_CHK=$($PIP3_BIN list 2> /dev/null | grep -i "$1") 376 | 377 | if [ -z "$PIP3_CHK" ]; then 378 | true 379 | else 380 | false 381 | fi 382 | } 383 | 384 | lib_chk() { 385 | sysupdate && pip_cmd_chk 386 | echo -e "\nChecking for installed libraries..." 387 | for debpkg in "${!deblibpairs[@]}"; do 388 | progress 3 389 | if command -v $PIP2_BIN > /dev/null && ! pip2_lib_req "${deblibpairs[$debpkg]}"; then 390 | if ! apt_deb_chk "python-$debpkg"; then 391 | PIP2_MSG=$(sudo -H $PIP2_BIN install -U "${deblibpairs[$debpkg]}" \ 392 | | grep -i -e "installed ${deblibpairs[$debpkg]}" -i -e "up-to-date: ${deblibpairs[$debpkg]}") 393 | if [[ "$PIP2_MSG" == *"up-to-date"* ]]; then 394 | echo "${deblibpairs[$debpkg]} for Python 2 is already the newest version" 395 | else 396 | echo "${deblibpairs[$debpkg]} for Python 2 was successfully upgraded" 397 | fi 398 | else 399 | sudo $PIP2_BIN uninstall -y "$debpkg" &> /dev/null 400 | fi 401 | fi 402 | if command -v $PIP3_BIN > /dev/null && ! pip3_lib_req "${deblibpairs[$debpkg]}"; then 403 | if ! apt_deb_chk "python3-$debpkg"; then 404 | PIP3_MSG=$(sudo -H $PIP3_BIN install -U "${deblibpairs[$debpkg]}" \ 405 | | grep -i -e "installed ${deblibpairs[$debpkg]}" -i -e "up-to-date: ${deblibpairs[$debpkg]}") 406 | if [[ "$PIP3_MSG" == *"up-to-date"* ]]; then 407 | echo "${deblibpairs[$debpkg]} for Python 3 is already the newest version" 408 | else 409 | echo "${deblibpairs[$debpkg]} for Python 3 was successfully upgraded" 410 | fi 411 | else 412 | sudo $PIP3_BIN uninstall -y "$debpkg" &> /dev/null 413 | fi 414 | fi 415 | done 416 | inform "\nall libraries are now up-to-date!\n" 417 | } 418 | 419 | : <<'MAINSTART' 420 | 421 | Perform all variables declarations as well as function definition 422 | above this section for clarity, thanks! 423 | 424 | MAINSTART 425 | 426 | # intro message 427 | 428 | if [ $debugmode != "no" ]; then 429 | if [ $debuguser != "none" ]; then 430 | gitusername="$debuguser" 431 | fi 432 | if [ $debugpoint != "none" ]; then 433 | gitrepobranch="$debugpoint" 434 | fi 435 | inform "\nDEBUG MODE ENABLED" 436 | echo -e "git user $gitusername and $gitrepobranch branch/tag will be used\n" 437 | else 438 | echo -e "\nThis script will make sure your Raspberry Pi is up to date" 439 | if [ "$FORCE" != '-y' ]; then 440 | inform "\nAlways be careful when running scripts and commands copied" 441 | inform "from the internet. Ensure they are from a trusted source.\n" 442 | echo -e "If you want to see what this script does before running it," 443 | echo -e "you should run: 'curl $GETPOOL/$scriptname'\n" 444 | fi 445 | fi 446 | 447 | # checks and init 448 | 449 | arch_check 450 | os_check 451 | space_chk 452 | home_dir 453 | 454 | if [ $debugmode != "no" ]; then 455 | echo "USER_HOME is $USER_HOME" 456 | echo "OS_NAME is $OS_NAME" 457 | echo "IS_SUPPORTED is $IS_SUPPORTED" 458 | echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL" 459 | echo 460 | fi 461 | 462 | if ! $IS_ARMHF; then 463 | warning "This hardware is not supported, sorry!" 464 | warning "Config files have been left untouched\n" 465 | exit 1 466 | fi 467 | 468 | if $IS_ARMv8 && [ $armv8 == "no" ]; then 469 | warning "Sorry, your CPU is not supported by this installer\n" 470 | exit 1 471 | elif $IS_ARMv7 && [ $armv7 == "no" ]; then 472 | warning "Sorry, your CPU is not supported by this installer\n" 473 | exit 1 474 | elif $IS_ARMv6 && [ $armv6 == "no" ]; then 475 | warning "Sorry, your CPU is not supported by this installer\n" 476 | exit 1 477 | fi 478 | 479 | if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then 480 | warning "This script is intended for Raspbian on a Raspberry Pi!\n" 481 | exit 1 482 | fi 483 | 484 | if $IS_RASPBIAN; then 485 | raspbian_check 486 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 487 | warning "\n--- Warning ---\n" 488 | echo "The $productname installer" 489 | echo "does not work on this version of Raspbian." 490 | echo "Check https://github.com/$gitusername/$gitreponame" 491 | echo "for additional information and support" && echo 492 | exit 1 493 | fi 494 | fi 495 | 496 | if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then 497 | warning "Your operating system is not supported, sorry!\n" 498 | exit 1 499 | fi 500 | 501 | if $IS_EXPERIMENTAL; then 502 | warning "Support for your operating system is experimental. Please visit" 503 | warning "forums.pimoroni.com if you experience issues with this product.\n" 504 | fi 505 | 506 | if [ $forcesudo == "yes" ]; then 507 | sudocheck 508 | fi 509 | 510 | if [ $uartreq == "yes" ]; then 511 | echo "Note: $productname requires UART communication" 512 | warning "The serial console will be disabled if you proceed!" 513 | fi 514 | if [ $spireq == "yes" ]; then 515 | echo -e "Note: $productname requires SPI communication" 516 | fi 517 | if [ $i2creq == "yes" ]; then 518 | echo -e "Note: $productname requires I2C communication" 519 | fi 520 | if [ $i2sreq == "yes" ]; then 521 | echo -e "Note: $productname uses the I2S interface" 522 | warning "The on-board audio chip will be disabled if you proceed!" 523 | fi 524 | 525 | newline 526 | if confirm "Do you wish to continue?"; then 527 | 528 | # environment preparation 529 | 530 | echo -e "\nBringing your system up-to-date..." 531 | if [ "$FORCE" != '-y' ]; then 532 | lib_chk 533 | fi 534 | sysupdate && sysupgrade 535 | inform "\nAll done!\n" 536 | if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then 537 | sysreboot && newline 538 | fi 539 | else 540 | echo -e "\nAborting...\n" 541 | fi 542 | 543 | exit 0 544 | -------------------------------------------------------------------------------- /learn/getstarted.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import webbrowser 4 | 5 | print("Launching Browser") 6 | webbrowser.open("http://learn.pimoroni.com", new=1, autoraise=True) 7 | -------------------------------------------------------------------------------- /resources/github-repo-terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/github-repo-terminal.png -------------------------------------------------------------------------------- /resources/pimoroni_1.0.0_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/pimoroni_1.0.0_all.deb -------------------------------------------------------------------------------- /resources/pimoroni_1.0.1_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/pimoroni_1.0.1_all.deb -------------------------------------------------------------------------------- /resources/pimoroni_1.0.2_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/pimoroni_1.0.2_all.deb -------------------------------------------------------------------------------- /resources/pimoroni_1.0.3_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/pimoroni_1.0.3_all.deb -------------------------------------------------------------------------------- /resources/pimoroni_1.0.4_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/pimoroni_1.0.4_all.deb -------------------------------------------------------------------------------- /resources/pimoroni_1.0.5_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/pimoroni_1.0.5_all.deb -------------------------------------------------------------------------------- /resources/python3-smbus1_1.1+35dbg-1_armhf.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pimoroni/get/e29ae2e8b9e5f5eee7d95e5b873851e8edbae591/resources/python3-smbus1_1.1+35dbg-1_armhf.deb -------------------------------------------------------------------------------- /support/gethelp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import webbrowser 4 | 5 | print("Launching Browser") 6 | webbrowser.open("http://forums.pimoroni.com", new=1, autoraise=True) 7 | -------------------------------------------------------------------------------- /update: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git diff --no-prefix installers/template > update.patch 4 | 5 | for FILE in installers/*; do 6 | 7 | REJECT="${FILE/installers/rejected}.rej" 8 | printf "Patching $FILE - rejections to $REJECT\n" 9 | patch --reject-file=$REJECT --input update.patch $FILE 10 | 11 | done 12 | 13 | rm update.patch 14 | -------------------------------------------------------------------------------- /update_scripts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | startpoint=73 4 | cmdpoint=1087 5 | endpoint=1117 6 | lenient="no" 7 | 8 | sourcedir="./installers" 9 | scriptlist=$(ls "$sourcedir") 10 | template="$sourcedir/template" 11 | startcheck=$(sed -n "$startpoint"p $template | grep "^# template") 12 | cmdcheck=$(sed -n "$cmdpoint"p $template | grep "^# script custom routines") 13 | endcheck=$(sed -n "$endpoint"p $template | grep "^exit 0") 14 | 15 | if [ -n "$startcheck" ] && [ -n "$endcheck" ]; then 16 | echo "lines specified match template expected patterns" 17 | else 18 | echo "lines specified do not match template expected patterns" 19 | exit 1 20 | fi 21 | 22 | for script in ${scriptlist[@]}; do 23 | validcheck=$(sed -n "$startpoint","$startpoint"p "$sourcedir/$script" | grep "template") 24 | if [ -n "$validcheck" ]; then 25 | if [ "$lenient" == "yes" ]; then 26 | endpoint=$((endpoint + 10)) 27 | blockcheck=$(sed -n "$startpoint","$endpoint"p "$sourcedir/$script" | grep "custom commands in this scope") 28 | else 29 | blockcheck=$(sed -n "$cmdpoint","$endpoint"p "$sourcedir/$script" | grep "custom commands in this scope") 30 | fi 31 | 32 | if [ -n "$blockcheck" ]; then 33 | echo "processing $script ..." 34 | variable=$(head -n "$startpoint" "$sourcedir/$script" | sed -e "$ d") 35 | common=$(sed -n "$startpoint","$endpoint"p "$template") 36 | 37 | { echo "$variable" ; echo "" ; echo "$common"; } > "$sourcedir/$script" 38 | fi 39 | fi 40 | done 41 | 42 | exit 0 43 | --------------------------------------------------------------------------------