Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#!/bin/bash | ||
|
||
: <<'DISCLAIMER' | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
This script is licensed under the terms of the MIT license. | ||
Unless otherwise noted, code reproduced herein | ||
was written for this script. | ||
- The Pimoroni Crew - | ||
DISCLAIMER | ||
|
||
# script control variables | ||
|
||
FORCE=$1 | ||
GAMEPAD="picadehat-default" | ||
|
||
# function define | ||
|
||
confirm() { | ||
if [ "$FORCE" == '-y' ]; then | ||
true | ||
else | ||
read -r -p "$1 [y/N] " response < /dev/tty | ||
if [[ $response =~ ^(yes|y|Y)$ ]]; then | ||
true | ||
else | ||
false | ||
fi | ||
fi | ||
} | ||
|
||
prompt() { | ||
read -r -p "$1 [y/N] " response < /dev/tty | ||
if [[ $response =~ ^(yes|y|Y)$ ]]; then | ||
true | ||
else | ||
false | ||
fi | ||
} | ||
|
||
success() { | ||
echo -e "$(tput setaf 2)$1$(tput sgr0)" | ||
} | ||
|
||
inform() { | ||
echo -e "$(tput setaf 6)$1$(tput sgr0)" | ||
} | ||
|
||
warning() { | ||
echo -e "$(tput setaf 1)$1$(tput sgr0)" | ||
} | ||
|
||
newline() { | ||
echo "" | ||
} | ||
|
||
progress() { | ||
count=0 | ||
until [ $count -eq $1 ]; do | ||
echo -n "..." && sleep 1 | ||
((count++)) | ||
done | ||
echo | ||
} | ||
sudocheck() { | ||
if [ $(id -u) -ne 0 ]; then | ||
echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n" | ||
exit 1 | ||
fi | ||
} | ||
|
||
sysclean() { | ||
sudo apt-get clean && sudo apt-get autoclean | ||
sudo apt-get -y autoremove &> /dev/null | ||
} | ||
|
||
sysupdate() { | ||
if ! $UPDATE_DB; then | ||
echo "Updating apt indexes..." && progress 3 & | ||
sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; } | ||
echo "Reading package lists..." | ||
progress 3 && UPDATE_DB=true | ||
fi | ||
} | ||
|
||
sysupgrade() { | ||
sudo apt-get upgrade | ||
sudo apt-get clean && sudo apt-get autoclean | ||
sudo apt-get -y autoremove &> /dev/null | ||
} | ||
|
||
sysreboot() { | ||
warning "Some changes made to your system require" | ||
warning "your computer to reboot to take effect." | ||
newline | ||
if prompt "Would you like to reboot now?"; then | ||
sync && sudo reboot | ||
fi | ||
} | ||
|
||
: <<'MAINSTART' | ||
Perform all global variables declarations as well as function definition | ||
above this section for clarity, thanks! | ||
MAINSTART | ||
|
||
# copying gamepad configuration file | ||
|
||
sudo service picadehatd stop | ||
sudo rm /usr/bin/picadehatd | ||
sudo cp $GAMEPAD /usr/bin/picadehatd | ||
sudo chmod +x /usr/bin/picadehatd | ||
sudo service picadehatd start | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
gamepads/adafruit-pigrrl-pcb → gamepads/pigrrl-default
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters