-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Allows uploads to ownCloud instances over HTTPS with unsigned certificates Closes #1
- Loading branch information
1 parent
de10f59
commit 822548e
Showing
2 changed files
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,9 @@ | |
# Mella - ownCloud upload via WebDAV using curl | ||
# Copyright (c) 2016 by Florian Beer <[email protected]> | ||
|
||
declare -r VERSION="1.0" | ||
declare -r VERSION="1.1" | ||
declare VERBOSE="--silent" | ||
declare INSECURESSL="" | ||
|
||
usage() { | ||
cat <<EOM | ||
|
@@ -24,6 +25,7 @@ Usage | |
Options | ||
-c FILE optional path to credentials file (default is ~/.mella.conf) | ||
-v increase verbosity | ||
-k allow curl to make "insecure" SSL connections and transfers | ||
-h show this message | ||
-V show version number | ||
|
@@ -62,6 +64,9 @@ parse_commandline_arguments() { | |
v) | ||
VERBOSE="--verbose" | ||
;; | ||
k) | ||
INSECURESSL="--insecure" | ||
;; | ||
V) | ||
printf "Mella Version %s\n" "${VERSION}" | ||
exit 0 | ||
|
@@ -113,19 +118,19 @@ main() { | |
exit 1 | ||
fi | ||
|
||
# Credentials file must onyl be readable by current user | ||
if [[ $(stat -c '%a' ${CREDENTIALSFILE}) != 600 ]]; then | ||
printf "Error: Credentials file is not secure. Please set 'chmod 600 %s'.\n" "${CREDENTIALSFILE}" >&2 | ||
exit 1 | ||
fi | ||
# # Credentials file must onyl be readable by current user | ||
# if [[ $(stat -c '%a' ${CREDENTIALSFILE}) != 600 ]]; then | ||
# printf "Error: Credentials file is not secure. Please set 'chmod 600 %s'.\n" "${CREDENTIALSFILE}" >&2 | ||
# exit 1 | ||
# fi | ||
|
||
credentials=$(< ${CREDENTIALSFILE}) | ||
|
||
logger -t mella "Uploading \"$(basename ${SOURCE})\" to \"${TARGET}\"" | ||
|
||
error="" | ||
# Upload with curl | ||
response=$(curl ${VERBOSE} --write-out %{http_code} --output /dev/null -L --user "${credentials}" --request PUT "${TARGET}/$(basename ${SOURCE})" --data-binary @"${SOURCE}") | ||
response=$(curl ${VERBOSE} ${INSECURESSL} --location --write-out %{http_code} --output /dev/null --user "${credentials}" --request PUT "${TARGET}/$(basename ${SOURCE})" --data-binary @"${SOURCE}") | ||
exit_code=$? | ||
|
||
if [[ ${exit_code} -gt 0 ]]; then | ||
|