forked from aceinnolab/Inkycal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
93 lines (74 loc) · 3.28 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Inkycal v2.0.0 bash installer
echo -e "\e[1mPlease select an option from below:"
echo -e "\e[97mEnter \e[91m[1]\e[97m to update Inkycal" #Option 1 : UPDATE
echo -e "\e[97mEnter \e[91m[2]\e[97m to install Inkycal" #Option 2 : INSTALL
echo -e "\e[97mEnter \e[91m[3]\e[97m to uninstall Inkycal" #Option 3 : UNINSTALL
echo -e "\e[97mConfirm your selection with [ENTER]"
read -r -p 'Waiting for input... ' option
# Invalid number selected, abort
if [ "$option" != 1 ] && [ "$option" != 2 ] && [ "$option" != 3 ];
then echo -e "invalid number, aborting now" exit
fi
# No option selected, abort
if [ -z "$option" ];
then echo -e "You didn't enter anything, aborting now." exit
fi
# Uninstall Inkycal
if [ "$option" = 1 ] || [ "$option" = 3 ]; then
# pip3 uninstall Inkycal
echo -e "\e[1;36m"Uninstalling Inkycal.."\e[0m"
pip3 uninstall Inkycal -y
# Remove crontab file
echo -e "\e[1;36m"Reverting crontab file"\e[0m"
crontab -r
echo -e "\e[1;36m"Uninstall complete."\e[0m"
fi
# Update Inkycal
if [ "$option" = 1 ]; then
if [ -d "/home/$USER/Inkycal" ]; then
echo -e "Found Inkycal folder in /home/$USER. Renaming it to Inkycal-old"
mv Inkycal Inkycal-old
fi
fi
# Full uninstall - remove Inkycal folder
if [ "$option" = 3 ]; then
if [ -d "/home/$USER/Inkycal" ]; then
echo -e "Found Inkycal folder in /home/$USER. Deleting previous Inkycal-folder"
cd
rm -rf Inkycal
fi
fi
# Install update
if [ "$option" = 1 ] || [ "$option" = 2 ]; then
# Cloning Inky-Calendar repo
echo -e "\e[1;36m"Cloning Inkycal repo from Github"\e[0m"
cd /home/"$USER" && git clone https://github.com/aceisace/Inkycal
# Installing dependencies
echo -e "\e[1;36m"Installing Inkycal.."\e[0m"
cd Inkycal && pip3 install -e ./
# Install additional dependencies for yfinance module (ad-hoc fix)
sudo apt-get install libatlas-base-dev -y && pip3 install yfinance && pip3 install -U numpy
echo -e "\e[97mDo you want the software to start automatically at boot?"
echo -e "\e[97mPress [Y] for yes or [N] for no. The default option is yes"
echo -e "\e[97mConfirm your selection with [ENTER]"
read -r -p 'Waiting for input... ' autostart
if [ "$autostart" != Y ] && [ "$autostart" != y ] && [ "$autostart" != N ] && [ "$autostart" != n ]; then
echo -e "invalid input, aborting now" exit
fi
if [ -z "$autostart" ] || [ "$autostart" = Y ] || [ "$autostart" = y ]; then
# Installing crontab
echo -e "\e[1;36m"Creating inky_run.py file in home directory"\e[0m"
bash -c 'cat > /home/$USER/inky_run.py' << EOF
from inkycal import Inkycal # Import Inkycal
inky = Inkycal(render = True) # Initialise Inkycal
# If your settings.json file is not in /boot, use the full path: inky = Inkycal('path/to/settings.json', render=True)
inky.test() # test if Inkycal can be run correctly, running this will show a bit of info for each module
inky.run() # If there were no issues, you can run Inkycal nonstop
EOF
echo -e "\e[1;36m"Updating crontab"\e[0m"
(crontab -l ; echo "@reboot sleep 60 && python3 /home/$USER/inky_run.py &")| crontab -
fi
# Final words
echo -e "\e[1;36m"The install was successful. If autostart on boot was activated, inkycal will run on each boot."\e[0m"
fi