Skip to content

Instantly share code, notes, and snippets.

@copyninja
Created February 7, 2012 16:24
Show Gist options
  • Save copyninja/1760531 to your computer and use it in GitHub Desktop.
Save copyninja/1760531 to your computer and use it in GitHub Desktop.
Patch for tony
From 41936a98e7429e21edd7a20c7f2718a8dfad91ed Mon Sep 17 00:00:00 2001
From: Vasudev Kamath <[email protected]>
Date: Tue, 7 Feb 2012 21:51:27 +0530
Subject: [PATCH 9/9] Some improvements added like storing user name password
and server to avoid frequent asking
---
frendi.sh | 46 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/frendi.sh b/frendi.sh
index 69319bc..5c94860 100755
--- a/frendi.sh
+++ b/frendi.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+set -x
# update friendika from bash with curl
# I put this in my path as "frendi"
@@ -9,19 +10,54 @@
filedate=$(date +%m%d%y%H%M%S)
-read -p "Please enter your username: " uname
-read -p "Please enter your password: " pwrd
+POSTDIR=~/.fposts
+CONFFILE=~/.frendish.conf
+
+if [ -f $CONFFILE ]; then
+ i=0
+ while read -e line; do
+ value=$(echo $line | cut -d'=' -f2- | tr -d ' ')
+ if [ $i -eq 0 ]; then
+ uname=$value
+ elif [ $i -eq 1 ]; then
+ pwrd=$value
+ else
+ url=$value
+ fi
+
+ i=$(expr $i + 1)
+ done <$CONFFILE
+else
+ read -p "Please enter your username: " uname
+
+ stty -echo
+ read -p "Please enter your password: " pwrd
+ stty echo
+
+ read -p "Enter the domain of your Friendika site (i.e. http://friendika.somesite.net): " url
+
+ cat > ${CONFFILE} <<EOF
+username = $uname
+password = $passwd
+server = $(url)
+EOF
+fi
+
read -p "Cross post to statusnet? (1=yes, 0=no): " snet
read -p "Cross post to twitter? (1=yes, 0=no): " twit
read -p "Cross post to Farcebork? (1=yes, 0=no): " fb
-read -p "Enter the domain of your Friendika site (i.e. http://friendika.somesite.net): " url
+
+
+if [ ! -d $POSTDIR ]; then
+ mkdir -p $POSTDIR
+fi
# if you did not enter text for update, the script asks for it
if [[ $(echo $*) ]]; then
ud="$*"
else
- vim $filedate.fpost
+ ${EDITOR} $filedate.fpost
ud=$(cat $filedate.fpost)
fi
@@ -36,4 +72,4 @@ else
echo "Success!"
echo $ud
fi
-mv $filedate.fpost ~/Documents/fposts/
+mv $filedate.fpost $POSTDIR
--
1.7.8.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment