commit 9b1f11e2b463e79e0c3544df90618f0d3cac8e94
parent f4ea634b23873a3dad66bce87a8fd126c1428c7f
Author: parazyd <parazyd@dyne.org>
Date: Sat, 3 Mar 2018 16:58:15 +0100
Remove rplib. It's not really needed anymore.
Diffstat:
12 files changed, 116 insertions(+), 110 deletions(-)
diff --git a/Makefile b/Makefile
@@ -48,7 +48,7 @@ install: all
sed "s,SHAREPREFIX,$(SHAREPREFIX),g" < bin/rpinit > $(DESTDIR)$(PREFIX)/bin/rpinit
chmod 755 $(DESTDIR)$(PREFIX)/bin/rpinit
mkdir -p $(DESTDIR)$(SHAREPREFIX)
- cp -r rplib mutt misc $(DESTDIR)$(SHAREPREFIX)
+ cp -r mutt misc $(DESTDIR)$(SHAREPREFIX)
uninstall:
cd bin; \
diff --git a/bin/rpabook b/bin/rpabook
@@ -1,14 +1,15 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
-. "$HOME"/.rp/rplib/common.sh
ab="$profile/whitelist.abook"
usage() {
- edie "usage: $(basename $0) [-a] [-c]
- -a: add to abook
- -c: completion (used from mutt)"
+ printf " * usage: $(basename $0) [-a] [-c]\n"
+ printf "\t-a: add to abook\n"
+ printf "\t-c: completion (used from mutt)\n"
+ exit 1
}
for i in $@; do
@@ -17,7 +18,7 @@ for i in $@; do
email="$(cat)"
addr="$(echo $email | rpheaders From | cut -d'<' -f2 | tr -d '<>')"
grep -q "^email=$addr" "$ab" && {
- einfo "address already in abook"
+ echo " * address already in abook"
exit 0
}
echo "$email" | abook --datafile "$ab" --add-email-quiet
diff --git a/bin/rpcomp b/bin/rpcomp
@@ -1,7 +1,7 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
-. "$HOME"/.rp/rplib/common.sh
content_head="Content-Type: text/plain; charset=\"utf-8\""
diff --git a/bin/rpgenc b/bin/rpgenc
@@ -1,5 +1,7 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
+
boundary="$(rputil -e genmimeb)"
email="$(cat)"
diff --git a/bin/rpgsign b/bin/rpgsign
@@ -1,5 +1,7 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
+
boundary="$(rputil -e genmimeb)"
email="$(cat)"
diff --git a/bin/rpinit b/bin/rpinit
@@ -2,10 +2,8 @@
shareprefix="SHAREPREFIX"
-. "$shareprefix"/rplib/common.sh
-
setupmutt() {
- einfo "copying mutt files"
+ echo " * copying mutt files"
mkdir -p "$HOME/.rp/$1/mutt"
touch "$HOME/.rp/$1/mutt/muttpass"
for i in $(ls -1 $shareprefix/mutt); do
@@ -14,8 +12,8 @@ setupmutt() {
}
usage() {
- einfo "usage: $(basename $0) [-u profilename]"
- einfo " -u: update"
+ printf " * usage: $(basename $0) [-u profilename]\n"
+ printf "\t-u: update\n"
exit 1
}
@@ -32,8 +30,8 @@ usage() {
esac
}
-einfo "Welcome to rp!"
-einfo "Let's start initializing your rp setup."
+echo " * Welcome to rp!"
+echo " * Let's start initializing your rp setup."
mkdir -p ~/.rp && cd ~/.rp || exit 1
@@ -44,58 +42,58 @@ echo
[ -L default ] || ln -s "$profile" default
-einfo "Now the configuration begins."
+echo " * Now the configuration begins."
echo
-einfo "Enter the string value that should appear in your From: headers."
-einfo " An example is: Luther Blisset <luther@bliss.et>"
+echo " * Enter the string value that should appear in your From: headers."
+echo " An example is: Luther Blisset <luther@bliss.et>"
printf " * from = "
read -r from || exit 1
echo
-einfo "Please enter the network spec of your remote imap server."
+echo "Please enter the network spec of your remote imap server."
echo
-einfo "Network specifications are for example:"
-einfo " tcp!mail.example.com!imap"
-einfo " tcp!mail.example.com!143"
+echo "Network specifications are for example:"
+echo " tcp!mail.example.com!imap"
+echo " tcp!mail.example.com!143"
echo
-einfo "For a direct TLS connection:"
-einfo " tcps!mail.example.com!imaps"
-einfo " tcps!mail.example.com!993"
+echo "For a direct TLS connection:"
+echo " tcps!mail.example.com!imaps"
+echo " tcps!mail.example.com!993"
printf " * remote imap netspec = "
read -r rnet || exit 1
echo
-einfo "Please enter your remote imap username."
+echo "Please enter your remote imap username."
printf " * remote imap username = "
read -r ruser || exit 1
echo
-einfo "Please enter your remote imap password."
+echo "Please enter your remote imap password."
printf " * remote imap password = "
read -r rpass || exit 1
echo
-einfo "Please enter the network spec of your local imap server."
+echo "Please enter the network spec of your local imap server."
echo
-einfo "Network specifications are for example:"
-einfo " tcp!localhost!imap"
-einfo " tcp!localhost!143"
+echo "Network specifications are for example:"
+echo " tcp!localhost!imap"
+echo " tcp!localhost!143"
echo
-einfo "For a direct TLS connection:"
-einfo " tcps!localhost!imaps"
-einfo " tcps!localhost!993"
+echo "For a direct TLS connection:"
+echo " tcps!localhost!imaps"
+echo " tcps!localhost!993"
printf " * local imap netspec = "
read -r lnet || exit 1
echo
-einfo "Please enter the username for your local imap server."
+echo "Please enter the username for your local imap server."
printf " * local imap username = "
read -r luser || exit 1
echo
-einfo "Please enter the password for your local imap server."
+echo "Please enter the password for your local imap server."
printf " * local imap password = "
read -r lpass || exit 1
echo
@@ -166,12 +164,6 @@ touch "$profile/whitelist.abook"
mkdir -p "$profile/tmp/mutt_hcache"
-ln -snf "$shareprefix/rplib" "./rplib"
-
-git init
-git add .
-git commit -m "rpinit"
-
-einfo "All done setting up rp!"
-einfo "Your profile files are in ~/.rp/$profile"
-einfo "Have fun!"
+echo "All done setting up rp!"
+echo "Your profile files are in ~/.rp/$profile"
+echo "Have fun!"
diff --git a/bin/rppeek b/bin/rppeek
@@ -1,10 +1,11 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
-. "$HOME"/.rp/rplib/common.sh
usage() {
- edie "usage: $(basename $0) [folder]"
+ printf " * usage: $(basename $0) [folder]\n"
+ exit 1
}
for i in $@; do
@@ -14,15 +15,9 @@ for i in $@; do
;;
*)
folder="-f =${i}"
- einfo "requested folder '$i'"
+ echo " * requested folder '$i'"
;;
esac
done
-einfo "starting up mutt"
neomutt -F $profile/muttrc $folder
-
-case $? in
- 0) einfo "mutt exited successfully";;
- *) edie "mutt didn't exit with 0 status";;
-esac
diff --git a/bin/rpqueue b/bin/rpqueue
@@ -1,10 +1,11 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
mkdir -p "$profile/tmp/outbox"
email="$(cat)"
-fname="$(printf "$email" | rpheaders Message-ID | tr -d '<>')"
+fname="$(echo "$email" | rpheaders Message-ID | tr -d '<>')"
-printf "%s\n" "$email" > "$profile/tmp/outbox/$fname"
+echo "%s" "$email" > "$profile/tmp/outbox/$fname"
diff --git a/bin/rpsend b/bin/rpsend
@@ -1,13 +1,14 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
-. "$HOME"/.rp/rplib/common.sh
usage() {
- edie "usage: $(basename $0) [-n] [-l] [-a] < email
- -n: dry run
- -l: list outbox
- -a: send all"
+ printf " * usage: $(basename $0) [-n] [-l] [-a] < email\n"
+ printf "\t-n: dry run\n"
+ printf "\t-l: list outbox\n"
+ printf "\t-a: send all\n"
+ exit 1
}
listoutbox() { find "$profile"/tmp/outbox -type f ; }
@@ -24,7 +25,7 @@ for i in $@; do
exit 0
;;
-a)
- einfo "sending all available emails"
+ echo " * sending all queued emails"
for i in $(rpsend -l); do
rpsend < "$i" && { [ -z "$dryrun" ] && rm -f "$i" ; }
done
@@ -43,23 +44,26 @@ rimap="$(echo $rnet | cut -d'!' -f2)"
ruser="$(rpheaders ruser < $profile/config)"
echo >&2
-einfo "smtp send via $rimap"
+echo " * smtp send via $rimap"
if ! [ -f "$profile/smtp-fingerprint" ]; then
- einfo "no saved tls certificate fingerprint found. going with tofu."
+ echo " * no saved tls certificate fingerprint found. going with tofu."
rputil -e getfpr "$rnet" > "$profile"/smtp-fingerprint
fi
known="$(cat $profile/smtp-fingerprint)"
served="$(rputil -e getfpr "$rnet")"
-einfo "known fingerprint: $known"
-einfo "served fingerprint: $served"
+echo
+echo " * known fingerprint: $known"
+echo " * served fingerprint: $served"
+echo
if [ "$known" != "$served" ]; then
- ewarn "server fingerprint mismatch!"
- ewarn "the known one is different, this may be mitm"
- edie "to trust the new one, edit or delete $profile/smtp-fingerprint"
+ echo " * server fingerprint mismatch!"
+ echo " * the known one is different, this may be mitm"
+ echo " * to trust the new one, edit or delete $profile/smtp-fingerprint"
+ exit 1
fi
@@ -80,10 +84,12 @@ EOF
_subj="$(printf "$email" | rpheaders Subject)"
_dest="$(printf "$email" | rpheaders To)"
-einfo "sending using msmtp"
-einfo "subject: $_subj"
-einfo "to: $_dest"
-einfo "sending $(rputil -e humansize $(printf "$email\n" | wc -c)) over the network"
+echo " * sending using msmtp"
+echo
+echo " * subject: $_subj"
+echo " * to: $_dest"
+echo
+echo " * sending $(rputil -e humansize $(printf "$email\n" | wc -c)) over the network"
printf "$email\n" | \
@@ -94,8 +100,12 @@ _e=$?
rm -f "$msmtpcfg"
case "$_e" in
- 0) einfo "email sent successfully";;
- *) edie "msmtp failed";;
+ 0)
+ echo " * email sent successfully"
+ ;;
+ *)
+ echo " * msmtp failed"
+ exit $_e;;
esac
# if successful, place into Sent
diff --git a/bin/rpsieve b/bin/rpsieve
@@ -1,18 +1,19 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
-. "$profile"/../rplib/common.sh
usage() {
- edie "usage: $(basename $0) [-e] [-u]
- -e: edit filters.txt before continuing
- -u: upload filters.sieve when done"
+ printf " * usage: $(basename $0) [-e] [-u]\n"
+ printf "\t-e: edit filters.txt before continuing\n"
+ printf "\t-u: upload filters.sieve when done\n"
+ exit 1
}
for i in $@; do
case "$i" in
-e)
- edit=true
+ ed=true
;;
-u)
upload=true
@@ -27,9 +28,16 @@ ft="$profile/filters.txt"
fs="$profile/filters.sieve"
ab="$profile/whitelist.abook"
-[ -n "$edit" ] && { vim "$ft" || edie "$(basename $0) canceled"; }
-[ -f "$ft" ] || edie "no filters.txt file"
-[ -f "$ab" ] || edie "no whitelist.abook file"
+[ -n "$et" ] && vim "$ft"
+
+[ -f "$ft" ] || {
+ echo " * no filters.txt file"
+ exit 1
+}
+[ -f "$ab" ] || {
+ echo " * no whitelist.abook file"
+ exit 1
+}
cat <<EOF > "$fs"
# mailbox supports fileinto :create
@@ -56,8 +64,11 @@ fileinto :create "unsorted";
EOF
if [ -n "$upload" ]; then
- einfo "uploading filters.sieve"
+ echo " * uploading filters.sieve"
host=t3.dyne.org
path=/var/vmail/sieve-scripts/"$(readlink $profile)"
- scp "$fs" "$host:$path" || edie "upload failed"
+ scp "$fs" "$host:$path" || {
+ echo " * upload failed"
+ exit 1
+ }
fi
diff --git a/bin/rpsync b/bin/rpsync
@@ -1,12 +1,13 @@
#!/bin/sh
+export PATH="/usr/local/bin:/usr/bin:/bin"
profile="${RPPROFILE:-$HOME/.rp/default}"
-. "$HOME"/.rp/rplib/common.sh
usage() {
- edie "usage: $(basename $0) [-n] [-d]
- -n: dry run
- -d: delete remote emails"
+ printf " * usage: $(basename $0) [-n] [-d]\n"
+ printf "\t-n: dry run\n"
+ printf "\t-d: delete remote emails\n"
+ exit 1
}
@@ -47,11 +48,13 @@ echo "$lpass" > "$profile/tmp/limap"
rhost="$(echo "$rnet" | cut -d'!' -f2)"
lhost="$(echo "$lnet" | cut -d'!' -f2)"
-nc -w 1 "$rhost" "$rport" || edie "$rhost unreachable"
+nc -w 1 "$rhost" "$rport" || {
+ echo " * $rhost unreachable"
+ exit 1
+}
-einfo "starting imapsync"
-[ -n "$delete" ] && ewarn "remote deletion enabled"
-[ -n "$dryrun" ] && ewarn "dry run enabled"
+[ -n "$delete" ] && echo " * remote deletion enabled"
+[ -n "$dryrun" ] && echo " * dry run enabled"
imapsync \
--tmpdir "$profile/tmp" \
@@ -71,6 +74,11 @@ _e=$?
rm -f "$profile/tmp/rimap" "$profile/tmp/limap"
case "$_e" in
- 0) einfo "synced successfully";;
- *) edie "error while syncing";;
+ 0)
+ echo " * synced successfully"
+ ;;
+ *)
+ echo " * error while syncing"
+ exit $_e
+ ;;
esac
diff --git a/rplib/common.sh b/rplib/common.sh
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-export PATH="/usr/local/bin:/usr/bin:/bin"
-
-einfo() {
- printf "$(tput setaf 2)$(tput bold) * $(tput sgr0)%s\n" "$*" >&2
-}
-
-ewarn() {
- printf "$(tput setaf 3)$(tput bold) * $(tput sgr0)%s\n" "$*" >&2
-}
-
-edie() {
- printf "$(tput setaf 1)$(tput bold) * $(tput sgr0)%s\n" "$*" >&2
- exit 1
-}