123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #!/bin/bash
- version=1.1
- scripts_file=$HOME/.config/i3/i3-copy-scripts
- configs_file=$HOME/.config/i3/i3-copy-configs
- copy_scripts()
- {
- if [ ! -f $scripts_file ]; then
- echo "The scrips file does not exist!"
- exit 2
- elif [ -z `sed -n "1p" $scripts_file` ]; then
- echo "The scripts file is empty!"
- exit 2
- else
- line_number=1
- while [ ! -z `sed -n "${line_number}p" $scripts_file` ]; do
- script=`sed -n "${line_number}p" $scripts_file`
- script="${script/#\~/$HOME}"
- echo "Copying $script..."
- if [ ! -f $script ]; then
- echo "The script '$script' does not exist or I cannot find it."
- echo "Aborting."
- exit 2
- fi
- sudo chmod -x $script
- qvm-copy-to-vm $1 $script
- sudo chmod +x $script
- let line_number=line_number+1
- done
- line_number=1
- while [ ! -z `sed -n "${line_number}p" $configs_file` ]; do
- config=`sed -n "${line_number}p" $configs_file`
- config="${config/#\~/$HOME}"
- echo "Copying $config..."
- if [ ! -f $config ]; then
- echo "The configuration file '$config' does not exist or I cannot find it."
- echo "Aborting."
- exit 2
- fi
- qvm-copy-to-vm $1 $config
- let line_number=line_number+1
- done
- fi
- }
- if [[ $# -le 1 ]]; then
- case $1 in
- -v | --version)
- echo "$0 - Version $version"
- exit 0
- ;;
- -h | --help)
- echo "This script is QubesOS specific."
- echo "It copies all the scripts/configuration files specified in a file to a vm of your choice."
- echo "All the inputs must have the format"
- echo "/path/to/script/script"
- echo "There has to be one input per line, whithout empty lines."
- echo "The scripts to copy have to be specified in the file ~./config/i3/i3-copy-scripts."
- echo "The configuration files to copy have to be specified in the file ~./config/i3/i3-copy-configs."
- echo "- v, --version Display current version"
- echo "-h, --help Display this message"
- echo "vmname Copies the scripts to vmname appvm"
- exit 0
- ;;
- *)
- if [ -z ${1} ]; then
- echo "Usage: $0 {-v, --version|-h, --help|up|toggle|down}"
- exit 2
- fi
- if [ ! -d /var/lib/qubes/appvms/${1} ]; then
- echo "The appvm '$1' does not exist."
- echo "Usage: $0 {-v, --version|-h, --help|up|toggle|down}"
- echo "Aborting."
- exit 2
- else
- copy_scripts $1
- fi
- esac
- fi
|