From b31c474ff062e7a2b202d37ba65c225d15d71009 Mon Sep 17 00:00:00 2001 From: Zergling_man Date: Mon, 19 Jun 2023 00:47:48 +1000 Subject: [PATCH] Can use http without ssl now. I use it internally for my instance. Maybe I'll also allow ignoring specific SSL errors, maybe some passthrough to curl. --- PKGBUILD | 2 +- api.sh | 2 +- clemmy.sh | 4 ++-- creds.sh | 15 ++++++++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 86c043a..8f92151 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ #Well, it seems to work now. pkgname=clemmy -pkgver=0.1.2 +pkgver=0.1.3 pkgrel=1 pkgdesc='A pure bash client for lemmy, with multiaccount support.' arch=('any') diff --git a/api.sh b/api.sh index dfb932c..026ddc2 100644 --- a/api.sh +++ b/api.sh @@ -1,4 +1,4 @@ -baseurl(){ echo "https://$INSTANCE/api/v3/"; } # This needs to be a function so updates to INSTANCE affect it. This is a very old bug lmao +baseurl(){ if [ -z $INSEC ]; then sec=s; fi; echo "http$sec://$INSTANCE/api/v3/"; } # This needs to be a function so updates to INSTANCE affect it. This is a very old bug lmao #Generics get(){ curl -s "$(baseurl)$1?${*:3}" | jq "$2"; } diff --git a/clemmy.sh b/clemmy.sh index eb567b8..e4e71f0 100755 --- a/clemmy.sh +++ b/clemmy.sh @@ -9,10 +9,10 @@ source $imps/creds.sh source $imps/utils.sh while getopts "a:hi:v" o;do case "${o}" in - a) INSTANCE=${insts[$OPTARG]}; TOKE=${tokes[$OPTARG]};; + a) select_account $OPTARG;; i) INSTANCE=$OPTARG;; h) echo $actions; exit;; - v) echo 0.1.2; exit;; + v) echo 0.1.3; exit;; esac done shift $((OPTIND-1)) diff --git a/creds.sh b/creds.sh index fdd94a5..aca1bbd 100644 --- a/creds.sh +++ b/creds.sh @@ -11,11 +11,16 @@ if [ ! -f ~/.config/clemmy/accounts.csv ]; then exit fi -accs=$(cat ~/.config/clemmy/accounts.csv) +accsr=$(cat ~/.config/clemmy/accounts.csv) i=0 -for line in ${accs[*]}; do - IFS=, read insts[$i] tokes[$i] <<< $line +for line in ${accsr[*]}; do + accs[$i]="$line" i=$((i+1)) done -INSTANCE=${insts[0]} -TOKE=${tokes[0]} \ No newline at end of file + +select_account() +{ + IFS=, read INSTANCE TOKE INSEC <<< "${accs[$1]}" +} + +select_account 0 \ No newline at end of file