Skip to content

Commit

Permalink
Add -k commandline option
Browse files Browse the repository at this point in the history
- Allows uploads to ownCloud instances over HTTPS with unsigned
  certificates

Closes #1
  • Loading branch information
florianbeer committed Mar 17, 2016
1 parent de10f59 commit 822548e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Target is you ownCloud WebDAV URL. You can find it by clicking on "Settings" in
```
-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
```
Expand Down
19 changes: 12 additions & 7 deletions mella
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -62,6 +64,9 @@ parse_commandline_arguments() {
v)
VERBOSE="--verbose"
;;
k)
INSECURESSL="--insecure"
;;
V)
printf "Mella Version %s\n" "${VERSION}"
exit 0
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 822548e

Please sign in to comment.