|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright 2022, TeamDev. All rights reserved. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Redistribution and use in source and/or binary forms, with or without |
| 13 | +# modification, must retain the above copyright notice and the following |
| 14 | +# disclaimer. |
| 15 | +# |
| 16 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | +# |
| 28 | + |
| 29 | +# Decrypts a file via `gpg`. |
| 30 | +# |
| 31 | +# Params: |
| 32 | +# 1. The secret passphrase used when encrypting the file. |
| 33 | +# 2. The encrypted file. |
| 34 | +# 3. The path where the decrypted file should go. |
| 35 | +# |
| 36 | + |
| 37 | +if [ "$#" -ne 3 ]; then |
| 38 | + echo "Usage: decrypt.sh <passphrase> <encrypted file> <target file>" |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | + |
| 42 | +gpg --quiet --batch --yes --decrypt --passphrase="$1" --output "$3" "$2" |
0 commit comments