Last active
April 6, 2018 01:35
-
-
Save exp0nge/f751ba41287dea3cde603a65161ea53a to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
#----make sure this is run as root | |
user=`id -u` | |
if [ $user -ne 0 ]; then | |
echo "This script requires root permissions. Please run this script with sudo." | |
exit | |
fi | |
#----ascii art! | |
echo " _ _ _ _ _ _ _ " | |
echo "| | (_) | | | | | | | | | " | |
echo "| |_ _| |__ ___ | |_ | |__ ___ ___ | |_ ___| |_ _ __ __ _ _ __ " | |
echo "| __| | '_ \ / _ \| __| | '_ \ / _ \ / _ \| __/ __| __| '__/ _\` | '_ \ " | |
echo "| |_| | |_) | (_) | |_ | |_) | (_) | (_) | |_\__ \ |_| | | (_| | |_) |" | |
echo " \__| |_.__/ \___/ \__| |_.__/ \___/ \___/ \__|___/\__|_| \__,_| .__/ " | |
echo " _/ | | | " | |
echo " |__/ |_| " | |
#----intro message | |
echo "" | |
echo "-----------------------------------------------------------------------" | |
echo "Welcome! Let's set up your Raspberry Pi with the TJBot software." | |
echo "" | |
echo "Important: This script was designed for setting up a Raspberry Pi after" | |
echo "a clean install of Raspbian. If you are running this script on a" | |
echo "Raspberry Pi that you've used for other projects, please take a look at" | |
echo "what this script does BEFORE running it to ensure you are comfortable" | |
echo "with its actions (e.g. performing an OS update, installing software" | |
echo "packages, removing old packages, etc.)" | |
echo "-----------------------------------------------------------------------" | |
#----test raspbian version: 8 is jessie, 9 is stretch | |
RASPIAN_VERSION_ID=`cat /etc/os-release | grep VERSION_ID | cut -d '"' -f 2` | |
RASPIAN_VERSION=`cat /etc/os-release | grep VERSION | grep -v ID | cut -d '"' -f 2` | |
if [ $RASPIAN_VERSION_ID -ne 8 ] && [ $RASPIAN_VERSION_ID -ne 9 ]; then | |
echo "Warning: it looks like your Raspberry Pi is not running Raspian (Jessie)" | |
echo "or Raspian (Stretch). TJBot has only been tested on these versions of" | |
echo "Raspian." | |
echo "" | |
fi | |
#----disabling ipv6 | |
# echo "" | |
# echo "In some networking environments, disabling ipv6 may help your Pi get on" | |
# echo "the network." | |
# read -p "Disable ipv6? [y/N] " choice </dev/tty | |
# case "$choice" in | |
# "y" | "Y") | |
# echo "Disabling ipv6" | |
# echo " ipv6.disable=1" | tee -a /boot/cmdline.txt | |
# echo "ipv6 has been disabled. It will take effect after rebooting." | |
# ;; | |
# *) ;; | |
# esac | |
#----setting local to US | |
echo "" | |
echo "Forcing locale to en-US. Please ignore any errors below." | |
export LC_ALL="en_US.UTF-8" | |
echo "en_US.UTF-8 UTF-8" | tee -a /etc/locale.gen | |
locale-gen en_US.UTF-8 | |
#----nodejs install | |
NODE_VERSION=$(node --version 2>&1) | |
NODE_LEVEL=$(node --version 2>&1 | cut -d '.' -f 1 | awk '{print substr($0,2,1)}') | |
# Node.js version 6 for Jessie | |
if [ $RASPIAN_VERSION_ID -eq 8 ]; then | |
RECOMMENDED_NODE_LEVEL="6" | |
# Node.js version 7 for Stretch | |
elif [ $RASPIAN_VERSION_ID -eq 9 ]; then | |
RECOMMENDED_NODE_LEVEL="7" | |
# Node.js version 7 for anything else | |
else | |
RECOMMENDED_NODE_LEVEL="7" | |
fi | |
echo "" | |
if [ $NODE_LEVEL -ge $RECOMMENDED_NODE_LEVEL ]; then | |
echo "Node.js version $NODE_VERSION is installed, which is the recommended version for" | |
echo "Raspian $RASPIAN_VERSION. Congratulations!" | |
else | |
echo "Node.js version $NODE_VERSION is currently installed. We recommend installing" | |
echo "Node.js version $RECOMMENDED_NODE_LEVEL for Raspian $RASPIAN_VERSION." | |
curl -sL https://deb.nodesource.com/setup_7.x | sudo bash - | |
apt-get install -y nodejs | |
fi | |
#----remove outdated apt packages | |
echo "" | |
echo "Removing unused software packages [apt-get autoremove]" | |
apt-get -y autoremove | |
#----clone tjbot | |
echo "" | |
echo "We are ready to clone the TJBot project." | |
export TJBOT_DIR='/home/pi/tjbot' | |
if [ ! -d $TJBOT_DIR ]; then | |
echo "Cloning TJBot project to $TJBOT_DIR" | |
sudo -u $SUDO_USER git clone https://github.com/ibmtjbot/tjbot.git $TJBOT_DIR | |
else | |
echo "TJBot project already exists in $TJBOT_DIR, leaving it alone" | |
fi | |
echo "Disabling the kernel modules for the built-in audio jack." | |
cp $TJBOT_DIR/bootstrap/tjbot-blacklist-snd.conf /etc/modprobe.d/ | |
#----installation complete | |
sleep_time=0.1 | |
echo "" | |
echo "" | |
echo " .yNNs\` " | |
sleep $sleep_time | |
echo " :hhhh- " | |
sleep $sleep_time | |
echo "/ssssssssssssssssssssssssssssssssssssssssssssssssssssssssss+" | |
sleep $sleep_time | |
echo "yNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMNmmmNMMMMMMMMMMMMMMMMMMMMMMNmmmMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMNd/\`\`\`.+NNMMMMMMMMMMMMMMMMNm+.\` \`/dNMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMNo \`hMMMMMMMMMMMMMMMMMMy\` oNMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMNm+.\`\`-sNMMMMMMMMMMMMMMMMMNNs-\`\`.+mNMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yMMMMMMMMMMMMMMNmmMMMMMMMMMMMMMMMMMMMMMMMMmmNMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "yNNNNNMMMMMMMMMMMMNNNNNNMMNNNNNNNNNNMMMMMMMMMMMMMMMMMMMNNNMy" | |
sleep $sleep_time | |
echo "-::::::::::::::::::::::::::::::::::::::::::::::::::::::::::-" | |
sleep $sleep_time | |
echo " " | |
sleep $sleep_time | |
echo " \`\`\`\`\`\`\`\`....--::::////++++ooossyyhhhhh/" | |
sleep $sleep_time | |
echo "//++ossssssyyyyhhddmmmmmmmmmmmmNNNNNMMNNNNNNMMMMMMMMMMMMMNNo" | |
sleep $sleep_time | |
echo "dMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy" | |
sleep $sleep_time | |
echo "sMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd" | |
sleep $sleep_time | |
echo "oNMMMMMMMMMMMMMMMMNNNNNNNNMMMMMMNNNNNmmmmmmmmmddhhhhyyyyssss" | |
sleep $sleep_time | |
echo "+Nmmmddhhhhyyyyssoo++++/////:::---....\`\`\`\`\`\`\`\` " | |
sleep $sleep_time | |
echo "" | |
sleep $sleep_time | |
echo "-------------------------------------------------------------------" | |
sleep $sleep_time | |
echo "Setup complete. Your Raspberry Pi is now set up as a TJBot! ;)" | |
sleep $sleep_time | |
echo "-------------------------------------------------------------------" | |
echo "" | |
#----tests | |
echo "" | |
echo "TJBot includes a set of hardware tests to ensure all of the hardware is" | |
echo "functioning properly. If you have made any changes to the camera or" | |
echo "sound configuration, we recommend rebooting first before running these" | |
echo "tests as they may fail. You can run these tests at anytime by running" | |
echo "the runTests.sh script in the tjbot/bootstrap folder." | |
echo "" | |
$TJBOT_DIR/runTests.sh $TJBOT_DIR | |
#----reboot | |
echo "" | |
echo "Rebooting." | |
reboot now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment