1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Split out processing of alt (past/future)

This commit is contained in:
Tim Byrne
2019-08-16 08:19:11 -05:00
parent 289b8e0c6c
commit c29292d02b
5 changed files with 83 additions and 30 deletions

52
yadm
View File

@@ -135,31 +135,51 @@ function alt() {
require_repo
parse_encrypt
local local_class
local_class="$(config local.class)"
local local_system
local_system="$(config local.os)"
if [ -z "$local_system" ] ; then
local_system="$OPERATING_SYSTEM"
fi
local local_host
local_host="$(config local.hostname)"
if [ -z "$local_host" ] ; then
local_host=$(hostname)
local_host=${local_host%%.*} # trim any domain from hostname
fi
local local_user
local_user="$(config local.user)"
if [ -z "$local_user" ] ; then
local_user=$(id -u -n)
fi
if [ "$YADM_COMPATIBILITY" = "1" ]; then
alt_past
else
alt_future
fi
}
function alt_future() {
# Future alternate processing, not implemented yet
return
}
function alt_past() {
if [ -z "$local_class" ] ; then
match_class="%"
else
match_class="$local_class"
fi
match_class="(%|$match_class)"
local_system="$(config local.os)"
if [ -z "$local_system" ] ; then
local_system="$OPERATING_SYSTEM"
fi
match_system="(%|$local_system)"
local_host="$(config local.hostname)"
if [ -z "$local_host" ] ; then
local_host=$(hostname)
local_host=${local_host%%.*} # trim any domain from hostname
fi
match_host="(%|$local_host)"
local_user="$(config local.user)"
if [ -z "$local_user" ] ; then
local_user=$(id -u -n)
fi
match_user="(%|$local_user)"
# regex for matching "<file>##CLASS.SYSTEM.HOSTNAME.USER"