|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2020 Crunchy Data Solutions, Inc. |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +# Get current working directory |
| 17 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 18 | + |
| 19 | +echo "" |
| 20 | +echo "Before running the Postgres Operator upgrade script, please ensure you have already updated and" |
| 21 | +echo "sourced your user's .bashrc file, as well as your \$PGOROOT\\postgres-operator\\pgo.yaml configuration file." |
| 22 | +echo "" |
| 23 | +echo "More information can be found in the \"Default Installation - Configure Environment\" section" |
| 24 | +echo "of the Postgres Operator Bash installation instructions, located here:" |
| 25 | +echo "" |
| 26 | +echo "https://crunchydata.github.io/postgres-operator/stable/installation/operator-install/" |
| 27 | +echo "" |
| 28 | + |
| 29 | +read -n1 -rsp $'Press any key to continue the upgrade or Ctrl+C to exit...\n' |
| 30 | + |
| 31 | +# Remove the current Operator |
| 32 | +$DIR/cleanup.sh |
| 33 | + |
| 34 | +# Set up the defined namespaces for use with the new Operator version |
| 35 | +$DIR/setupnamespaces.sh |
| 36 | + |
| 37 | +# Install the correct RBAC |
| 38 | +$DIR/install-rbac.sh |
| 39 | + |
| 40 | +# Deploy the new Operator |
| 41 | +$DIR/deploy.sh |
| 42 | + |
| 43 | +# Run 'dep ensure' to update needed libraries |
| 44 | +dep ensure |
| 45 | + |
| 46 | +# Store the current location of the PGO client |
| 47 | +MYPGO=`which pgo` |
| 48 | +# Store the expected location of the PGO client |
| 49 | +BASHPGO="${GOBIN}/pgo" |
| 50 | + |
| 51 | +if [ "$MYPGO" != "$BASHPGO" ]; then |
| 52 | + |
| 53 | + echo "Current location\(${MYPG}O\) does not match the expected location \(${BASHPGO}\). You will need to manually install the updated Posgres Operator client in your preferred location." |
| 54 | + |
| 55 | +else |
| 56 | + # install the new PGO client |
| 57 | + go install $PGOROOT/pgo/pgo.go |
| 58 | + cp $GOBIN/pgo $PGOROOT/bin/pgo |
| 59 | +fi |
| 60 | + |
| 61 | +# Final instructions |
| 62 | +NEWLINE=$'\n' |
| 63 | +echo "" |
| 64 | +echo "" |
| 65 | +echo "Postgres Operator upgrade has completed!" |
| 66 | +echo "" |
| 67 | +echo "Please note it may take a few minutes for the deployment to complete," |
| 68 | +echo "" |
| 69 | +echo "and you will need to use the setip function to update your Apiserver URL once the Operator is ready." |
| 70 | +echo "" |
0 commit comments