-
Notifications
You must be signed in to change notification settings - Fork 63
/
ubuntu_ionic_installer.sh
122 lines (93 loc) · 3.79 KB
/
ubuntu_ionic_installer.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
#!/bin/bash
# Ubuntu Developer Script For Ionic Framework
# Created by Nic Raboy
# http://www.nraboy.com
#
#
# Downloads and configures the following:
#
# Java JDK
# Apache Ant
# Android
# NPM
# Apache Cordova
# Ionic Framework
# Gradle
HOME_PATH=$(cd ~/ && pwd)
INSTALL_PATH=/opt
ANDROID_SDK_PATH=/opt/android-sdk
NODE_PATH=/opt/node
GRADLE_PATH=/opt/gradle
# x86_64 or i686
LINUX_ARCH="$(lscpu | grep 'Architecture' | awk -F\: '{ print $2 }' | tr -d ' ')"
# Latest Android Linux SDK for x64 and x86 as of 12-19-2015
ANDROID_SDK_X64="http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz"
ANDROID_SDK_X86="http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz"
# Latest NodeJS for x64 and x86 as of 12-19-2015
NODE_X64="https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz"
NODE_X86="https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x86.tar.xz"
# Latest Gradle as of 10-19-2018
GRADLE_ALL="https://services.gradle.org/distributions/gradle-4.10.2-all.zip"
if [ "$LINUX_ARCH" == "x86_64" ]; then
# Add i386 architecture
dpkg --add-architecture i386
fi
# Update all Ubuntu software repository lists
apt-get update
cd ~/Desktop
if [ "$LINUX_ARCH" == "x86_64" ]; then
wget -c "$NODE_X64" -O "nodejs.tgz" --no-check-certificate
wget -c "$ANDROID_SDK_X64" -O "android-sdk.tgz" --no-check-certificate
wget -c "$GRADLE_ALL" -O "gradle.zip" --no-check-certificate
tar zxvf "nodejs.tgz" -C "$INSTALL_PATH"
tar zxvf "android-sdk.tgz" -C "$INSTALL_PATH"
unzip "gradle.zip"
mv "gradle-4.10.2-all" "$INSTALL_PATH"
cd "$INSTALL_PATH" && mv "android-sdk-linux" "android-sdk"
cd "$INSTALL_PATH" && mv "node-v8.12.0-linux-x64" "node"
cd "$INSTALL_PATH" && mv "gradle-4.10.2-all" "gradle"
# Android SDK requires some x86 architecture libraries even on x64 system
apt-get install -qq -y libc6:i386 libgcc1:i386 libstdc++6:i386 libz1:i386
else
wget -c "$NODE_X86" -O "nodejs.tgz" --no-check-certificate
wget -c "$ANDROID_SDK_X86" -O "android-sdk.tgz" --no-check-certificate
wget -c "$GRADLE_ALL" -O "gradle.zip" --no-check-certificate
tar zxvf "nodejs.tgz" -C "$INSTALL_PATH"
tar zxvf "android-sdk.tgz" -C "$INSTALL_PATH"
unzip "gradle.zip"
mv "gradle-4.10.2-all" "$INSTALL_PATH"
cd "$INSTALL_PATH" && mv "android-sdk-linux" "android-sdk"
cd "$INSTALL_PATH" && mv "node-v8.12.0-linux-x86" "node"
cd "$INSTALL_PATH" && mv "gradle-4.10.2-all" "gradle"
fi
cd "$INSTALL_PATH" && chown root:root "android-sdk" -R
cd "$INSTALL_PATH" && chmod 777 "android-sdk" -R
cd ~/
# Add Android and NPM paths to the profile to preserve settings on boot
echo "export PATH=\$PATH:$ANDROID_SDK_PATH/tools" >> ".profile"
echo "export PATH=\$PATH:$ANDROID_SDK_PATH/platform-tools" >> ".profile"
echo "export PATH=\$PATH:$NODE_PATH/bin" >> ".profile"
echo "export PATH=\$PATH:$GRADLE_PATH/bin" >> ".profile"
# Add Android and NPM paths to the temporary user path to complete installation
export PATH=$PATH:$ANDROID_SDK_PATH/tools
export PATH=$PATH:$ANDROID_SDK_PATH/platform-tools
export PATH=$PATH:$NODE_PATH/bin
export PATH=$PATH:$GRADLE_PATH/bin
# Install JDK and Apache Ant
apt-get -qq -y install default-jdk ant
# Set JAVA_HOME based on the default OpenJDK installed
export JAVA_HOME="$(find /usr -type l -name 'default-java')"
if [ "$JAVA_HOME" != "" ]; then
echo "export JAVA_HOME=$JAVA_HOME" >> ".profile"
fi
# Install Apache Cordova and Ionic Framework
npm install -g cordova
npm install -g ionic
cd "$INSTALL_PATH" && chmod 777 "node" -R
cd "$INSTALL_PATH" && chmod 777 "gradle" -R
# Clean up any files that were downloaded from the internet
cd ~/Desktop && rm "android-sdk.tgz"
cd ~/Desktop && rm "nodejs.tgz"
cd ~/Desktop && rm "gradle.zip"
echo "----------------------------------"
echo "Restart your Ubuntu session for installation to complete..."