aboutsummaryrefslogtreecommitdiffstats
path: root/element-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'element-desktop')
-rw-r--r--element-desktop/Makefile19
-rw-r--r--element-desktop/bash-aliases42
-rwxr-xr-xelement-desktop/element-desktop4
-rwxr-xr-xelement-desktop/mount-element22
-rwxr-xr-xelement-desktop/umount-element17
5 files changed, 56 insertions, 48 deletions
diff --git a/element-desktop/Makefile b/element-desktop/Makefile
index ce7b6d2..acc013c 100644
--- a/element-desktop/Makefile
+++ b/element-desktop/Makefile
@@ -9,12 +9,19 @@ install:
../check-installed gnupg
../check-installed cryptsetup
../check-installed key2root
- mkdir -p -- ~/.config/bash/aliases.d
- test ! -e ~/.config/bash/aliases.d/element-desktop || \
- test -L ~/.config/bash/aliases.d/element-desktop
- ln -sf -- ~/.dotfiles/element-desktop/bash-aliases ~/.config/bash/aliases.d/element-desktop
+ ../check-installed-shebang mount-element
+ ../check-installed-shebang umount-element
+ ../check-installed-shebang element-desktop
+ mkdir -p -- ~/.local/bin/
+ test ! -e ~/.local/bin/mount-element || test -L ~/.local/bin/mount-element
+ ln -sf -- ~/.dotfiles/element-desktop/mount-element ~/.local/bin/
+ test ! -e ~/.local/bin/umount-element || test -L ~/.local/bin/umount-element
+ ln -sf -- ~/.dotfiles/element-desktop/umount-element ~/.local/bin/
+ test ! -e ~/.local/bin/element-desktop || test -L ~/.local/bin/element-desktop
+ ln -sf -- ~/.dotfiles/element-desktop/element-desktop ~/.local/bin/
uninstall:
+! ../check-installed element-desktop
- -unlink -- ~/.config/bash/aliases.d/element-desktop
- -rmdir -- ~/.config/bash/aliases.d
+ -unlink -- ~/.local/bin/mount-element
+ -unlink -- ~/.local/bin/umount-element
+ -unlink -- ~/.local/bin/element-desktop
diff --git a/element-desktop/bash-aliases b/element-desktop/bash-aliases
deleted file mode 100644
index 1a5362b..0000000
--- a/element-desktop/bash-aliases
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- shell-script -*-
-
-mount-element () {
- if mountpoint -q -- ~/.var/opt/element/ElementCrypt.d; then
- printf '%s\n' 'mount-element: already mounted' >&2
- elif test -e /dev/mapper/ElementCrypt; then
- asroot env ELEMENT_DIR=~/.var/opt/element sh -ec \
- 'mount -- /dev/mapper/ElementCrypt "${ELEMENT_DIR}/ElementCrypt.d"'
- else
- gpg --decrypt ~/.var/opt/element/ElementCrypt.key | \
- key2root -k ElementCrypt env \
- ELEMENT_IMG=~/.var/opt/element/ElementCrypt.img \
- ELEMENT_DIR=~/.var/opt/element \
- ELEMENT_DEV="$(losetup | sed 's/\s\+/ /g' | cut -d ' ' -f 1,6 | \
- sed -n 's#\(/[^ ]*\) '"$(realpath -- ~/.var/opt/element/ElementCrypt.img)"'$#\1#p' | sed 1q)" \
- sh -ec '
- if test -z "${ELEMENT_DEV}"; then
- ELEMENT_DEV="$(losetup --show -f -P "${ELEMENT_IMG}")"
- fi
- cryptsetup -d - open "${ELEMENT_DEV}" ElementCrypt
- mount -- /dev/mapper/ElementCrypt "${ELEMENT_DIR}/ElementCrypt.d"
- '
- fi
-}
-
-umount-element () {
- asroot env \
- ELEMENT_DIR=~/.var/opt/element \
- ELEMENT_DEV="$(losetup | sed 's/\s\+/ /g' | cut -d ' ' -f 1,6 | \
- sed -n 's#\(/[^ ]*\) '"$(realpath -- ~/.var/opt/element/ElementCrypt.img)"'$#\1#p' | sed 1q)" \
- sh -c '
- if mountpoint -q -- "${ELEMENT_DIR}/ElementCrypt.d"; then
- umount -- "${ELEMENT_DIR}/ElementCrypt.d"
- fi
- if test -e /dev/mapper/ElementCrypt; then
- cryptsetup close ElementCrypt
- fi
- if test -n "${ELEMENT_DEV}"; then
- losetup -d "${ELEMENT_DEV}"
- fi
- '
-}
diff --git a/element-desktop/element-desktop b/element-desktop/element-desktop
new file mode 100755
index 0000000..87f1f17
--- /dev/null
+++ b/element-desktop/element-desktop
@@ -0,0 +1,4 @@
+#!/bin/dash
+set -e
+mount-element
+exec /usr/bin/element-desktop "$@"
diff --git a/element-desktop/mount-element b/element-desktop/mount-element
new file mode 100755
index 0000000..1d3c03c
--- /dev/null
+++ b/element-desktop/mount-element
@@ -0,0 +1,22 @@
+#!/bin/dash
+
+if mountpoint -q -- "${HOME}/.var/opt/element/ElementCrypt.d"; then
+ printf '%s\n' 'mount-element: already mounted' >&2
+elif test -e /dev/mapper/ElementCrypt; then
+ asroot env ELEMENT_DIR="${HOME}/.var/opt/element" sh -ec \
+ 'mount -- /dev/mapper/ElementCrypt "${ELEMENT_DIR}/ElementCrypt.d"'
+else
+ gpg --decrypt -- "${HOME}/.var/opt/element/ElementCrypt.key" | \
+ key2root -k ElementCrypt env \
+ ELEMENT_IMG="${HOME}/.var/opt/element/ElementCrypt.img" \
+ ELEMENT_DIR="${HOME}/.var/opt/element" \
+ ELEMENT_DEV="$(losetup | sed 's/\s\+/ /g' | cut -d ' ' -f 1,6 | \
+ sed -n 's#\(/[^ ]*\) '"$(realpath -- "${HOME}/.var/opt/element/ElementCrypt.img")"'$#\1#p' | sed 1q)" \
+ sh -ec '
+ if test -z "${ELEMENT_DEV}"; then
+ ELEMENT_DEV="$(losetup --show -f -P -- "${ELEMENT_IMG}")"
+ fi
+ cryptsetup -d - -- open "${ELEMENT_DEV}" ElementCrypt
+ mount -- /dev/mapper/ElementCrypt "${ELEMENT_DIR}/ElementCrypt.d"
+ '
+fi
diff --git a/element-desktop/umount-element b/element-desktop/umount-element
new file mode 100755
index 0000000..eb9fbdd
--- /dev/null
+++ b/element-desktop/umount-element
@@ -0,0 +1,17 @@
+#!/bin/dash
+
+asroot env \
+ ELEMENT_DIR="${HOME}/.var/opt/element" \
+ ELEMENT_DEV="$(losetup | sed 's/\s\+/ /g' | cut -d ' ' -f 1,6 | \
+ sed -n 's#\(/[^ ]*\) '"$(realpath -- "${HOME}/.var/opt/element/ElementCrypt.img")"'$#\1#p' | sed 1q)" \
+ sh -c '
+ if mountpoint -q -- "${ELEMENT_DIR}/ElementCrypt.d"; then
+ umount -- "${ELEMENT_DIR}/ElementCrypt.d"
+ fi
+ if test -e /dev/mapper/ElementCrypt; then
+ cryptsetup close ElementCrypt
+ fi
+ if test -n "${ELEMENT_DEV}"; then
+ losetup -d -- "${ELEMENT_DEV}"
+ fi
+ '