diff --git a/Makefile b/Makefile index 3fd0dfd..40f02a5 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,18 @@ -PREFIX ?= /usr/local - -fmt: - shfmt -p -w rin +include config.mk +clean: + rm -f rin +distclean: clean + rm -f config.mk install: - install -Dm0755 rin ${PREFIX}/bin/rin - install -Dm0600 rin.1 ${PREFIX}/share/man/man1/rin.1 + install -m0755 rin ${DESTDIR}${PREFIX}/bin/rin + install -d ${DESTDIR}${PREFIX}/lib/orin + for i in check clean fetch list profile; do + install -m0755 rin-$$i ${DESTDIR}${PREFIX}/lib/orin/rin-$$i + done + install -m0644 rin.1 ${DESTDIR}${PREFIX}/man/man1/rin.1 uninstall: - rm -f ${PREFIX}/bin/rin - rm -f ${PREFIX}/man/man1/rin.1 - + rm -f ${DESTDIR}${PREFIX}/bin/rin + rm -f ${DESTDIR}${PREFIX}/man/man1/rin.1 + rm -rf ${DESTDIR}${PREFIX}/lib/orin + diff --git a/README b/README index 9d025ea..4654eac 100644 --- a/README +++ b/README @@ -1,10 +1,10 @@ -RIN(1) FreeBSD General Commands Manual RIN(1) +RIN(1) General Commands Manual RIN(1) NAME rin – My personal e-mail assistant, named after Rin Kaenbyou (aka Orin) SYNOPSIS - rin [check] [clean] [fetch] [list] account + rin [check] [clean] [fetch] [list] [profile] account DESCRIPTION It is a script that uses fdm(1) and mblaze(7) adapted to my configuration @@ -22,8 +22,14 @@ USAGE list account List messages on a Maildir + profile --list + List available mblaze profiles + + profile --use account + Use the specified profile + AUTHORS - Izuru Yakumo + Izuru Yakumo -FreeBSD 13.3-RELEASE July 25, 2024 FreeBSD 13.3-RELEASE +NetBSD 10.1 April 21, 2025 NetBSD 10.1 diff --git a/configure b/configure new file mode 100755 index 0000000..df76d84 --- /dev/null +++ b/configure @@ -0,0 +1,80 @@ +#!/bin/sh +# $YakumoLabs$ + +name="rin" +rev=`svn info --show-item revision` + +prefix="/usr/local" +eprefix="${prefix}" +mandir="${prefix}/man" + +check_prog() { + command -v "$@" || echo "not found" ; exit 1 +} + +print_usage() { + cat < rin +echo "PREFIX=${prefix}" > config.mk +echo "MANDIR=${mandir}" >> config.mk diff --git a/rin b/rin deleted file mode 100644 index 4c4d98a..0000000 --- a/rin +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# $TheSupernovaDuo$ -# (o)rin - my personal e-mail assistant in posix shell - -# Source code: -# - https://gitler.moe/novaburst/orin -# - https://git.chaotic.ninja/yakumo.izuru/orin - -# Check for mail in the server -# Arguments: -fn_check() { - fdm -a "$@" poll 2>/dev/null - if [ $? -ne 0 ]; then - echo "ごめんなさい、できませんでした..." - exit 1 - fi -} - -# Clean-up the Maildir directory -# Arguments: -fn_clean() { - find "$@"/cur -type f -print -delete -} -# Fetch e-mails from remote server -# Arguments: -fn_fetch() { - echo "はい、すぐに!" - fdm -a "$@" fetch 2>/dev/null - if [ $? -ne 0 ]; then - echo "ごめんなさい、できませんでした..." - exit 1 - fi -} -# List messages on a Maildir -# Arguments: -fn_list() { - minc -q "$HOME/Mail/$@/INBOX" - mlist -s "$HOME/Mail/$@/INBOX" | msort -dr | mthread -r | mseq -S | mscan -} -# Print an usage note -# Triggered if the assistant is called without any arguments. -fn_usage() { - printf "usage: %s [ check | clean | fetch | list ] \n" "$(basename $0)" -} -case $1 in -check) - fn_check "$2" - ;; -clean) - fn_clean "$2" - ;; -fetch) - fn_fetch "$2" - ;; -list) - fn_list "$2" - ;; -*) - fn_usage - ;; -esac diff --git a/rin-check b/rin-check new file mode 100644 index 0000000..f3cc097 --- /dev/null +++ b/rin-check @@ -0,0 +1,8 @@ +#!/bin/sh +# $YakumoLabs$ +echo "Checking if there is any mail..." +env fdm -a "$@" poll +if [ $? -ne 0 ]; then + echo "Sorry, I couldn't..." + exit 1 +fi diff --git a/rin-clean b/rin-clean new file mode 100644 index 0000000..dd68c8c --- /dev/null +++ b/rin-clean @@ -0,0 +1,23 @@ +#!/bin/sh +# $YakumoLabs$ +# XXX: This command is destructive + +if [ "$1" = "" ]; then + echo "No account specified" + echo "" + echo "usage: $0 account" + exit 1 +else + echo "Do you really want to remove all mail for account: $1? [y/n]" + read answer + case $answer in + [y|Y]) + echo "You asked for it!" + find "${HOME}/Mail/$1/cur" -type f -0 | xargs rm -f -v + ;; + [n|N]) + echo "Aborting operation" + exit 0 + ;; + esac +fi diff --git a/rin-fetch b/rin-fetch new file mode 100644 index 0000000..548e1c2 --- /dev/null +++ b/rin-fetch @@ -0,0 +1,8 @@ +#!/bin/sh +# $YakumoLabs$ +echo "Fetching mail from account: $1 ..." +env fdm -a "$@" fetch +if [ $? -ne 0 ]; then + echo "Sorry, I couldn't..." + exit 1 +fi diff --git a/rin-list b/rin-list new file mode 100644 index 0000000..82e206d --- /dev/null +++ b/rin-list @@ -0,0 +1,4 @@ +#!/bin/sh +# $YakumoLabs$ +env minc -q "$HOME/Mail/$1/INBOX" +env mlist -s "$HOME/Mail/$1/INBOX" | env msort -dr | env mthread -r | env mseq -S | env mscan diff --git a/rin-profile b/rin-profile new file mode 100755 index 0000000..aca7695 --- /dev/null +++ b/rin-profile @@ -0,0 +1,19 @@ +#!/bin/sh +# $YakumoLabs$ +case $1 in + -h|--help) + echo "usage: $0 [-l] [-u profile-name]" + exit 0 + ;; + -l|--list) + echo "List of available profiles" + find "${HOME}/.mblaze" -name "profile-*" -type f + ;; + -u|--use) + echo "Using profile $2" + ln -sf "${HOME}/.mblaze/profile-$2" "${HOME}/.mblaze/profile" + ;; + *) + echo "Unrecognized switch $1" + ;; +esac diff --git a/rin.1 b/rin.1 index 5e75d59..dfd6462 100644 --- a/rin.1 +++ b/rin.1 @@ -1,4 +1,4 @@ -.Dd July 25, 2024 +.Dd April 21, 2025 .Dt RIN 1 .Os .Sh NAME @@ -10,6 +10,7 @@ .Op clean .Op fetch .Op list +.Op profile .Ar account .Sh DESCRIPTION It is a script that uses @@ -27,6 +28,10 @@ Clean up the Maildir directory Fetch mail from the remote server .It list Ar account List messages on a Maildir +.It profile Cm --list +List available mblaze profiles +.It profile Cm --use account +Use the specified profile .El .Sh AUTHORS -.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja +.An Izuru Yakumo Aq Mt eternal-servant@yakumo.dev diff --git a/rin.in b/rin.in new file mode 100644 index 0000000..86879fb --- /dev/null +++ b/rin.in @@ -0,0 +1,32 @@ +#!/bin/sh +# $YakumoLabs$ +# (o)rin -- My personal e-mail assistant from the former Hell of Blazing Fires +# +# Source code: +# - https://svn.yakumo.dev/repo/rin (primary) +# - https://git.yakumo.dev/yakumo.izuru/rin (mirror) +case "$1" in + check) + %%PREFIX%%/lib/orin/rin-check "$2" + ;; + clean) + %%PREFIX%%/lib/orin/rin-clean "$2" + ;; + fetch) + %%PREFIX%%/lib/orin/rin-fetch "$2" + ;; + list) + %%PREFIX%%/lib/orin/rin-list "$2" + ;; + profile) + %%PREFIX%%/lib/orin/rin-profile "$2" "$3" + ;; + *) + cat <