mirror of
https://github.com/gaschz/dotfiles.git
synced 2025-11-02 12:38:59 +01:00
- Standardize capability usage with the terminfo database for portability. POSIX tput does declare only the basic options such as 'init', 'reset' and 'clear', leaving the rest unspecified, that is not ideal but hard coding escape sequences is way worse. - Set colorization options based on number of colors the terminal supports and not the TERM variable when possible. This is incomplete, terminal emulators may support or adapt more than it is advertised, but involves using DECRQSS queries and delays, as an example, 'resize' utility from XTerm uses 3 seconds as delay, this is worrisome. - Term with only '-direct' variants without ending with 256 means it only supports direct-color indexing, therefore 'tmux-direct' cannot be used, but the non-multiplexer terminal 'xterm-direct256' can.
46 lines
1.5 KiB
Bash
Executable File
46 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
##
|
|
## SPDX-FileCopyrightText: 2023 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
##
|
|
## SPDX-License-Identifier: AGPL-3.0-or-later
|
|
##
|
|
## Benefits of this method:
|
|
## - faster than salt, no need for a dispvm.
|
|
## - preserve permissions, salt-ssh doesn't.
|
|
## Disadvantages:
|
|
## - files need be copied to dom0 preserving permissions or setting again.
|
|
##
|
|
## Commands to run:
|
|
## sudo ./qvm-copy-dotfiles QUBE
|
|
set -eu
|
|
|
|
test -n "${1:-}" || { printf '%s\n' "usage: ${0##*/} QUBE"; exit 1; }
|
|
uid="$(id -u)"
|
|
test "${uid}" = "0" || { printf '%s\n' "Program requires root."; exit 1; }
|
|
|
|
qube="${1-}"
|
|
if ! qvm-check -- "${qube}" >/dev/null 2>&1; then
|
|
printf '%s\n' "VM doesn't exist: '${qube}'"
|
|
exit 1
|
|
fi
|
|
test -f ./setup.sh ||
|
|
{ printf '%s\n' "File doesn't exist: './setup.sh'"; exit 1; }
|
|
|
|
if test "${qube}" = "dom0"; then
|
|
sh ./dotfiles/setup.sh
|
|
user="$(getent group qubes | awk -F "[:,]" '{print $4}')"
|
|
home="$(getent passwd "${user}" | awk -F ":" '{print $6}')"
|
|
sudo -u "${user}" mkdir -pv -- "${home}/.cache"
|
|
tmpdir="$(sudo -u "${user}" -- mktemp -d -- "${home}/.cache/XXXXXX")"
|
|
trap 'rm -rf -- "${tmpdir}"' EXIT INT HUP QUIT ABRT
|
|
cp -r -- ./dotfiles "${tmpdir}"
|
|
chown -R -- "${user}:${user}" "${tmpdir}"
|
|
sudo -u "${user}" -- "${tmpdir}/dotfiles/setup.sh"
|
|
exit
|
|
fi
|
|
|
|
qvm-run --no-gui -q -- "${qube}" "rm -rf -- ~/QubesIncoming/dom0/files"
|
|
qvm-copy-to-vm "${qube}" ../files
|
|
qvm-run --no-gui -q -- "${qube}" "sh -- ~/QubesIncoming/dom0/files/setup.sh"
|
|
qvm-run --no-gui -q -- "${qube}" "rm -rf -- ~/QubesIncoming/dom0/files"
|