88
99
1010CODENAME=$( lsb_release -c -s)
11+
12+ is_core () {
13+ grep -qFx ' ID=ubuntu-core' /etc/os-release
14+ }
15+
16+ is_classic () {
17+ ! is_core
18+ }
19+
20+ is_ubuntu_ge () {
21+ is_classic && compare_ubuntu " ${1:- } " " -ge"
22+ }
23+
24+ compare_ubuntu () {
25+ VERSION=$1
26+ OPERAND=$2
27+
28+ if [ -z " $VERSION " ]; then
29+ echo " os.query: version id is expected"
30+ exit 1
31+ fi
32+
33+ if ! grep -q ' ID=ubuntu' /etc/os-release; then
34+ echo " os.query: comparing non ubuntu system"
35+ return 1
36+ fi
37+
38+ NUM_RE=' ^[0-9]+$'
39+ NUM_VERSION=" $( echo " $VERSION " | tr -d ' ".' ) "
40+ if ! [[ $NUM_VERSION =~ $NUM_RE ]] ; then
41+ echo " os.query: invalid version format \" $VERSION \" provided"
42+ exit 1
43+ fi
44+
45+ SYS_VERSION=" $( grep ' VERSION_ID' /etc/os-release) "
46+ SYS_VERSION=" $( echo " ${SYS_VERSION#* =} " | tr -d ' ".' ) "
47+ if ! [[ $SYS_VERSION =~ $NUM_RE ]] ; then
48+ echo " os.query: invalid version format \" $SYS_VERSION \" retrieved from system"
49+ exit 1
50+ fi
51+
52+ test " $SYS_VERSION " " $OPERAND " " $NUM_VERSION "
53+ }
54+
55+ is_ubuntu_ge_22_04 () {
56+ is_ubuntu_ge " 22.04"
57+ }
58+
1159PY_FLAG=$1
1260
1361IS_TRUSTY () { [ " ${CODENAME} " == " trusty" ]; }
@@ -88,11 +136,7 @@ if [ $is_ansible_right -ne 0 ]; then
88136 do_cmd sudo apt-get -y install wget python python-crypto python-yaml python-httplib2 python-setuptools python-markupsafe python-jinja2 python-paramiko sshpass
89137 do_cmd sudo wget -O /tmp/ansible.deb https://raw.githubusercontent.com/codio/install_software/${BRANCH} /tools/ansible_2.7.5-1ppa_bionic_all.deb
90138 fi
91- if IS_JAMMY; then
92- do_cmd sudo apt update
93- do_cmd sudo apt install -y ansible
94- fi
95- if IS_RESOLUTE; then
139+ if is_ubuntu_ge_22_04; then
96140 do_cmd sudo apt update
97141 do_cmd sudo apt install -y ansible
98142 else
@@ -105,7 +149,7 @@ download_playbook
105149
106150do_cmd sudo apt-get update
107151
108- if USE_PYTHON3 || IS_JAMMY || IS_RESOLUTE ; then
152+ if USE_PYTHON3 || is_ubuntu_ge_22_04 ; then
109153 sudo ansible-playbook -v " ${COOKBOOK_PATH} /install_software-${BRANCH} /$0 /playbook.yaml" -e ' ansible_python_interpreter=/usr/bin/python3'
110154elif IS_TRUSTY; then
111155 sudo ansible-playbook -v " ${COOKBOOK_PATH} /install_software-${BRANCH} /$0 /playbook.yaml"
0 commit comments