-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgodot.sh
116 lines (94 loc) · 3.6 KB
/
godot.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
#!/bin/bash
# If you want to help add something to this, here are my current thoughts
# Add some of the following
# Make godot command to open godot from terminal
# - add options to pick version of godot + source
# Make install for source
# - add right click option on desktop icon "view source" link to folder in terminal
# uninstall process
# add downloader to get from github repos "release" / if website down ( for download ticker?.. )
# make options to install popular plugins with godot like
# - godot_voxel map generator tool https://github.com/Zylann/godot_voxel
# - Vpainter https://www.youtube.com/watch?v=vVxemrkB3Mg and or Material maker for godot
linebreak="echo "
# Install Godat game engine
echo "◦ Install Godot Game Engine"
# get system data for auto install
operatingSystem=$(uname -m)
# get logged in username for link purposes
userName=$(who | cut --delimiter " " --fields 1)
# programExec=''
scrapeLink="https://godotengine.org/download/linux"
# game engine zip link
linkRegex1='downloads\.tuxfamily.*(64|32)'
excludeSearch1='mono'
temp="tempfiles"
mkdir "${temp}"
# save HTML data to temp file for link scraping
htmlToScrape="./${temp}/scraper.html"
# download html page with curl and save to tempfile for parsing
curl -s $scrapeLink > $htmlToScrape
# using -E for regex complexity
# Get godot engine links from html file
grep -i -E $linkRegex1 $htmlToScrape |
grep -i -o '".*"' | # displays only text within "" due to -o option with grep
grep -v $excludeSearch1 | # exclude from search by flipping the results
sed 's/"//g' > ./${temp}/godotlinks.txt # removes quotes from link
# downloading files
(cd ./${temp};
# download the logo svg file into ./tempfiles
curl -LOs https://godotengine.org/themes/godotengine/assets/press/icon_color_outline.svg
if [[ $operatingSystem =~ .*64 ]]; then
# download 64 bit zip file
echo " ‣ 💾 Downloading 64bit Godot game engine"
$linebreak
grep -i -E '.*64' godotlinks.txt | xargs curl -LO
$linebreak
elif [[ $operatingSystem != ".*64" ]]; then
# download 32 bit zip file
echo " ‣ 💾 Downloading 32bit Godot game engine"
$linebreak
grep -i -E '.*32' godotlinks.txt | xargs curl -LO
$linebreak
fi
# unzip the downloaded godot file
zipValidator=$(find -iname "*.zip" | sed 's/^[.]//g') # [.] needs removed for test -f check to work
if ! test -f "$zipValidator"; then
zipFile=$(echo $zipValidator | sed 's/^[/]//g') # remove starting / for unzip process
unzip -qqo $zipFile
fi
)
installDirectory="Godot"
# create install folder
(cd /home/${userName}/;
mkdir ${installDirectory}
)
# get unzipped filename from zip file
unzippedFilename=$(find tempfiles/ -iname "*.zip" |
sed 's/tempfiles//g' |
sed 's/[/]//' |
sed 's/.zip//')
# move godot game engine and svg file into the /home/${username}/${installDirectory}folder
mv ./${temp}/$unzippedFilename /home/${userName}/${installDirectory}
mv ./${temp}/icon_color_outline.svg /home/${userName}/${installDirectory}/logo.svg
# create desktop icon
# printf gives us /n newlines which are needed for the .desktop file
echo " ‣ Creating desktop shortcut"
printf "#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Terminal=false
StartupNotify=false
Icon=/home/${userName}/${installDirectory}/logo.svg
Exec=/home/${userName}/${installDirectory}/${unzippedFilename}
Categories=Game Development
Name[en_US]=Godot
Name=Godot" | cat > ~/Desktop/Godot.desktop
# set as executable just incase linux system compatability
# chmod +x /home/${userName}/Desktop/Godot.desktop
echo " • Desktop shortcut created "
rm -rf ./${temp}
# UNINSTALL PROCESS
# remove folder to clean up
# remove folder ${installDirectory}
# ~/.local/share/godot