Allow override of OS/Host/User (#21)

This commit is contained in:
Tim Byrne 2017-01-18 19:51:28 -06:00
parent 1534420106
commit 3b4c405d7f
No known key found for this signature in database
GPG Key ID: 6CBE24C2FD8CF76E
1 changed files with 17 additions and 5 deletions

22
yadm
View File

@ -108,14 +108,26 @@ function alt() {
require_repo require_repo
#; regex for matching "<file>##SYSTEM.HOSTNAME.USER" match_system="$(config alt.os)"
match_system=$(uname -s) if [ -z "$match_system" ] ; then
match_system=$(uname -s)
fi
match_system="(%|$match_system)" match_system="(%|$match_system)"
match_host=$(hostname)
match_host=${match_host%%.*} #; trim any domain from hostname match_host="$(config alt.host)"
if [ -z "$match_host" ] ; then
match_host=$(hostname)
match_host=${match_host%%.*} #; trim any domain from hostname
fi
match_host="(%|$match_host)" match_host="(%|$match_host)"
match_user=$(id -u -n)
match_user="$(config alt.user)"
if [ -z "$match_user" ] ; then
match_user=$(id -u -n)
fi
match_user="(%|$match_user)" match_user="(%|$match_user)"
#; regex for matching "<file>##SYSTEM.HOSTNAME.USER"
match="^(.+)##($match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_user|())$" match="^(.+)##($match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_user|())$"
#; process relative to YADM_WORK #; process relative to YADM_WORK