-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_Linux_x86_64.sh
230 lines (217 loc) · 7.7 KB
/
install_Linux_x86_64.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
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
#!/usr/bin/env bash
# shellcheck disable=SC2034
# Use this script for any Intel/AMD-based specific installations
source ./bin/utils.sh
packages="$1"
fonts="$2"
config="$3"
xcode="$4"
gui="$5"
yes="$6"
debug="$7"
serveronly="$8"
INSTALLDIR=${TMPDIR:-/tmp}/dotfiles-installer
mkdir -p "$INSTALLDIR"
DOWNLOADS=${HOME}/Downloads
mkdir -p "$DOWNLOADS"
initial_wd=$PWD
installTarball () {
tarball=$1
basepath=$2
tarpath=$3
url=$4
if [ -d "$basepath/$tarpath" ]
then
[[ $debug -eq 1 ]] && g_success "$tarball is already installed"
else
if [[ $yes -eq 1 ]]
then
install=y
else
if [[ $gui -eq 0 ]]
then
read -rp "Do you want to install ${C_FORE_BLUE}$tarpath${C_RESET}? [y/${C_BOLD}n${C_RESET}]: " install
else
zenity --question --text="Do you want to install ${tarpath}?" \
--window-icon=./installer.svg --width=300 --height=100 && install=y
fi
fi
if [[ $install == "y" ]]
then
cd "$INSTALLDIR" && {
wget -q "$url" -O "$tarball"
if sudo tar -x -f "$tarball" -z -C "$basepath" --owner=root --group=root
then
sudo chown -R root:root "$basepath/$tarpath"
g_success "Installed tarball: $tarball"
else
g_error "Unable to install tarball: $tarball"
fi
}
fi
fi
}
installTarballs () {
g_bold "Installing Tarballs"
installTarball "free42linux.tar.gz" "/opt" "Free42Linux" "https://thomasokken.com/free42/download/Free42Linux.tgz"
}
hasFlatpak () {
flatpak info "$1" &> /dev/null
return $?
}
# TODO write function for update script to update all flatpaks when run (flatpak update)
installFlatpaks () {
g_bold "Installing Flatpaks"
declare -a flatpaks=(
"com.getpostman.Postman"
"com.github.alexkdeveloper.desktop-files-creator"
"com.github.artemanufrij.regextester"
"com.github.fabiocolacio.marker"
"com.github.gijsgoudzwaard.image-optimizer"
"com.github.junrrein.PDFSlicer"
"com.github.muriloventuroso.pdftricks"
"com.github.tchx84.Flatseal"
"com.jetbrains.IntelliJ-IDEA-Community"
"com.jetbrains.PyCharm-Community"
"com.poweriso.PowerISO"
"com.syntevo.SmartGit"
"com.syntevo.SmartSynchronize"
"com.yacreader.YACReader"
"fr.handbrake.ghb"
"fr.rubet.rpn"
"io.dbeaver.DBeaverCommunity"
"io.github.arunsivaramanneo.GPUViewer"
"io.github.seadve.Breathing"
"io.github.trytonvanmeer.DungeonJournal"
"org.gustavoperedo.FontDownloader"
"re.sonny.OhMySVG"
)
# declare -a optionalFlatpaks=(
# "com.google.AndroidStudio"
# "us.zoom.Zoom"
# )
type flatpak &> /dev/null && {
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
local toInstall=()
for pkg in "${flatpaks[@]}"
do
if hasFlatpak "$pkg"
then
[[ $debug -eq 1 ]] && g_success "$pkg (flatpak) is already installed"
install=n
elif [[ $yes -eq 1 ]]
then
install=y
else
if [[ $gui -eq 0 ]]
then
read -rp "Do you want to install flatpak ${C_FORE_BLUE}$pkg${C_RESET}? [y/${C_BOLD}n${C_RESET}]: " install
else
zenity --question --text="Do you want to install flatpak ${pkg}?" \
--window-icon=./installer.svg --width=300 --height=100 && install=y
fi
fi
if [[ $install == "y" ]]
then
toInstall+=( "${pkg}" )
fi
done
if [[ ${#toInstall[@]} -gt 0 ]]
then
for pkg in "${toInstall[@]}"
do
hasFlatpak "$pkg" || {
g_info "Installing flatpak $pkg"
flatpak install -y flathub "$pkg"
hasFlatpak "$pkg"
reportResult "$pkg flatpack successfully installed" "$pkg flatpak not installed"
}
done
fi
}
}
getLatestGithubResource () {
repo=$1
search=$2
githubDownload=$(wget -q -nv -O- https://api.github.com/repos/"${repo}"/releases/latest 2>/dev/null | jq -r ".assets[] | select(.name | test(\"${search}\")) | .browser_download_url")
}
installAppImages () {
g_bold "Installing AppImages"
declare -a urls=(
"https://developers.yubico.com/yubikey-manager-qt/Releases/yubikey-manager-qt-latest-linux.AppImage"
)
getLatestGithubResource "dail8859/NotepadNext" "x86_64.AppImage"
urls+=("$githubDownload")
local toInstall=()
for url in "${urls[@]}"
do
filename=$(python3 "$initial_wd/get_url_file.py" "$url")
if [ -x "${HOME}/bin/${filename}" ]
then
[[ $debug -eq 1 ]] && g_success "$filename is already installed"
install=n
elif [[ $yes -eq 1 ]]
then
install=y
else
if [[ $gui -eq 0 ]]
then
read -rp "Do you want to install AppImage ${C_FORE_BLUE}$filename${C_RESET}? [y/${C_BOLD}n${C_RESET}]: " install
else
zenity --question --text="Do you want to install AppImage ${filename}?" \
--window-icon=./installer.svg --width=300 --height=100 && install=y
fi
fi
if [[ $install == "y" ]]
then
toInstall+=( "${url}" )
fi
done
if [[ ${#toInstall[@]} -gt 0 ]]
then
for url in "${toInstall[@]}"
do
filename=$(python3 "$initial_wd/get_url_file.py" "$url")
cd "$INSTALLDIR" && {
wget -q "$url" -O "$filename"
cp "$filename" "${HOME}/bin"
chmod +x "${HOME}/bin/${filename}"
# TODO extract .desktop and icon files from AppImage to add to system menu
# - extract AppImage: "${HOME}/bin/${filename}" --appimage-extract
# - cd squashfs-root (created in extraction)
# - get .desktop file name
# - pull icon file name from .desktop file
# - check icon file in folder for extension
# - if extension = svg
# - resolution="scalable"
# - else
# - resolution=$(identify "$iconfile.*" | cut -f3 -d' ' | head -n 1)
# - cp icon file to ${HOME}/.local/share/icons/hicolor/${resolution}/apps/
# - replace Exec= line in .desktop file with "Exec=${HOME}/bin/${filename}" (expanded variables)
# - copy .desktop file to ${HOME}/.local/share/applications
# - cd ..
# - rm -rf squashfs-root
}
done
fi
}
downloadManualInstallers () {
g_bold "Downloading Manual Installers"
url=$(python3 "$initial_wd/get_html_href.py" https://www.anaconda.com/products/distribution | grep "Linux-x86_64\.sh" | head -n 1)
filename=$(python3 "$initial_wd/get_url_file.py" "$url")
if [ -e "${DOWNLOADS}/${filename}" ]
then
[[ $debug -eq 1 ]] && g_success "$filename has already been downloaded"
else
[[ $debug -eq 1 ]] && g_info "Downloading $url"
wget -q --progress=dot:giga --show-progress "$url" -O "${DOWNLOADS}/${filename}"
reportResult "Installer $filename has been downloaded to $HOME/Downloads" "Unable to download $filename"
fi
}
if [[ $packages -eq 1 ]]
then
installTarballs
installFlatpaks
installAppImages
downloadManualInstallers
fi