17e40b3c67f7d8396d554859e017a08c618a6a07
- Author
- zertrin <zertrin@gmail.com>
- Committer
- zertrin <zertrin@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.travis.yml b/.travis.yml
2index 7cc5202f0333a32c79a3259a17e8ab3667180e3f..f0044100077f40fc753f2f3da4b84e880748185b 100644
3--- a/.travis.yml
4+++ b/.travis.yml
5@@ -11,7 +11,7 @@ addons:
6 - shellcheck
7
8 script:
9- - shellcheck -e SC2034 -e SC2166 duplicity-backup.sh duplicity-backup.conf.example
10+ - shellcheck -e SC2034 duplicity-backup.sh duplicity-backup.conf.example
11
12 matrix:
13 fast_finish: true
14diff --git a/duplicity-backup.sh b/duplicity-backup.sh
15index fc771a38b992af16d6feb124b2cf690f7611161d..0dba3513923e1381d920f79219549a584a590caa 100755
16--- a/duplicity-backup.sh
17+++ b/duplicity-backup.sh
18@@ -97,7 +97,7 @@ while getopts ":c:t:bfvelsnd-:" opt; do
19 restore)
20 COMMAND=${OPTARG}
21 # We try to find the optional value [restore dest]
22- if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
23+ if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
24 RESTORE_DEST=${!OPTIND}
25 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
26 fi
27@@ -107,28 +107,28 @@ while getopts ":c:t:bfvelsnd-:" opt; do
28 restore-file|restore-dir)
29 COMMAND=${OPTARG}
30 # We try to find the first optional value [file to restore]
31- if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
32+ if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
33 FILE_TO_RESTORE=${!OPTIND}
34 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
35 else
36 continue # no value for the restore-file option, skip the rest
37 fi
38 # We try to find the second optional value [restore dest]
39- if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
40+ if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
41 RESTORE_DEST=${!OPTIND}
42 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
43 fi
44 ;;
45 config) # set the config file from the command line
46 # We try to find the config file
47- if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
48+ if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
49 CONFIG=${!OPTIND}
50 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
51 fi
52 ;;
53 time) # set the restore time from the command line
54 # We try to find the restore time
55- if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
56+ if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
57 TIME=${!OPTIND}
58 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
59 fi
60@@ -167,7 +167,7 @@ while getopts ":c:t:bfvelsnd-:" opt; do
61 done
62
63 # Read config file if specified
64-if [ ! -z "${CONFIG}" -a -f "${CONFIG}" ];
65+if [ ! -z "${CONFIG}" ] && [ -f "${CONFIG}" ];
66 then
67 # shellcheck source=duplicity-backup.conf.example
68 . "${CONFIG}"
69@@ -214,7 +214,7 @@ if [ "${ENCRYPTION}" = "yes" ]; then
70 if [ ! -z "${GPG_ENC_KEY}" ] && [ ! -z "${GPG_SIGN_KEY}" ]; then
71 if [ "${HIDE_KEY_ID}" = "yes" ]; then
72 ENCRYPT="--hidden-encrypt-key=${GPG_ENC_KEY}"
73- if [ "${COMMAND}" != "restore" -a "${COMMAND}" != "restore-file" -a "${COMMAND}" != "restore-dir" ]; then
74+ if [ "${COMMAND}" != "restore" ] && [ "${COMMAND}" != "restore-file" ] && [ "${COMMAND}" != "restore-dir" ]; then
75 ENCRYPT="${ENCRYPT} --sign-key=${GPG_SIGN_KEY}"
76 fi
77 else
78@@ -270,10 +270,10 @@ if [ "$(echo "${DEST}" | cut -c 1,2)" = "s3" ]; then
79 S3CMD="$(which s3cmd)"
80 if [ ! -x "${S3CMD}" ]; then
81 echo "${NO_S3CMD}"; S3CMD_AVAIL=false
82- elif [ -z "${S3CMD_CONF_FILE}" -a ! -f "${HOME}/.s3cfg" ]; then
83+ elif [ -z "${S3CMD_CONF_FILE}" ] && [ ! -f "${HOME}/.s3cfg" ]; then
84 S3CMD_CONF_FOUND=false
85 echo "${NO_S3CMD_CFG}"; S3CMD_AVAIL=false
86- elif [ ! -z "${S3CMD_CONF_FILE}" -a ! -f "${S3CMD_CONF_FILE}" ]; then
87+ elif [ ! -z "${S3CMD_CONF_FILE}" ] && [ ! -f "${S3CMD_CONF_FILE}" ]; then
88 S3CMD_CONF_FOUND=false
89 echo "${S3CMD_CONF_FILE} not found, check S3CMD_CONF_FILE variable in duplicity-backup's configuration!";
90 echo "${NO_S3CMD_CFG}";
91@@ -281,7 +281,7 @@ if [ "$(echo "${DEST}" | cut -c 1,2)" = "s3" ]; then
92 else
93 S3CMD_AVAIL=true
94 S3CMD_CONF_FOUND=true
95- if [ ! -z "${S3CMD_CONF_FILE}" -a -f "${S3CMD_CONF_FILE}" ]; then
96+ if [ ! -z "${S3CMD_CONF_FILE}" ] && [ -f "${S3CMD_CONF_FILE}" ]; then
97 # if conf file specified and it exists then add it to the command line for s3cmd
98 S3CMD="${S3CMD} -c ${S3CMD_CONF_FILE}"
99 fi
100@@ -654,7 +654,7 @@ duplicity_cleanup_failed()
101
102 setup_passphrase()
103 {
104- if [ ! -z "${GPG_ENC_KEY}" -a ! -z "${GPG_SIGN_KEY}" -a "${GPG_ENC_KEY}" != "${GPG_SIGN_KEY}" ]; then
105+ if [ ! -z "${GPG_ENC_KEY}" ] && [ ! -z "${GPG_SIGN_KEY}" ] && [ "${GPG_ENC_KEY}" != "${GPG_SIGN_KEY}" ]; then
106 echo -n "Please provide the passphrase for decryption (GPG key 0x${GPG_ENC_KEY}): "
107 builtin read -s -r ENCPASSPHRASE
108 echo -ne "\n"
109@@ -702,7 +702,7 @@ backup_this_script()
110 echo "You are backing up: "
111 echo " 1. ${SCRIPTPATH}"
112
113- if [ ! -z "${GPG_ENC_KEY}" -a ! -z "${GPG_SIGN_KEY}" ]; then
114+ if [ ! -z "${GPG_ENC_KEY}" ] && [ ! -z "${GPG_SIGN_KEY}" ]; then
115 if [ "${GPG_ENC_KEY}" = "${GPG_SIGN_KEY}" ]; then
116 echo " 2. GPG Secret encryption and sign key: ${GPG_ENC_KEY}"
117 else