From 564263512e6425ae68ef431350edcfde8a3f1075 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 25 Jun 2021 14:33:06 +0200 Subject: Use asroot instead of sudo and add emacs configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- bash/Makefile | 8 +++++++- bash/aliases-Zenith | 23 +++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'bash') diff --git a/bash/Makefile b/bash/Makefile index 7ea782a..e1e62ae 100644 --- a/bash/Makefile +++ b/bash/Makefile @@ -25,7 +25,13 @@ install: ln -sf -- ~/.dotfiles/bash/bashrc_palette ~/.config/bash/bashrc_palette ln -sf -- ~/.dotfiles/bash/bashrc_prompt ~/.config/bash/bashrc_prompt ln -sf -- ~/.dotfiles/bash/aliases ~/.config/bash/aliases - ln -sf -- ~/.dotfiles/bash/aliases-Zenith ~/.config/bash/aliases-Zenith + if test "$$(hostname | tr '[[:upper:]]' '[[:lower:]]')" = zenith; then \ + test "$$(hostname)" = Zenith && \ + pacman -Qq -- asroot /dev/null && \ + pacman -Qq -- gnupg /dev/null && \ + pacman -Qq -- cryptsetup /dev/null && \ + ln -sf -- ~/.dotfiles/bash/aliases-Zenith ~/.config/bash/aliases-Zenith; \ + fi uninstall: -unlink -- ~/.bash_history diff --git a/bash/aliases-Zenith b/bash/aliases-Zenith index ac794c9..419de1d 100644 --- a/bash/aliases-Zenith +++ b/bash/aliases-Zenith @@ -1,17 +1,20 @@ # -*- shell-script -*- mount-crypt () { - sudo printf '' && \ - device="$(sudo losetup --show -f -P /media/Secondary/.crypt/crypt.img)" && \ - printf '%s\n' "${device}" > "${XDG_RUNTIME_DIR}/CryptCrypt" && \ - gpg --decrypt /media/Secondary/.crypt/crypt.key | sudo cryptsetup -d - open "${device}" CryptCrypt && \ - mkdir -p ~/Crypt && \ - sudo mount /dev/mapper/CryptCrypt ~/Crypt + asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" CRYPT_DIR=~/Crypt sh -ec ' + device="$(losetup --show -f -P /media/Secondary/.crypt/crypt.img)" + printf "%s\n" "${device}" > "${XDG_RUNTIME_DIR}/CryptCrypt" + gpg --decrypt /media/Secondary/.crypt/crypt.key | cryptsetup -d - open "${device}" CryptCrypt + mkdir -p "${CRYPT_DIR}" + mount /dev/mapper/CryptCrypt "${CRYPT_DIR}" + ' } umount-crypt () { - sudo umount ~/Crypt - rmdir ~/Crypt - sudo cryptsetup close CryptCrypt - sudo losetup --detach "$(cat -- "${XDG_RUNTIME_DIR}/CryptCrypt")" + asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" CRYPT_DIR=~/Crypt sh -c ' + umount "${CRYPT_DIR}" + rmdir "${CRYPT_DIR}" + cryptsetup close CryptCrypt + losetup --detach "$(cat -- "${XDG_RUNTIME_DIR}/CryptCrypt")" + ' } -- cgit v1.2.3-70-g09d2