This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-sanbox.sh
executable file
·107 lines (92 loc) · 3.09 KB
/
setup-sanbox.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
# setup variables
avrgcc_compressed='avr-gcc.tar.gz'
jdk_compressed='jdk.tar.gz'
# setup functions to download and extract toolchains/compilers
##
# Prompt the download of the toolchains.
##
function confirmDownload() {
printf "%s" "Additional data apply charges may be applied, if you want to proceed type [y] or [Y], and [n] or [N] to terminate ? "
read command < /dev/stdin
if [[ "$command" = "n" || "$command" = "N" ]]; then
exit 640
# ignore other ASCIIs other than 'n' and "N"
elif [[ "$command" != "y" && "$command" != "Y" ]]; then
echo -e 'Command not found'
# Recall the prompt
confirmDownload
fi
}
##
# Sets up avr-dude from the apt package manager.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function setupAvrDude() {
sudo apt-get install avrdude
return $?
}
##
# Sets up the client url utility.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function setupCURL() {
sudo apt-get install curl
return $?
}
##
# Downloads the avr gcc toolchains from Microchip domains.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function downloadAvrToolChain() {
curl https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/avr8-gnu-toolchain-3.7.0.1796-linux.any.x86_64.tar.gz --output $avrgcc_compressed
return $?
}
##
# Downloads jdk-19 from oracle domains.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function downloadJdk() {
curl https://download.oracle.com/java/19/archive/jdk-19_linux-x64_bin.tar.gz --output $jdk_compressed
return $?
}
##
# Provokes R/W/E permissions to the specified files in the given folder.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function provokeReadWriteExecutePermissions() {
local directory=$1
# rwx = read-write-execute for the owner, -R for recursive search
chmod +rwx -R $directory
return $?
}
##
# Extracts a compressed `.tar.gz` file to this directory.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function extractCompressedFile() {
local compressedFile=$1
tar --overwrite -xf $compressedFile
return $?
}
##
# Deletes the avr gcc archive if exists.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function deleteAvrToolchainsArchive() {
if [[ ! -e "$avrgcc_compressed" ]]; then
return 1
fi
rm $avrgcc_compressed
return $?
}
##
# Deletes the jdk archive if exists.
# @return [0] for success, [positive-number] for failure indicating errno, [1] for operation not permitted [EPERM].
##
function deleteJdkArchive() {
if [[ ! -e "$jdk_compressed" ]]; then
return 1
fi
rm $jdk_compressed
return $?
}