Andrew Grimberg | 78bc6d5 | 2017-10-13 12:55:05 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # vim: ts=4 sw=4 sts=4 et tw=72 : |
| 4 | |
| 5 | # force any errors to cause the script and job to end in failure |
| 6 | set -xeu -o pipefail |
| 7 | |
| 8 | rh_systems() { |
| 9 | echo 'No changes to apply' |
| 10 | } |
| 11 | |
Brian O'Connor | 476369f | 2017-10-18 16:36:33 -0700 | [diff] [blame^] | 12 | ubuntu_install_java_setup() { |
| 13 | DISTRO="xenial" # TODO get this programatically |
| 14 | echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections |
| 15 | echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu $DISTRO main" | \ |
| 16 | tee /etc/apt/sources.list.d/webupd8team-java.list |
| 17 | echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu $DISTRO main" | \ |
| 18 | tee -a /etc/apt/sources.list.d/webupd8team-java.list |
| 19 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 |
| 20 | } |
| 21 | |
Andrew Grimberg | 78bc6d5 | 2017-10-13 12:55:05 -0700 | [diff] [blame] | 22 | ubuntu_systems() { |
| 23 | apt-get clean |
Brian O'Connor | 476369f | 2017-10-18 16:36:33 -0700 | [diff] [blame^] | 24 | ubuntu_install_java_setup |
Andrew Grimberg | 78bc6d5 | 2017-10-13 12:55:05 -0700 | [diff] [blame] | 25 | apt-get update |
Brian O'Connor | 476369f | 2017-10-18 16:36:33 -0700 | [diff] [blame^] | 26 | apt-get install -y \ |
| 27 | bzip2 \ |
| 28 | curl \ |
| 29 | git \ |
| 30 | less \ |
| 31 | oracle-java8-installer \ |
| 32 | oracle-java8-set-default \ |
| 33 | python \ |
| 34 | ssh \ |
| 35 | zip \ |
| 36 | # end of apt-get install list |
| 37 | |
| 38 | #TODO clean up |
| 39 | #apt-get clean |
| 40 | #apt-get purge -y |
| 41 | #apt-get autoremove -y |
| 42 | #rm -rf /var/lib/apt/lists/* |
| 43 | #rm -rf /var/cache/oracle-jdk8-installer |
Andrew Grimberg | 78bc6d5 | 2017-10-13 12:55:05 -0700 | [diff] [blame] | 44 | echo 'No changes to apply' |
| 45 | } |
| 46 | |
| 47 | all_systems() { |
| 48 | echo 'No common distribution configuration to perform' |
| 49 | } |
| 50 | |
| 51 | echo "---> Detecting OS" |
| 52 | ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') |
| 53 | |
| 54 | case "${ORIGIN}" in |
| 55 | fedora|centos|redhat) |
| 56 | echo "---> RH type system detected" |
| 57 | rh_systems |
| 58 | ;; |
| 59 | ubuntu) |
| 60 | echo "---> Ubuntu system detected" |
| 61 | ubuntu_systems |
| 62 | ;; |
| 63 | *) |
| 64 | echo "---> Unknown operating system" |
| 65 | ;; |
| 66 | esac |
| 67 | |
| 68 | # execute steps for all systems |
| 69 | all_systems |