This repository was archived by the owner on Dec 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanageFileCrypto.sh
More file actions
executable file
·63 lines (59 loc) · 1.52 KB
/
manageFileCrypto.sh
File metadata and controls
executable file
·63 lines (59 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
if [[ -n "${GENERATION_DEBUG}" ]]; then set ${GENERATION_DEBUG}; fi
trap 'exit ${RESULT:-1}' EXIT SIGHUP SIGINT SIGTERM
function usage() {
echo -e "\nManage crypto for files"
echo -e "\nUsage: $(basename $0) -f CRYPTO_FILE -e -d -u\n"
echo -e "\nwhere\n"
echo -e "(o) -d if file should be decrypted"
echo -e "(o) -e if file should be encrypted"
echo -e "(o) -f CRYPTO_FILE is the path to the file managed"
echo -e " -h shows this text"
echo -e "(o) -u if file should be updated"
echo -e "\nDEFAULTS:\n"
echo -e "\nNOTES:\n"
echo -e "1. If no operation is provided, the current file contents are displayed"
echo -e ""
exit
}
# Parse options
while getopts ":def:hu" opt; do
case $opt in
d)
export CRYPTO_OPERATION="decrypt"
;;
e)
export CRYPTO_OPERATION="encrypt"
;;
f)
export CRYPTO_FILE="${OPTARG}"
;;
h)
usage
;;
u)
export CRYPTO_UPDATE="true"
;;
\?)
echo -e "\nInvalid option: -${OPTARG}"
usage
;;
:)
echo -e "\nOption -${OPTARG} requires an argument"
usage
;;
esac
done
# Perform the operation required
case $CRYPTO_OPERATION in
encrypt)
${GENERATION_DIR}/manageCrypto.sh -e
;;
decrypt)
${GENERATION_DIR}/manageCrypto.sh -b -d -v
;;
*)
${GENERATION_DIR}/manageCrypto.sh -n
;;
esac
RESULT=$?