Fixed wrong condition to determine direct debit month.
[memberdb.git] / shell / update-puppet.sh
1 #!/bin/bash
2
3 OS=$(/bin/bash /vagrant/shell/os-detect.sh ID)
4 RELEASE=$(/bin/bash /vagrant/shell/os-detect.sh RELEASE)
5 CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME)
6
7 if [[ ! -f /.puphpet-stuff/update-puppet ]]; then
8     if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then
9         echo "Downloading https://github.com/puphpet/apt-puppetlabs-com/raw/master/puppetlabs-release-${CODENAME}.deb"
10         wget --quiet --tries=5 --timeout=10 -O "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" "https://github.com/puphpet/apt-puppetlabs-com/raw/master/puppetlabs-release-${CODENAME}.deb"
11         echo "Finished downloading https://github.com/puphpet/apt-puppetlabs-com/raw/master/puppetlabs-release-${CODENAME}.deb"
12
13         dpkg -i "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" >/dev/null
14
15         echo "Running update-puppet apt-get update"
16         apt-get update >/dev/null
17         echo "Finished running update-puppet apt-get update"
18
19         echo "Updating Puppet to latest version"
20         apt-get -y install puppet >/dev/null
21         PUPPET_VERSION=$(puppet help | grep 'Puppet v')
22         echo "Finished updating puppet to latest version: $PUPPET_VERSION"
23
24         touch /.puphpet-stuff/update-puppet
25         echo "Created empty file /.puphpet-stuff/update-puppet"
26     elif [ "$OS" == 'centos' ]; then
27         echo "Downloading http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm"
28         yum -y --nogpgcheck install "http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm" >/dev/null
29         echo "Finished downloading http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm"
30
31         echo "Running update-puppet yum update"
32         yum -y update >/dev/null
33         echo "Finished running update-puppet yum update"
34
35         echo "Installing/Updating Puppet to latest version"
36         yum -y install puppet >/dev/null
37         PUPPET_VERSION=$(puppet help | grep 'Puppet v')
38         echo "Finished installing/updating puppet to latest version: $PUPPET_VERSION"
39
40         touch /.puphpet-stuff/update-puppet
41         echo "Created empty file /.puphpet-stuff/update-puppet"
42     fi
43 fi