Browse code

Adding support to forked distributions in installer script.

Signed-off-by: Filipe Oliveira <contato@fmoliveira.com.br>

Filipe Oliveira authored on 2015/08/05 09:33:48
Showing 1 changed files
... ...
@@ -51,6 +51,32 @@ echo_docker_as_nonroot() {
51 51
 	EOF
52 52
 }
53 53
 
54
+# Check if this is a forked Linux distro
55
+check_forked() {
56
+	# Check for lsb_release command existence, it usually exists in forked distros
57
+	if command_exists lsb_release; then
58
+		# Check if the `-u` option is supported
59
+		lsb_release -a -u > /dev/null 2>&1
60
+
61
+		# Check if the command has exited successfully, it means we're in a forked distro
62
+		if [ "$?" = "0" ]; then
63
+			# Print info about current distro
64
+			cat <<-EOF
65
+			You're using '$lsb_dist' version '$dist_version'.
66
+			EOF
67
+
68
+			# Get the upstream release info
69
+			lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[[:space:]]')
70
+			dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[[:space:]]')
71
+
72
+			# Print info about upstream distro
73
+			cat <<-EOF
74
+			Upstream release is '$lsb_dist' version '$dist_version'.
75
+			EOF
76
+		fi
77
+	fi
78
+}
79
+
54 80
 do_install() {
55 81
 	case "$(uname -m)" in
56 82
 		*64)
... ...
@@ -187,8 +213,11 @@ do_install() {
187 187
 
188 188
 
189 189
 	esac
190
-		
191 190
 
191
+	# Check if this is a forked Linux distro
192
+	check_forked
193
+
194
+	# Run setup for each distro accordingly
192 195
 	case "$lsb_dist" in
193 196
 		amzn)
194 197
 			(