| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | #!/bin/bash | 
					
						
							|  |  |  | # This script is for automating the install for both displays, | 
					
						
							|  |  |  | # The 2-colour and 3-colour one. | 
					
						
							| 
									
										
										
										
											2018-12-24 21:06:38 +01:00
										 |  |  | # Version: 1.4 (Late December) | 
					
						
							| 
									
										
										
										
											2019-01-05 16:16:03 +01:00
										 |  |  | # Well tested and confirmed on 5th Jan 2019 | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:06:38 +01:00
										 |  |  | # Copyright by aceisace | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Getting input to see which E-Paper version is currently being used. | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | echo -e "\e[1mWhich version of the E-Paper display are you using?" | 
					
						
							|  |  |  | echo -e "\e[97mEnter \e[91m2 \e[97m if you are using the 2-Colour E-Paper" | 
					
						
							|  |  |  | echo -e "\e[97mEnter \e[91m3 \e[97m if you are using the 3-Colour E-Paper" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:54:06 +02:00
										 |  |  | echo -e "\e[97mconfirm your selection with [ENTER]" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:52:33 +02:00
										 |  |  | read -r -p 'Please type in the number now:  ' digit | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if [ -z "$digit" ]; then | 
					
						
							|  |  |  |     echo "You didn't enter anything." | 
					
						
							|  |  |  |     echo "Aborting now." | 
					
						
							|  |  |  |     exit | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ "$digit" != 2 ] && [ "$digit" != 3 ]; then | 
					
						
							|  |  |  |     echo "invalid number, only 2 or 3 can be accepted." | 
					
						
							|  |  |  |     echo "Aborting now." | 
					
						
							|  |  |  |     exit | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:09:19 +02:00
										 |  |  | if [ "$digit" = 2 ] || [ "$digit" = 3 ]; then | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  |     echo "" | 
					
						
							|  |  |  |     echo -e "\e[1;36m"Your input was accepted"\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-01 23:09:50 +02:00
										 |  |  |     echo -e "\e[1;36m"The installer will finish the rest now. You can enjoy a break in the meanwhile."\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  |     echo "" | 
					
						
							| 
									
										
										
										
											2018-10-01 22:09:19 +02:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Updating and upgrading the system, without taking too much space | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | echo -e "\e[1;36m"Running apt-get update and apt-get dist-upgrade for you..."\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | echo -e "\e[1;36m"This will take a while, sometimes up to 30 mins"\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-02 01:30:28 +02:00
										 |  |  | sudo apt-get update && sudo apt-get dist-upgrade -y | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | echo -e "\e[1;36m"System successfully updated and upgraded!"\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  | echo "" | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Installing a few packages which are missing on Raspbian Stretch Lite | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | echo -e "\e[1;36m"Installing a few packages that are missing on Raspbian Stretch Lite..."\e[0m" | 
					
						
							| 
									
										
										
										
											2019-01-04 19:03:23 +01:00
										 |  |  | sudo apt-get install python3-pip python-rpi.gpio-dbgsym python3-rpi.gpio python-rpi.gpio python3-rpi.gpio-dbgsym python3-spidev git libopenjp2-7-dev libtiff5 -y | 
					
						
							| 
									
										
										
										
											2019-01-04 20:03:29 +01:00
										 |  |  | pip3 install Pillow==5.3.0 | 
					
						
							|  |  |  | sudo pip3 install Pillow==5.3.0 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  | echo "" | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Running apt-get clean and apt-get autoremove | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | echo -e "\e[1;36m"Cleaning a bit of mess to free up some space..."\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-02 01:30:28 +02:00
										 |  |  | sudo apt-get clean && sudo apt-get autoremove -y | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  | echo "" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-16 23:22:07 +02:00
										 |  |  | # Installing packages required by the main script | 
					
						
							|  |  |  | echo -e "\e[1;36m"Installing a few required packages for the E-Paper Software"\e[0m" | 
					
						
							|  |  |  | sudo pip3 install pyowm | 
					
						
							|  |  |  | sudo pip3 install ics | 
					
						
							|  |  |  | pip3 install pyowm | 
					
						
							|  |  |  | pip3 install ics | 
					
						
							|  |  |  | echo "" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-16 23:33:16 +02:00
										 |  |  | echo -e "\e[1;36m"Installing the E-Paper-Calendar Software for your display"\e[0m" | 
					
						
							|  |  |  | git clone https://github.com/aceisace/E-Paper-Calendar-with-iCal-sync-and-live-weather | 
					
						
							|  |  |  | mkdir E-Paper-Master | 
					
						
							|  |  |  | cd E-Paper-Calendar-with-iCal-sync-and-live-weather | 
					
						
							|  |  |  | cp -r Calendar /home/pi/E-Paper-Master/ | 
					
						
							|  |  |  | cp README.md /home/pi/E-Paper-Master/ | 
					
						
							|  |  |  | cp LICENSE /home/pi/E-Paper-Master/ | 
					
						
							|  |  |  | cp -r .git /home/pi/E-Paper-Master/ | 
					
						
							|  |  |  | cd | 
					
						
							|  |  |  | sudo rm -r E-Paper-Calendar-with-iCal-sync-and-live-weather | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Using this part for the 2-colour E-Paper version | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | if [ "$digit" = 2 ]; then | 
					
						
							| 
									
										
										
										
											2018-10-16 23:22:07 +02:00
										 |  |  |     # execute the monocolour-converter to convert all 3-colour icons to 2-colour ones | 
					
						
							|  |  |  |     python3.5 /home/pi/E-Paper-Master/Calendar/monocolour-converter.py | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     # edit the settings file for the 2-colour display option | 
					
						
							|  |  |  |     sed -i 's/display_colours = "bwr"/display_colours = "bw"/' /home/pi/E-Paper-Master/Calendar/settings.py | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2018-10-02 01:24:28 +02:00
										 |  |  |     # add a short info | 
					
						
							| 
									
										
										
										
											2018-10-02 01:03:33 +02:00
										 |  |  |     cat > /home/pi/E-Paper-Master/Info.txt << EOF | 
					
						
							| 
									
										
										
										
											2018-10-16 23:22:07 +02:00
										 |  |  | This document contains a short info of the E-Paper-Calendar software version | 
					
						
							| 
									
										
										
										
											2018-10-02 01:10:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | Version: 2-Colour E-Paper-version | 
					
						
							| 
									
										
										
										
											2019-02-02 22:03:07 +01:00
										 |  |  | Installer version: 1.5 (Mid February 2018) | 
					
						
							| 
									
										
										
										
											2018-10-16 23:22:07 +02:00
										 |  |  | configuration file: /home/pi/E-Paper-Master/Calendar/settings.py | 
					
						
							| 
									
										
										
										
											2018-10-02 01:10:01 +02:00
										 |  |  | If the time was set correctly, you installed this software on: | 
					
						
							| 
									
										
										
										
											2018-10-02 01:03:33 +02:00
										 |  |  | EOF | 
					
						
							|  |  |  |     echo "$(date)" >> /home/pi/E-Paper-Master/Info.txt | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  |     echo "" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Using this part for the 3-colour E-Paper version | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | if [ "$digit" = 3 ]; then | 
					
						
							| 
									
										
										
										
											2018-10-02 01:24:28 +02:00
										 |  |  |     # add a short info | 
					
						
							|  |  |  |     cat > /home/pi/E-Paper-Master/Info.txt << EOF | 
					
						
							|  |  |  | This document contains a short info of the version | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Version: 3-Colour E-Paper-version | 
					
						
							| 
									
										
										
										
											2019-02-02 22:03:07 +01:00
										 |  |  | Installer version: 1.5 (Mid February 2019) | 
					
						
							| 
									
										
										
										
											2018-10-16 23:22:07 +02:00
										 |  |  | configuration file: /home/pi/E-Paper-Master/Calendar/settings.py | 
					
						
							| 
									
										
										
										
											2018-10-02 01:24:28 +02:00
										 |  |  | If the time was set correctly, you installed this software on: | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  |     echo "$(date)" >> /home/pi/E-Paper-Master/Info.txt | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  |     echo "" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Setting up supervisor | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | echo -e "\e[1;36m"Setting up the script to start at boot..."\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-02 01:30:28 +02:00
										 |  |  | sudo apt-get install supervisor -y | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | sudo bash -c 'cat > /etc/supervisor/conf.d/E-Paper.conf' << EOF | 
					
						
							|  |  |  | [program:E-Paper] | 
					
						
							| 
									
										
										
										
											2019-02-02 22:03:07 +01:00
										 |  |  | command = sudo /usr/bin/python3.5 /home/pi/E-Paper-Master/Calendar/E-Paper.py | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | stdout_logfile = /home/pi/E-Paper-Master/E-Paper.log | 
					
						
							| 
									
										
										
										
											2018-12-24 21:06:38 +01:00
										 |  |  | stdout_logfile_maxbytes = 1MB | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | stderr_logfile = /home/pi/E-Paper-Master/E-Paper-err.log | 
					
						
							| 
									
										
										
										
											2018-12-24 21:06:38 +01:00
										 |  |  | stderr_logfile_maxbytes = 1MB | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sudo service supervisor start E-Paper | 
					
						
							| 
									
										
										
										
											2018-10-01 22:23:33 +02:00
										 |  |  | echo "" | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 22:14:19 +02:00
										 |  |  | # Final words | 
					
						
							| 
									
										
										
										
											2018-09-09 21:22:19 +02:00
										 |  |  | echo -e "\e[1;36m"The install was successful"\e[0m" | 
					
						
							| 
									
										
										
										
											2018-10-01 21:38:23 +02:00
										 |  |  | echo -e "\e[1;36m"The programm will now start at every boot."\e[0m" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 13:29:04 +02:00
										 |  |  | echo -e "\e[1;31m"Please enter your details in the file 'settings.py'."\e[0m" | 
					
						
							|  |  |  | echo -e "\e[1;31m"If this file is not modified, the programm will not start"\e[0m" | 
					
						
							| 
									
										
										
										
											2018-09-23 23:12:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 13:29:04 +02:00
										 |  |  | echo -e "\e[1;36m"To modify the settings file, enter:"\e[0m" | 
					
						
							|  |  |  | echo -e "\e[1;36m"nano /home/pi/E-Paper-Master/Calendar/settings.py"\e[0m" |