-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmasterscript
More file actions
executable file
·185 lines (158 loc) · 5.12 KB
/
masterscript
File metadata and controls
executable file
·185 lines (158 loc) · 5.12 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
# ----------------------------------
# Define variables
# ----------------------------------
# Colors name
COLOR_BLACK="\033[0;30m"
COLOR_RED="\033[0;31m"
COLOR_YELLOW="\033[0;33m"
COLOR_GREEN="\033[0;32m"
COLOR_RESET="\033[0m"
# ----------------------------------
# Function
# ----------------------------------
pause(){
read -p "Press [Enter] key to continue..." fackEnterKey
}
upgradeAndClean(){
echo "Updating apt packages"
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoclean
sudo apt-get autoremove
echo -e "\nUpdating snap packages"
sudo snap refresh
# Test if a reboot is needed
if [ -f /var/run/reboot-required ]; then
echo -e $COLOR_RED'Reboot required!'$COLOR_RESET
fi
pause
}
REPOSITORIES_LIST=(
".dotfiles"
".scripts"
#".vim"
"Templates"
".fzf"
"nvim"
".config/nvim"
"grive2"
)
updateRepositories(){
# TODO: test if 'git pull' fails
for i in "${REPOSITORIES_LIST[@]}"; do
echo "Checking $i"
cd ~/$i/ && git fetch
# updating neovim specific code
if [[ "$i" == "nvim" ]]; then
tag="stable"
current_hash=$(git rev-parse HEAD)
remote_hash=$(git ls-remote --tags --refs -q | grep $tag | cut -f1)
if [[ "$current_hash" != "$remote_hash" ]]; then
echo "Neovim remote has updated"
git fetch origin --tags --force
git tag -d $tag
git fetch origin tag $tag
git checkout $tag
# update code
make distclean
make CMAKE_BUILD_TYPE=RelWithDebInfo
# Create deb package to make it easier to uninstall
cd ~/nvim/build && cpack -G DEB && sudo dpkg -i nvim-linux-x86_64.deb
fi
# update non neovim code
else
if [[ $(git status | grep -o 'Your branch is up to date') != 'Your branch is up to date' ]]; then
echo "Updating $i"
echo ""
git pull
# Update fzf
if [[ "$i" == *".fzf" ]]; then
~/.fzf/install
fi
## Update and compile vim
#if [[ "$i" == "vim" ]]; then
# sudo make uninstall
# make distclean
# ./configure --prefix=/usr/local --disable-darwin --enable-luainterp=yes --with-lua-prefix=/usr/include/lua5.1 --enable-perlinterp=yes --enable-python3interp=yes --enable-python3interp=yes --enable-tclinterp=yes -enable-rubyinterp=yes --enable-cscope --enable-terminal --enable-multibyte --enable-xim --enable-fontset --enable-gui=gtk3 --with-features=huge --with-x
# #./configure --prefix=/usr/local --disable-darwin --enable-luainterp=yes --with-lua-prefix=/usr/include/lua5.1 --enable-perlinterp=yes --enable-python3interp=yes --enable-pythoninterp=yes --enable-tclinterp=yes -enable-rubyinterp=yes --enable-cscope --enable-terminal --enable-multibyte --enable-xim --enable-fontset --enable-gui=auto --with-features=huge --with-x
# sudo make VIMRUNTIMEDIR=/usr/local/share/vim/vim82
# sudo make install
## sudo make uninstall
## make distclean
## ./configure --with-features=huge --enable-multibyte --enable-rubyinterp=yes --enable-python3interp=yes --with-python3-config-dir=$(python3-config --configdir) --with-python-command=/usr/bin/python3 --enable-perlinterp=yes --enable-luainterp=yes --enable-gui=auto --enable-cscope --prefix=/usr/local
## make VIMRUNTIMEDIR=/usr/local/share/vim/vim82
## sudo make install
#fi
## Update and compile neovim
#if [[ "$i" == "nvim" ]]; then
# make distclean
# make CMAKE_BUILD_TYPE=RelWithDebInfo
# # Create deb package to make it easier to uninstall
# cd ~/nvim/build && cpack -G DEB && sudo dpkg -i nvim-linux64.deb
#fi
# Update grive
# https://yourcmc.ru/wiki/Grive2#Installation
if [[ "$i" == "grive2" ]]; then
read -p "Do you want to proceed compiling grive2? (y/n) " yn
case $yn in
[yY] ) echo ok, we will proceed;
cd ~/grive2/build;
cmake ..;
make -j4;
sudo make install;
break;;
*) echo "aborting";
break;;
esac
fi
fi
fi
done
pause
}
# Menu headlines
SYSTEM_MAINTENANCE="${COLOR_GREEN}SYSTEM MAINTENANCE${COLOR_RESET}"
BUNDLES="${COLOR_GREEN}BUNDLES${COLOR_RESET}"
PLACEHOLDER="${COLOR_GREEN}SOMETHING ELSE${COLOR_RESET}"
show_menu(){
clear
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " MASTERSCRIPT "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${SYSTEM_MAINTENANCE}"
echo "1. Clean And Upgrade System"
echo "2. Update My Repositories"
echo "3. Sync google drive"
echo ""
echo -e "${BUNDLES}"
echo "4. (1 and 2)"
echo " - Clean And Upgrade System"
echo " - Update My Repositories "
echo ""
echo -e "${PLACEHOLDER}"
echo "5. Help"
echo "6. Exit"
echo ""
}
read_options(){
local choice
read -p "Enter choice: " choice
case $choice in
1) upgradeAndClean ;;
2) updateRepositories;;
3) (cd ~/google-drive/ && grive && pause);;
4) upgradeAndClean && updateRepositories;;
5) echo -e "${COLOR_YELLOW}Help not written yet${COLOR_RESET}" && sleep 2;;
6) exit 0;;
*) echo -e "${COLOR_RED}Error:${COLOR_RESET} invalid input" && sleep 2
esac
}
# -----------------------------------
# Main logic - infinite loop
# ------------------------------------
while true
do
show_menu
read_options
done