-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostinstall-script.sh
More file actions
251 lines (194 loc) · 7.09 KB
/
postinstall-script.sh
File metadata and controls
251 lines (194 loc) · 7.09 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/bin/bash
# Settings
UBUNTU_VERSION=$(lsb_release -r | cut -f 2)
NODE_VERSION=24
PHP_VERSION=8.4
GO_VERSION=1.26.2
# Flags
WITHOUT_SERVICES=("mysql" "nginx" "dbeaver" "ghostty" "code" "nodejs" "php" "go" "fluent-icons" "spinup")
declare -A WITHOUT_FLAGS
for service in "${WITHOUT_SERVICES[@]}"; do
WITHOUT_FLAGS["$service"]=false
done
# Functions
parse_without_args() {
while [[ $# -gt 0 ]]; do
case $1 in
--without)
shift
while [[ $# -gt 0 && $1 != --* ]]; do
if [[ " ${WITHOUT_SERVICES[@]} " =~ " $1 " ]]; then
WITHOUT_FLAGS["$1"]=true
else
echo "Unknown argument for --without: $1"
fi
shift
done
;;
*)
echo "Unknown argument: $1"
break
;;
esac
done
}
install_composer() {
local expected_checksum="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-installer.php');"
local actual_checksum="$(php -r "echo hash_file('sha384', 'composer-installer.php');")"
if [ "$expected_checksum" != "$actual_checksum" ]; then
>&2 echo 'ERROR: Invalid composer installer checksum'
rm composer-installer.php
return
fi
php composer-installer.php --quiet
mv composer.phar /usr/local/bin/composer
rm composer-installer.php
return
}
download_latest_github_release() {
local url=$(
curl -s https://api.github.com/repos/$1/$2/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
)
# Grab the latest release for the current Ubuntu version
# Check for that version first, as it is the most specific
# Then check for ubuntu, as it is the most general
if [[ "$url" == *"$UBUNTU_VERSION"* ]]; then
url=$(echo "$url" | grep "$UBUNTU_VERSION")
elif [[ "$url" == *"ubuntu"* ]]; then
url=$(echo "$url" | grep "ubuntu")
fi
wget -qi - $url
local filename=$(echo $url | rev | cut -d / -f 1 | rev)
return $filename
}
if [[ $EUID -ne 0 ]]; then
echo "This script must be run using sudo"
exit 1
else
parse_without_args $@
########################
### General software ###
########################
echo "Updating and upgrading using apt..."
apt update && apt upgrade -y
echo "Installing general software..."
apt install -y git curl wget gpg tmux htop build-essential apt-transport-https software-properties-common
###########################
### Additional Software ###
###########################
if [ "$WITHOUT_FLAGS[mysql]" = false ]; then
echo "Installing MySQL..."
apt install -y mysql-server
fi
if [ "$WITHOUT_FLAGS[nginx]" = false ]; then
echo "Installing nginx..."
apt install -y nginx
fi
if [ "$WITHOUT_FLAGS[dbeaver]" = false ]; then
echo "Installing dbeaver..."
snap install dbeaver-ce
fi
###############
### Node js ###
###############
if [ "$WITHOUT_FLAGS[nodejs]" = false ]; then
echo "Installing nodejs..."
curl -fsSL https://deb.nodesource.com/setup_$NODE_VERSION.x | sudo -E bash -
apt install -y nodejs
# Install npm-check-updates and pnpm as global nodejs packages
npm install -g npm-check-updates pnpm
fi
###########
### PHP ###
###########
if [ "$WITHOUT_FLAGS[php]" = false ]; then
echo "Installing PHP $PHP_VERSION..."
apt install -y php$PHP_VERSION php$PHP_VERSION-mbstring php$PHP_VERSION-xml php$PHP_VERSION-zip php$PHP_VERSION-curl php$PHP_VERSION-gd php$PHP_VERSION-mysql php$PHP_VERSION-intl php$PHP_VERSION-bcmath php$PHP_VERSION-sqlite3 php$PHP_VERSION-pgsql
# Disable apache2
update-rc.d apache2 disable
service apache2 stop
echo "Installing composer..."
install_composer
fi
##########
### Go ###
##########
if [ "$WITHOUT_FLAGS[go]" = false ]; then
wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz
tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz
rm -f go$GO_VERSION.linux-amd64.tar.gz
go install github.com/mailhog/MailHog@latest
fi
##############
### Spinup ###
##############
if [ "$WITHOUT_FLAGS[spinup]" = false ]; then
echo "Installing spinup..."
spinup_installer=$(download_latest_github_release "iskandervdh" "spinup")
dpkg -i $spinup_installer
rm -f $spinup_installer
fi
###############
### Ghostty ###
###############
if [ "$WITHOUT_FLAGS[ghostty]" = false ]; then
echo "Installing ghostty..."
ghostty_installer=$(download_latest_github_release "mkasberg" "ghostty-ubuntu")
dpkg -i $ghostty_installer
rm -f $ghostty_installer
# Set ghostty as default terminal
update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/ghostty 1
update-alternatives --set x-terminal-emulator /usr/bin/ghostty
fi
############
### Code ###
############
if [ "$WITHOUT_FLAGS[code]" = false ]; then
echo "Installing Code..."
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg
apt update
apt install -y code
fi
####################
### Fluent icons ###
####################
if [ "$WITHOUT_FLAGS[fluent-icons]" = false ]; then
git clone https://github.com/vinceliuice/Fluent-icon-theme.git
cd Fluent-icon-theme
./install.sh yellow
cd ..
rm -rf Fluent-icon-theme
fi
#####################
### General Setup ###
#####################
### TODO
# # Generate SSH keys
# echo "Generating SSH keys"
# ssh-keygen -o -t ed25519
# Disable screen blank
gsettings set org.gnome.desktop.session idle-delay 0
#################
### ZSH + OMZ ###
#################
apt install -y fonts-powerline
apt install -y zsh
chsh -s $(which zsh)
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended
rm ~/.zshrc.pre-oh-my-zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
#################
### .Dotfiles ###
#################
git clone git@github.com:iskandervdh/.dotfiles.git
cd .dotfiles
./install.sh
fi