-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautoinstall
executable file
·142 lines (128 loc) · 3.48 KB
/
autoinstall
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
#!/usr/bin/env bash
# Set variables
# Source directory
repodir="$( dirname -- "$0"; )"
# Colors
RED='\033[1;31m'
NC='\033[0m'
GRN='\033[0;32m'
YLW='\033[0;33m'
PRP='\033[1;35m'
# Functions
conprompt () # Confirmation prompt
{
if [[ $int = 1 ]] # At this point, $int variable used for separating behaviour for interactive and non-interactive setups, keep in mind that this is not the only way i'm doing such separation, because i'm a dumbo.
then
echo -e "${YLW}There are still some software missing\nI recommend installing ${RED}missing parts${YLW}\nBut you can continue anyway${NC}"
echo -e ${PRP}
read -p "Continue anyway? (y/n) " yn
echo -e ${NC}
case $yn in
[yY] )
true ;;
* )
echo -e "${RED}Exiting${NC}"
exit;;
esac
fi
}
has() #checks if dependency is installed
{
type -p "$1" >/dev/null && dependency=$1;
}
# Balls parts
ball.pt0 () # Not made for non-interactive setup, that's why it won't be included in balls_rollout
{
echo -e "${YLW}Looking for desired dependencies...${NC}"
for i in {zsh,tmux,micro,gnome-terminal,neofetch}
do
if has "$i"
then
have="$have $i"
else
missing="$missing $i"
fi
done
if [[ $missing < "?" ]]
then
true
echo -e "${GRN}Looks like you have everything needed${NC}"
else
false
echo -e "${RED}Missing parts:${NC}$missing"
conprompt
fi
}
ball.pt1 ()
{
echo -e "${YLW}Putting balls in your jaws..."
cp -r $repodir/{Documents,.config,.local,.zshrc} $HOME
}
ball.pt2 ()
{
echo -e "${YLW}Updating fonts..."
fc-cache -f
}
ball.pt3 ()
{
echo -e "${YLW}Applying gnome-terminal settings..."
dconf load /org/gnome/terminal/legacy/ < $repodir/gnome-terminal.dconf
cp /usr/share/applications/*gnome*?erminal*.desktop $HOME/.local/share/applications/
sed -i 's/Actions=new-window;preferences/Actions=new-window;new-session;preferences/' $HOME/.local/share/applications/*gnome*?erminal*.desktop
printf "\n[Desktop Action new-session]\nName=New Session\nExec=gnome-terminal -- tmux new\n" >> $HOME/.local/share/applications/*gnome*?erminal*.desktop
}
# Actual installation process
balls_rollout ()
{
for i in {1..3}
do
ball.pt$i
done
echo -e "${GRN}Everything done, enjoy 🥒"
}
# Message to make everything clear for user
warn ()
{
echo -e "${RED}Be aware${NC}\nRunning this script will cause irreversible changes\nIt will replace your existing configuration files\nIt's not made for everyone\nIt's made to recreate my setup as simply as possible."
}
# Message for help option
help()
{
echo -e "Without options this script will run interactively\nOptions:\n${GRN}-a${NC}\tFully-automatic non-interactive setup (without warning and asking prompt)\n${GRN}-c${NC}\tWill check for desired software\n${GRN}-h${NC}\tWill show you this text"
}
# Interactive side
interactive-balls ()
{
int=1
warn
echo -e ${PRP}
read -p "Can i put my balls in your jaws? (y/n) " yn
echo -e ${NC}
case $yn in
[yY] )
ball.pt0
balls_rollout;;
* )
echo -e "${RED}Sadje :<${NC}";;
esac
}
# Running part of the script
# Act depending on option
while getopts ":ahc" option; do
case $option in
a) # Non-interactive setup
balls_rollout
exit;;
h)
help
exit;;
c) # For dependency-checking
ball.pt0
exit;;
\?)
echo -e "${RED}Invalid option${NC}\ntry ${GRN}autoinstall -h${NC} to get list of options"
exit;;
esac
done
# This part will run when no options set
interactive-balls