2018-10-01 21:38:23 +02:00
|
|
|
#!/bin/bash
|
2019-11-25 21:46:30 +01:00
|
|
|
# E-Paper-Calendar software installer for Raspberry Pi running Debian 10 (a.k.a. Buster) with Desktop
|
|
|
|
# Version: 1.7 (Early Dec 2019)
|
2019-04-18 00:53:46 +02:00
|
|
|
|
2019-02-03 16:27:54 +01:00
|
|
|
echo -e "\e[1mPlease select an option from below:"
|
2019-12-06 20:03:53 +01:00
|
|
|
echo -e "\e[97mEnter \e[91m1 \e[97m to update the E-Paper software" #Option 1 : UPDATE
|
|
|
|
echo -e "\e[97mEnter \e[91m2 \e[97m to install the E-Paper software" #Option 2 : INSTALL
|
|
|
|
echo -e "\e[97mEnter \e[91m3 \e[97m to uninstall the E-Paper software" #Option 3 : UNINSTALL
|
2019-02-03 16:27:54 +01:00
|
|
|
echo -e "\e[97mConfirm your selection with [ENTER]"
|
|
|
|
read -r -p 'Waiting for input... ' option
|
2018-10-01 21:38:23 +02:00
|
|
|
|
2019-12-06 20:03:53 +01:00
|
|
|
# Invalid number selected, abort
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ "$option" != 1 ] && [ "$option" != 2 ] && [ "$option" != 3 ]; then echo -e "invalid number, aborting now" exit
|
2018-10-01 21:38:23 +02:00
|
|
|
fi
|
2019-12-06 20:03:53 +01:00
|
|
|
|
|
|
|
# No option selected, abort
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ -z "$option" ]; then echo -e "You didn't enter anything, aborting now." exit
|
2018-10-01 21:38:23 +02:00
|
|
|
fi
|
2019-12-06 20:03:53 +01:00
|
|
|
|
|
|
|
# What to do when uninstalling software
|
2019-02-06 02:17:56 +01:00
|
|
|
if [ "$option" = 3 ]; then
|
2019-12-17 00:44:27 +01:00
|
|
|
|
|
|
|
# Remove requirements of software
|
|
|
|
echo -e "\e[1;36m"Removing requirements for Inky-Calendar software"\e[0m"
|
|
|
|
cd /home/$USER/Inky-Calendar && pip3 uninstall -r requirements.txt && sudo apt-get clean && sudo apt-get autoremove -y
|
|
|
|
|
|
|
|
# Remove configuration file for supervisor if it exists
|
|
|
|
if [ -e /etc/supervisor/conf.d/Inky-Calendar.conf ]; then sudo rm /etc/supervisor/conf.d/Inky-Calendar.conf
|
2019-02-06 02:17:56 +01:00
|
|
|
fi
|
2019-12-17 00:44:27 +01:00
|
|
|
|
|
|
|
# Print message that libraries have been uninstalled now
|
2019-04-18 16:48:08 +02:00
|
|
|
echo -e "\e[1;36m"The libraries have been removed successfully"\e[0m"
|
2019-12-17 00:44:27 +01:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# Remove the Inky-Calendar directory if it exists
|
2019-04-17 17:05:13 +02:00
|
|
|
echo -e "Removing the Inky-Calendar folder if it exists"
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ -d "/home/$USER/Inky-Calendar" ]; then
|
|
|
|
sudo rm -r /home/$USER/Inky-Calendar/
|
2019-12-06 20:03:53 +01:00
|
|
|
echo -e "\e[1;36m"Found Inky-Calendar folder and deleted it"\e[0m"
|
2019-02-06 02:17:56 +01:00
|
|
|
fi
|
2019-04-18 16:48:08 +02:00
|
|
|
echo -e "\e[1;36m"All done!"\e[0m"
|
2018-10-01 22:09:19 +02:00
|
|
|
fi
|
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ "$option" = 1 ]; then # UPDATE software
|
2019-06-18 17:17:54 +02:00
|
|
|
echo -e "\e[1;36m"Checking if the Inky-Calendar folder exists..."\e[0m"
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ -d "/home/$USER/Inky-Calendar" ]; then
|
|
|
|
echo -e "Found Inky-Calendar directory in /home/$USER"
|
2019-02-03 16:27:54 +01:00
|
|
|
sleep 2
|
2019-06-18 17:17:54 +02:00
|
|
|
echo -e "To prevent overwriting the Inky-Calendar folder, the installer will not continue."
|
|
|
|
echo -e "Please rename the Inky-Calendar folder and then re-run the installer"
|
|
|
|
exit
|
2019-02-03 16:27:54 +01:00
|
|
|
fi
|
2019-02-06 02:17:56 +01:00
|
|
|
fi
|
2019-02-03 16:27:54 +01:00
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ "$option" = 1 ] || [ "$option" = 2 ]; then # This happens when installing or updating
|
2019-04-18 16:48:08 +02:00
|
|
|
# Ask to update system
|
|
|
|
echo -e "\e[1;36m"Would you like to update and upgrade the operating system first?"\e[0m"
|
|
|
|
sleep 1
|
|
|
|
echo -e "\e[97mIt is not scrictly required, but highly recommended."
|
|
|
|
sleep 1
|
|
|
|
echo -e "\e[97mPlease note that updating may take quite some time, in rare cases up to 1 hour."
|
|
|
|
sleep 1
|
|
|
|
echo -e "\e[97mPlease type [y] for yes or [n] for no and confirm your selection with [ENTER]"
|
|
|
|
read -r -p 'Waiting for input... ' update
|
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
if [ "$update" != Y ] && [ "$update" != y ] && [ "$update" != N ] && [ "$update" != n ]; then echo -e "invalid input, aborting now" exit
|
2019-04-18 16:48:08 +02:00
|
|
|
fi
|
2019-12-17 00:44:27 +01:00
|
|
|
|
|
|
|
if [ -z "$update" ]; then echo -e "You didn't enter anything, aborting now." exit
|
2019-04-18 16:48:08 +02:00
|
|
|
fi
|
2019-12-06 20:03:53 +01:00
|
|
|
|
2019-04-18 16:48:08 +02:00
|
|
|
if [ "$update" = Y ] || [ "$update" = y ]; then
|
|
|
|
# Updating and upgrading the system, without taking too much space
|
|
|
|
echo -e "\e[1;36m"Running apt-get update and apt-get dist-upgrade for you..."\e[0m"
|
|
|
|
sleep 1
|
|
|
|
echo -e "\e[1;36m"This will take a while, sometimes up to 1 hour"\e[0m"
|
2019-12-17 00:44:27 +01:00
|
|
|
sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get clean
|
2019-04-18 16:48:08 +02:00
|
|
|
echo -e "\e[1;36m"System successfully updated and upgraded!"\e[0m"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
# Cloning Inky-Calendar repo
|
|
|
|
echo -e "\e[1;36m"Cloning Inky-Calendar repo from Github"\e[0m"
|
|
|
|
cd /home/$USER && git clone -b dev https://github.com/aceisace/Inky-Calendar
|
|
|
|
|
2019-04-18 16:48:08 +02:00
|
|
|
# Installing dependencies
|
2019-12-17 00:44:27 +01:00
|
|
|
echo -e "\e[1;36m"Installing requirements for Inky-Calendar software"\e[0m"
|
|
|
|
cd /home/$USER/Inky-Calendar && pip3 install -r requirements.txt
|
2019-12-06 20:03:53 +01:00
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
# Create symlinks of settings and configuration file
|
|
|
|
ln -s /home/$USER/Inky-Calendar/settings/settings.py /home/$USER/Inky-Calendar/modules/
|
|
|
|
ln -s /home/$USER/Inky-Calendar/settings/configuration.py /home/$USER/Inky-Calendar/modules/
|
2019-02-03 16:27:54 +01:00
|
|
|
|
2019-02-06 02:17:56 +01:00
|
|
|
# add a short info
|
2019-04-17 17:05:13 +02:00
|
|
|
cat > /home/pi/Inky-Calendar/Info.txt << EOF
|
|
|
|
This document contains a short info of the Inky-Calendar software version
|
2019-02-03 16:27:54 +01:00
|
|
|
|
2019-11-25 21:46:30 +01:00
|
|
|
Version: 1.7
|
2019-12-17 00:44:27 +01:00
|
|
|
Installer version: 1.7 (Mid December 2019)
|
|
|
|
settings file: /home/pi/Inky-Calendar/settings/settings.py
|
2019-02-05 16:14:46 +01:00
|
|
|
If the time was set correctly, you installed this software on:
|
2019-02-03 16:27:54 +01:00
|
|
|
EOF
|
2019-04-17 17:05:13 +02:00
|
|
|
echo "$(date)" >> /home/pi/Inky-Calendar/Info.txt
|
2019-02-06 02:17:56 +01:00
|
|
|
echo ""
|
2019-02-03 16:27:54 +01:00
|
|
|
|
|
|
|
# Setting up supervisor
|
2019-02-06 02:17:56 +01:00
|
|
|
echo -e "\e[1;36m"Setting up auto-start of script at boot"\e[0m"
|
2019-02-03 16:27:54 +01:00
|
|
|
sudo apt-get install supervisor -y
|
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
sudo bash -c 'cat > /etc/supervisor/conf.d/inkycal.conf' << EOF
|
2019-11-25 21:46:30 +01:00
|
|
|
[program:Inky-Calendar]
|
2019-12-17 00:44:27 +01:00
|
|
|
command = /usr/bin/python3 /home/$USER/Inky-Calendar/modules/inkycal.py
|
|
|
|
stdout_logfile = /home/$USER/Inky-Calendar/logs/logfile.log
|
2019-11-25 21:46:30 +01:00
|
|
|
stdout_logfile_maxbytes = 5MB
|
2019-12-17 00:44:27 +01:00
|
|
|
stderr_logfile = /home/$USER/Inky-Calendar/logs/errors.log
|
2019-11-25 21:46:30 +01:00
|
|
|
stderr_logfile_maxbytes = 5MB
|
2019-12-17 00:44:27 +01:00
|
|
|
user = $USER
|
|
|
|
startsecs = 30
|
2019-02-03 16:27:54 +01:00
|
|
|
EOF
|
|
|
|
|
2019-12-17 00:44:27 +01:00
|
|
|
sudo service supervisor reload
|
|
|
|
sudo service supervisor start Inky-Calendar
|
2019-03-12 17:33:33 +01:00
|
|
|
|
2019-02-03 16:27:54 +01:00
|
|
|
echo ""
|
2018-09-09 21:22:19 +02:00
|
|
|
|
2019-02-03 16:27:54 +01:00
|
|
|
# Final words
|
|
|
|
echo -e "\e[1;36m"The install was successful"\e[0m"
|
2019-02-10 23:42:11 +01:00
|
|
|
echo -e "\e[1;36m"The programm is set to start at every boot."\e[0m"
|
2019-05-12 17:32:16 +02:00
|
|
|
|
|
|
|
echo -e "\e[1;31m"To enter your personal details, please use"\e[0m"
|
|
|
|
echo -e "\e[1;31m"the Settings-Web-UI.html web-page"\e[0m"
|
|
|
|
echo -e "\e[1;36m"To do so, open the file Settings-Web-UI.html from"\e[0m"
|
|
|
|
echo -e "\e[1;36m"/home/pi/Inky-Calendar/Settings-Web-UI.html with your browser,"\e[0m"
|
|
|
|
echo -e "\e[1;36m"add your details, click on generate and copy the settings.py"\e[0m"
|
2019-12-06 20:03:53 +01:00
|
|
|
echo -e "\e[1;36m"file to /home/pi/Inky-Calendar/settings/setting.py"\e[0m"
|
2019-05-12 17:32:16 +02:00
|
|
|
|
2019-02-03 17:03:28 +01:00
|
|
|
echo -e "\e[1;36m"You can test if the programm works by typing:"\e[0m"
|
2019-12-17 00:44:27 +01:00
|
|
|
echo -e "\e[1;36m"python3 /home/$USER/Inky-Calendar/Calendar/E-Paper.py"\e[0m"
|
2019-02-03 16:27:54 +01:00
|
|
|
fi
|