1 | #!/bin/bash |
2 |
|
3 | HELPTEXT="./install.sh <desktop|laptop|headless>" |
4 | case $1 in |
5 | h|help|\?|-h|-help|-\?|--h|--help|--\?) |
6 | echo -e $HELPTEXT |
7 | exit 0 |
8 | ;; |
9 | desktop) |
10 | UNIT=DESKTOP |
11 | ;; |
12 | laptop) |
13 | UNIT=LAPTOP |
14 | ;; |
15 | headless) |
16 | if [ $(whoami) != "root" ]; then |
17 | echo "Root privileges required for headless install." |
18 | exit 1 |
19 | fi |
20 | UNIT=HEADLESS |
21 | ;; |
22 | *) |
23 | echo -e $HELPTEXT |
24 | exit 0 |
25 | ;; |
26 | esac |
27 |
|
28 | category(){ |
29 | echo -e " \e[1;37m$1\e[0m" |
30 | } |
31 |
|
32 | item(){ |
33 | echo -e " \e[0m$1\e[0m" |
34 | } |
35 |
|
36 | echo -e " \e[1;33mInstall type \e[1;35m$UNIT\e[0m" |
37 |
|
38 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" |
39 |
|
40 | # Bash config |
41 | category "Bash config" |
42 | item "~/.bash_aliases" |
43 | install $SCRIPT_DIR/.bash_aliases $HOME/.bash_aliases |
44 | item "~/.bashrc" |
45 | install $SCRIPT_DIR/.bashrc $HOME/.bashrc |
46 | item "~/.profile" |
47 | install $SCRIPT_DIR/.profile $HOME/.profile |
48 |
|
49 | category "Common folders" |
50 | item "~/src/" |
51 | SRCFOLDER=$HOME/src |
52 | mkdir -p $SRCFOLDER |
53 | item "~/.local/bin/" |
54 | LOCALBIN=$HOME/.local/bin |
55 | mkdir -p $LOCALBIN |
56 | item "~/.local/share/" |
57 | mkdir -p $HOME/.local/share |
58 |
|
59 | # Local scripts |
60 | category "Local scripts" |
61 | if [ $UNIT == "DESKTOP" ] && [ $(whoami) != "root" ]; then |
62 | item "~/.local/bin/middle-mouse-scroll" |
63 | install $SCRIPT_DIR/middle-mouse-scroll $LOCALBIN/middle-mouse-scroll |
64 | fi |
65 |
|
66 | if ! command -v minesweeper &> /dev/null |
67 | then |
68 | if [ $(whoami) == "root" ]; then |
69 | item "/usr/local/bin/minesweeper" |
70 | else |
71 | item "~/.local/bin/minesweeper" |
72 | fi |
73 | git clone --depth=1 git://joshstock.in/ncurses-minesweeper.git $SRCFOLDER/ncurses-minesweeper |
74 | cd $SRCFOLDER/ncurses-minesweeper |
75 | make compile build |
76 | if [ $(whoami) == "root" ]; then |
77 | install bin/minesweeper /usr/local/bin/minesweeper |
78 | else |
79 | install bin/minesweeper $LOCALBIN/minesweeper |
80 | fi |
81 | rm -rf $SRCFOLDER/ncurses-minesweeper |
82 | cd $SCRIPT_DIR |
83 | fi |
84 |
|
85 | if [ $UNIT == "DESKTOP" ] || [ $UNIT == "LAPTOP" ]; then |
86 | # GTK config |
87 | category "GTK config" |
88 |
|
89 | GTKDIR=$HOME/.config/gtk-3.0 |
90 | item "~/.config/gtk-3.0/" |
91 | mkdir -p $GTKDIR |
92 |
|
93 | item "~/.config/gtk-3.0/gtk.css" |
94 | install $SCRIPT_DIR/gtk.css $GTKDIR/gtk.css |
95 |
|
96 | item "Terminal theme 'Oceanic Next'" |
97 | $SCRIPT_DIR/terminal_theme.sh $1 &>/dev/null |
98 |
|
99 | if [ $(whoami) == "root" ]; then |
100 | # Fonts |
101 | category "Fonts" |
102 | FONTDIR=/usr/share/fonts |
103 |
|
104 | item "Fira Sans pack" |
105 | if [ ! -f $FONTDIR/FiraSans-Regular.ttf ]; then |
106 | curl -fLso /tmp/Fira.zip https://fonts.google.com/download?family=Fira%20Sans |
107 | unzip -q /tmp/Fira.zip -d $FONTDIR |
108 | fi |
109 |
|
110 | item "Fira Mono (Nerd Fonts) pack" |
111 | if [ ! -f $FONTDIR/FiraMono-Regular.otf ]; then |
112 | curl -fLso $FONTDIR/FiraMono-Regular.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Regular/complete/Fura%20Mono%20Regular%20Nerd%20Font%20Complete%20Mono.otf |
113 | fi |
114 | if [ ! -f $FONTDIR/FiraMono-Medium.otf ]; then |
115 | curl -fLso $FONTDIR/FiraMono-Medium.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Medium/complete/Fura%20Mono%20Medium%20Nerd%20Font%20Complete%20Mono.otf |
116 | fi |
117 | if [ ! -f $FONTDIR/FiraMono-Bold.otf ]; then |
118 | curl -fLso $FONTDIR/FiraMono-Bold.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Bold/complete/Fura%20Mono%20Bold%20Nerd%20Font%20Complete%20Mono.otf |
119 | fi |
120 |
|
121 | item "Refreshing font cache" |
122 | fc-cache |
123 | fi |
124 | fi |
125 |
|
126 | # Global git config |
127 | category "Global git config" |
128 |
|
129 | if [ $(whoami) == "root" ]; then |
130 | item "/etc/gitconfig" |
131 | install $SCRIPT_DIR/.gitconfig /etc/gitconfig |
132 | else |
133 | item "~/.gitconfig" |
134 | install $SCRIPT_DIR/.gitconfig $HOME/.gitconfig |
135 | fi |
136 |
|
137 | # Vim |
138 | category "Vim config" |
139 |
|
140 | if [ $UNIT == "HEADLESS" ]; then |
141 | item "/usr/share/vim/" |
142 | VIMDIR=/usr/share/vim |
143 | mkdir -p $VIMDIR |
144 | item "/usr/share/vim/vimrc" |
145 | grep -v "RMHEADLESS" vimrc > $SCRIPT_DIR/.vimrc_headless |
146 | install $SCRIPT_DIR/.vimrc_headless $VIMDIR/vimrc |
147 | item "/usr/share/vim/autoload/plug.vim" |
148 | curl -fLso $VIMDIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
149 | else |
150 | item "~/.vim/" |
151 | VIMDIR=$HOME/.vim |
152 | mkdir -p $VIMDIR |
153 | item "~/.vim/vimrc" |
154 | install $SCRIPT_DIR/vimrc $VIMDIR/vimrc |
155 | item "~/.vim/autoload/plug.vim" |
156 | curl -fLso $VIMDIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
157 | fi |
158 |
|
159 | # Done |
160 | echo -e " \e[1;33mDONE\e[0m" |
161 |
|