mirror of
				https://github.com/gaschz/dotfiles.git
				synced 2025-11-04 05:28:56 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/sh
 | 
						|
##
 | 
						|
## SPDX-FileCopyrightText: 2023 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 permisions, salt-ssh doesnt.
 | 
						|
## 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:-}" || { echo "usage: ${0##*/} QUBE"; exit 1; }
 | 
						|
test "$(id -u)" = "0" || { echo "Program requires root."; exit 1; }
 | 
						|
 | 
						|
vm="$1"
 | 
						|
qvm-check "$vm" >/dev/null 2>&1 || { echo "VM doesn't exist: '$vm'"; exit 1; }
 | 
						|
test -f ./setup.sh || { echo "File doesn't exist: './setup.sh'"; exit 1; }
 | 
						|
 | 
						|
if test "$vm" = "dom0"; then
 | 
						|
  sh ./dotfiles/setup.sh
 | 
						|
  sudo -u user mkdir -pv /home/user/.cache
 | 
						|
  tmpdir="$(sudo -u user mktemp -d /home/user/.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 -q "$vm" -- "rm -rf ~/QubesIncoming/dom0/files"
 | 
						|
qvm-copy-to-vm "$vm" ../files
 | 
						|
qvm-run -q "$vm" -- "sh ~/QubesIncoming/dom0/files/setup.sh"
 | 
						|
qvm-run -q "$vm" -- "rm -rf ~/QubesIncoming/dom0/files"
 |