diff options
-rwxr-xr-x | install | 8 | ||||
-rwxr-xr-x | machine_profiles | 32 |
2 files changed, 40 insertions, 0 deletions
@@ -28,8 +28,16 @@ DOTBOT_DIR="dotbot" DOTBOT_BIN="bin/dotbot" BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +MACHINE_PROFILE_BIN="machine_profiles" + cd "${BASEDIR}" git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive git submodule update --init --recursive "${DOTBOT_DIR}" +echo "Installing global configuration" "${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}" + +for profile in $(${BASEDIR}/${MACHINE_PROFILE_BIN}); do + echo "Installing configuration for profile " $profile + "${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${profile}.conf.yaml" "${@}" +done diff --git a/machine_profiles b/machine_profiles new file mode 100755 index 0000000..eb7b06d --- /dev/null +++ b/machine_profiles @@ -0,0 +1,32 @@ +#!/usr/bin/python3 + +# print a comma-separate list of tags for system + +import socket +import sys + +tags = { + "desktop" : [ + "daenerys", + "shion", + "diziet", + "cirno", + ], +} + +hostname = socket.getfqdn() +if hostname.startswith('localhost'): + # try gethostname, it might sometimes return a real name + # when FQDN is misconfigured + hostname = socket.gethostname() + +if hostname.startswith('localhost'): + sys.stderr.write('System hostname "%s" starts with localhost, ' + 'that is probably wrong\n', hostname) + +for t, systems in tags.items(): + for s in systems: + if (hostname.startswith(s) and + (len(s) == len(hostname) or hostname[len(s)] == '.')): + print(t) + break |