-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathupdate.sh
58 lines (48 loc) · 1.44 KB
/
update.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
#!/usr/bin/bash
# Description: Update LED-Stock-Ticker (github.com/feram18/led-stock-ticker)
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
function clean() {
rm -f "*.log*"
sudo rm -rf "*/__pycache__"
sudo rm -rf "__pycache__"
}
function updateRepository() {
printf "Updating repository...\n"
git reset --hard
git pull origin master
git fetch --tags -f
tag="$(git describe --tags --abbrev=0)"
git checkout tags/"$tag"
}
function installDependencies(){
printf "\nInstalling dependencies...\n"
sudo pip3 install -r requirements.txt
}
function createConfigFile() {
echo "$(tput setaf 7)Creating new config.json file..."
cp config.json.example config.json
chown "$USER": config.json
echo "Set your preferences using the command $(tput setaf 3)./config.py$(tput setaf 7)"
}
# Checks if configuration file exists/requires update
function checkConfigFile() {
cd "${ROOT_DIR}/matrix/" || exit
if [[ ! -e config.json ]]; then
createConfigFile
elif [[ -e config.json && config.json.example -nt config.json ]];then
echo -e "\n$(tput setaf 1)Your config file is out of date"
mv config.json old-config.json
createConfigFile
fi
cd "${ROOT_DIR}" || exit
}
function main() {
clean
updateRepository
installDependencies
checkConfigFile
# Allow scripts to be easily executed next time
chmod +x install.sh update.sh config.py
echo "$(tput setaf 2)Update completed$(tput setaf 7)"
}
main