summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielsLPecke <daniel.letsplay007@gmail.com>2016-11-18 14:53:08 +0100
committerDanielsLPecke <daniel.letsplay007@gmail.com>2016-11-18 14:56:20 +0100
commitd3d849c021fde15eea4d4ff958f7c15ce7106d42 (patch)
tree6ec993869bc1823a51deed97b4f96a817df40cb7
parentd79b6c65cf52185b92a32c85ebd87e4c51b04d40 (diff)
downloadimpressive-display-d3d849c021fde15eea4d4ff958f7c15ce7106d42.tar.gz
impressive-display-d3d849c021fde15eea4d4ff958f7c15ce7106d42.tar.bz2
impressive-display-d3d849c021fde15eea4d4ff958f7c15ce7106d42.zip
Use curl's --netrc-file option rather than its promiscuous -u option.
-rwxr-xr-xbin/impressive-display36
1 files changed, 5 insertions, 31 deletions
diff --git a/bin/impressive-display b/bin/impressive-display
index 803701d..5305575 100755
--- a/bin/impressive-display
+++ b/bin/impressive-display
@@ -35,12 +35,6 @@
VERSION="0.2.990"
-
-# default credentials.
-DEFAULT_PDF_URL_CREDS=""
-# all credentials
-declare -A CREDS
-
# Can be configured at "/etc/default/impressive-display"
# FIXME: use LaTeX Beamer based presentation file that documents impressive-display.
DEFAULT_PDF_URI="file:///usr/share/doc/impressive-display/examples/testpage1.pdf"
@@ -87,11 +81,6 @@ if type -p xrandr 1>/dev/null; then
currentOutput=`echo "$(xrandr)" | grep -w 'connected' | sed -r -e 's/connected.*//' | head -n 1`
fi
-# if files exists: source it to this file (The script will overide variables)
-if [ -r $HOME/.impressive-display-secrets ] && [ ! -d $HOME/.impressive-display-secrets ]; then
- . $HOME/.impressive-display-secrets
-fi
-
if [ -r /etc/default/impressive-display ] && [ ! -d /etc/default/impressive-display ]; then
. /etc/default/impressive-display
fi
@@ -106,11 +95,6 @@ else
OUTPUT="logger -t impressive-display"
fi
-# FIXME: find good regexp for usernames (incl. email addresses)
-if ! echo ${DEFAULT_PDF_URL_CREDS} | grep -q -E '(^$|[-@_a-z0-9A-Z]+:.+)'; then
- $OUTPUT "DEFAULT_PDF_URL_CREDS does not seem to have valid credentials (expected format: <user>:<pw>)."
-fi
-
workdir="$HOME/.impressive-display"
mkdir -p "$workdir"
pdffile_previous="$workdir/impressive-pdffile-previous.pdf"
@@ -172,16 +156,6 @@ else
RESOLUTION="$DEFAULT_RESOLUTION"
fi
-if echo ${!CREDS[@]} | grep -q "$THIS_HOSTNAME"; then
- if echo ${CREDS[$THIS_HOSTNAME]} | grep ":"; then
- PDF_URL_CREDS="${CREDS[$THIS_HOSTNAME]}"
- else
- $OUTPUT "Display host '$THIS_HOSTNAME' does not seem to have valid credentials (expected format: <user>:<pw>)."
- fi
-else
- PDF_URL_CREDS="$DEFAULT_PDF_URL_CREDS"
-fi
-
if [ -n "${RESOLUTION}" ]; then
if type -p xrandr 1>/dev/null; then
xrandr -d :0 --output "$(echo $currentOutput)" --mode $RESOLUTION
@@ -342,12 +316,12 @@ function download_pdffile {
if [ -r "$pdffile_downloaded" ]; then
cp "$pdffile_downloaded" "$pdffile_previous"
fi
- if [ -n "$PDF_URL_CREDS" ]; then
- creds="-u $PDF_URL_CREDS"
- fi
-
+
DOWNLOADED_FILE="$workdir/$(basename $PDF_URI)"
- if ! curl $creds "$PDF_URI" 1> "$DOWNLOADED_FILE"; then
+ if [ -e "$workdir/secrets/$THIS_HOSTNAME.secret" ]; then
+ NETRCFILE=" --netrc-file $workdir/secrets/${THIS_HOSTNAME}.secret"
+ fi
+ if ! curl $NETRCFILE "$PDF_URI" 1> "$DOWNLOADED_FILE"; then
$OUTPUT "The curl tool failed in retrieving PDF file."
fi