-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·78 lines (63 loc) · 2.24 KB
/
install.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
#!/bin/bash
apt-get update
apt-get install -y sudo jq curl git tar xz-utils libarchive-tools \
openjdk-17-jdk
curl -s https://install.zerotier.com | bash
useradd -m -s /bin/bash -G sudo vscode
echo "vscode ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vscode
function download_flutter {
if [[ -f '/tmp/flutter.tar.xz' ]]; then
echo 'Flutter is already downloaded.'
return
fi
infra_channel='stable'
infra='https://storage.googleapis.com/flutter_infra_release/releases'
infra_json="$(curl -s "${infra}/releases_linux.json")"
infra_hash="$(echo ${infra_json} | \
jq -r ".current_release.${infra_channel}")"
infra_release="$(echo ${infra_json} | \
jq -r ".releases[] | select(.hash == \"${infra_hash}\")")"
flutter_version="$(echo ${infra_release} | jq -r '.version')"
dart_version="$(echo ${infra_release} | jq -r '.dart_sdk_version')"
flutter_archive="${infra}/$(echo ${infra_release} | jq -r '.archive')"
echo 'Downloading Flutter...'
echo "Flutter Channel : ${infra_channel}"
echo "Flutter Version : ${flutter_version}"
echo "Dart Version : ${dart_version}"
curl "${flutter_archive}" -o '/tmp/flutter.tar.xz'
}
function extract_flutter {
echo 'Extracting Flutter...'
mkdir -p '/opt'
tar -xf '/tmp/flutter.tar.xz' -C '/opt'
echo 'Change ownership of Flutter folder...'
chown -R 'vscode:vscode' '/opt/flutter'
}
function download_android_cmd {
if [[ -f '/tmp/cmdline.zip' ]]; then
echo 'Android Command Line Tools is already downloaded.'
return
fi
cmdline_archive="$(curl -s 'https://developer.android.com/studio' | \
grep 'https' | grep 'commandlinetools-linux' | \
sed -E 's/^\s+href=\"(.+)\"\s*$/\1/')"
echo 'Downloading Android Command Line Tools...'
curl "${cmdline_archive}" -o '/tmp/cmdline.zip'
}
function extract_android_cmd {
echo 'Extracting Android Command Line Tools...'
mkdir -p '/opt/android/sdk/cmdline-tools/latest'
bsdtar -xf '/tmp/cmdline.zip' -s '|[^/]*/||' \
-C '/opt/android/sdk/cmdline-tools/latest'
echo 'Change ownership of Android SDK folder...'
chown -R 'vscode:vscode' '/opt/android'
}
function clear_temp {
rm '/tmp/flutter.tar.xz'
rm '/tmp/cmdline.zip'
}
download_flutter
extract_flutter
download_android_cmd
extract_android_cmd
clear_temp