Create initial encryption script.

This commit is contained in:
Érico Rolim 2020-10-09 00:25:20 -03:00
parent 2f1a62265c
commit fa759a0c4b
3 changed files with 25 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
cbc-file
get-otp
encrypt-otp

16
encrypt-otp.in Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh
dest="${OTP_ACCOUNTS:-$HOME/.local/share/otp_accounts}"
file="$1"
if [ ! -e "$file" ]; then
echo "'$file' doesn't exist!"
exit 1
fi
if @PREFIX@/libexec/cbc-file lock "$file" > "$dest"; then
echo "'$dest' successfully generated!"
exit 0
else
echo "couldn't create '$dest'"
exit 1
fi

View File

@ -3,11 +3,13 @@ LDLIBS = -lbearssl -largon2
OPT = -O2
CFLAGS = -std=c99 $(OPT) -Wall -Wextra -Werror=implicit -pedantic
SCRIPT = get-otp
SCRIPT = get-otp encrypt-otp
all: $(EXE) $(SCRIPT)
$(SCRIPT): $(SCRIPT).in
get-otp: get-otp.in
encrypt-otp: encrypt-otp.in
%: %.in
sed -e 's|@PREFIX@|$(PREFIX)|' $^ > $@
install: all
@ -15,3 +17,7 @@ install: all
mkdir -p $(DESTDIR)$(PREFIX)/libexec
install -Dm755 cbc-file $(DESTDIR)$(PREFIX)/libexec/
install -Dm755 get-otp $(DESTDIR)$(PREFIX)/bin/
install -Dm755 encrypt-otp $(DESTDIR)$(PREFIX)/bin/
clean:
rm -f $(EXE) $(SCRIPT)