pax_global_header00006660000000000000000000000064126441013050014506gustar00rootroot0000000000000052 comment=10f8833968803483ff2de11d07989b88030239de yadm-1.03/000077500000000000000000000000001264410130500123635ustar00rootroot00000000000000yadm-1.03/CHANGES000066400000000000000000000002771264410130500133640ustar00rootroot000000000000001.03 * Add username matching for alternate files (PR #1) 1.02 * Handle permissions for `~/.gnupg/*gpg` 1.01 * Set `status.showUntrackedFiles` to "no" 1.00 * Initial public release yadm-1.03/CONTRIBUTORS000066400000000000000000000000441264410130500142410ustar00rootroot00000000000000CONTRIBUTORS Tim Byrne Patrick Hof yadm-1.03/LICENSE000066400000000000000000000011711264410130500133700ustar00rootroot00000000000000yadm - Yet Another Dotfiles Manager Copyright (C) 2015 Tim Byrne This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . yadm-1.03/Makefile000066400000000000000000000005611264410130500140250ustar00rootroot00000000000000all: yadm.md contrib yadm.md: yadm.1 @groff -man -Tascii ./yadm.1 | col -bx | sed 's/^[A-Z]/## &/g' | sed '/yadm(1)/d' > yadm.md contrib: @echo "CONTRIBUTORS\n" > CONTRIBUTORS @git shortlog -ns | cut -f2 >> CONTRIBUTORS pdf: @groff -man -Tps ./yadm.1 > yadm.ps @open yadm.ps @sleep 1 @rm yadm.ps man: groff -man -Tascii ./yadm.1 | less wide: man ./yadm.1 yadm-1.03/README.md000066400000000000000000000161131264410130500136440ustar00rootroot00000000000000# yadm - Yet Another Dotfiles Manager _A house that does not have one warm, comfy chair in it is soulless._—May Sarton When you live in a command line, configurations are a deeply personal thing. They are often crafted over years of experience, battles lost, lessons learned, advice followed, and ingenuity rewarded. When you are away from your own configurations, you are an orphaned refugee in unfamiliar and hostile surroundings. You feel clumsy and out of sorts. You are filled with a sense of longing to be back in a place you know. A place you built. A place where all the short-cuts have been worn bare by your own travels. A place you proudly call... `$HOME`. ## Introduction _Home is an invention on which no one has yet improved._—Ann Douglas As so many others, I started out with a repository of dotfiles and a few scripts to symbolically link them around my home directory. This quickly became inadequate and I looked for solutions elsewhere. I've used two excellent tools; [homeschick](https://github.com/andsens/homeshick), and [vcsh](https://github.com/RichiH/vcsh). These tools are great, and you should check them out to understand their strengths. However, I didn't find all of the features I personally wished for in a single tool. **yadm** was written with the following goals: - Use a single repository - Few dependencies - Ability to use alternate files based on OS or host - Ability to encrypt and track confidential files - Stay out of the way and let Git do what it's good at ## Installation _Seek home for rest, for home is best._—Thomas Tusser #### OSX **yadm** can be installed using [Homebrew](https://github.com/Homebrew/homebrew). brew tap TheLocehiliosan/yadm && brew install yadm #### Linux YUM/RPM wget https://bintray.com/thelocehiliosan/rpm/rpm -O bintray-thelocehiliosan-rpm.repo sudo mv bintray-thelocehiliosan-rpm.repo /etc/yum.repos.d/ sudo yum install yadm Or if not using yum, you can just directly download the RPM curl -fLO https://dl.bintray.com/thelocehiliosan/rpm/yadm-1.02-1.noarch.rpm sudo rpm -ivh yadm-1.02-1.noarch.rpm #### Other You *can* simply download the **yadm** script and put it into your `$PATH`. Something like this: curl -fLo /usr/local/bin/yadm https://github.com/TheLocehiliosan/yadm/raw/master/yadm && chmod a+x /usr/local/bin/yadm ## Getting Started _I would not change my blest estate for all the world calls good or great._—Isaac Watts If you know how to use Git, then you already know how to use **yadm**. See the [man page](yadm.md) for a comprehensive explanation of commands and options. #### If you don't currently have a repository Start out with an empty local repository yadm init yadm add yadm commit Eventually you will want to push the local repo to a remote. yadm remote add origin yadm push -u origin master #### If you have an existing remote repository This `clone` will attempt to merge your existing repository, but if it fails, it will do a reset instead and you'll have to decide best on how resolve the differences. yadm clone yadm status ## Strategies for alternate files on different systems _To feel at home, stay at home._—Clifton Fadiman Where possible, you should try to use the same file on every system. Here are a few examples: ### .vimrc let OS=substitute(system('uname -s'),"\n","","") if (OS == "Darwin") " do something that only makes sense on a Mac endif ### .tmux.conf # use reattach-to-user-namespace as the default command on OSX if-shell "test -f /usr/local/bin/reattach-to-user-namespace" 'set -g default-command "reattach-to-user-namespace -l bash"' ### .bash_profile system_type=$(uname -s) if [ "$system_type" = "Darwin" ]; then eval $(gdircolors $HOME/.dir_colors) else eval $(dircolors -b $HOME/.dir_colors) fi However, sometimes the type of file you are using doesn't allow for this type of logic. If a configuration can do an "include", you can include a specific alternate version using **yadm**. Consider these three files: ### .gitconfig #---- .gitconfig ----------------- [log] decorate = short abbrevCommit = true [include] path = .gitconfig.local #---- .gitconfig.local##Darwin --- [user] name = Tim Byrne email = tim@personal.email.org #---- .gitconfig.local##Linux ---- [user] name = Dr. Tim Byrne email = dr.byrne@work.email.com Configuring Git this way includes `.gitconfig.local` in the standard `.gitconfig`. **yadm** will automatically link the correct version based on the operation system. The bulk of your configurations can go in a single file, and you just put the exceptions in OS-specific files. Of course, you can use **yadm** to manage completely separate files for different systems as well. ### .signature #---- .signature## - Tim #---- .signature##Darwin.host1 Sent from my MacBook - Tim #---- .signature##Linux.host2 Sincerely, Dr. Tim Byrne **yadm** will link the appropriate version for the current host, or use the default `##` version. ## Example of managing SSH configurations _We shape our dwellings, and afterwards our dwellings shape us._—Winston Churchill Below is an example of how **yadm** can be used to manage SSH configurations. The example demonstrates **yadm** directly managing the `config` file, managing a host-specific `authorized_keys` file, and storing the private SSH key as part of its encrypted files. This example assumes a typical working SSH configuration exists, and walks through the steps to bring it under **yadm**'s management. yadm add ~/.ssh/config mv ~/.ssh/authorized_keys ~/.ssh/authorized_keys##Linux.myhost yadm add ~/.ssh/authorized_keys##Linux.myhost echo '.ssh/id_rsa' >> ~/.yadm/encrypt yadm add ~/.yadm/encrypt yadm encrypt ------ yadm status Changes to be committed: (use "git rm --cached ..." to unstage) new file: .ssh/authorized_keys##Linux.myhost new file: .ssh/config new file: .yadm/encrypt new file: .yadm/files.gpg ------ ls ~/.ssh authorized_keys -> ~/.ssh/authorized_keys##Linux.myhost authorized_keys##Linux.myhost config rsa_id First, the `config` file is simply added. This will cause the same `config` file to be used on other **yadm** managed hosts. The `authorized_keys` file needs to be host specific, so rename the file using the OS and hostname. After adding the renamed `authorized_keys##Linux.myhost`, **yadm** will automatically create the symlink for it. Last, the private key should be maintained in **yadm**'s encrypted files. Add a pattern to the `.yadm/encrypt` file which matches the private key. Then instruct **yadm** to encrypt all files matching the patterns found in `.yadm/encrypt`. Notice that the **yadm** repository is not tracking the private key directly, rather it tracks the collection of encrypted files `.yadm/files.gpg`. When these changes are brought onto another host, using the `yadm decrypt` command will extract the files stored. yadm-1.03/yadm000077500000000000000000000267131264410130500132540ustar00rootroot00000000000000#!/bin/bash # yadm - Yet Another Dotfiles Manager # Copyright (C) 2015 Tim Byrne # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . VERSION=1.03 YADM_WORK="$HOME" YADM_DIR="$HOME/.yadm" YADM_REPO="$YADM_DIR/repo.git" YADM_CONFIG="$YADM_DIR/config" YADM_ENCRYPT="$YADM_DIR/encrypt" YADM_ARCHIVE="$YADM_DIR/files.gpg" #; flag when something may have changes (which prompts auto actions to be performed) CHANGES_POSSIBLE=0 #; use the yadm repo for all git operations export GIT_DIR="$YADM_REPO" function main() { require_git #; create the YADM_DIR if it doesn't exist yet [ -d "$YADM_DIR" ] || mkdir -p $YADM_DIR #; parse command line arguments internal_commands="^(alt|clean|clone|config|decrypt|encrypt|help|init|list|perms|version)$" if [ -z "$*" ] ; then #; no argumnts will result in help() help elif [ "$1" = "gitconfig" ] ; then #; 'config' is used for yadm, need to use 'gitcofnig' to pass through to git shift git_command config "$@" elif [[ "$1" =~ $internal_commands ]] ; then #; for internal commands, process all of the arguments YADM_COMMAND="$1" YADM_ARGS="" shift while [[ $# > 0 ]] ; do key="$1" case $key in -a) #; used by list() LIST_ALL="YES" ;; -d) #; used by all commands DEBUG="YES" ;; -f) #; used by init() and clone() FORCE="YES" ;; -l) #; used by decrypt() DO_LIST="YES" ;; -w) #; used by init() and clone() if [[ ! "$2" =~ ^/ ]] ; then error_out "You must specify a fully qualified work tree" fi YADM_WORK="$2" shift ;; *) #; any unhandled arguments if [ -z "$YADM_ARGS" ] ; then YADM_ARGS="$1" else YADM_ARGS+=" $1" fi ;; esac shift done [ ! -d $YADM_WORK ] && error_out "Work tree does not exist: [$YADM_WORK]" $YADM_COMMAND "$YADM_ARGS" else #; any other commands are simply passed through to git git_command "$@" fi #; process automatic events auto_alt auto_perms } #; ****** yadm Commands ****** function alt() { require_repo #; regex for matching "##SYSTEM.HOSTNAME.USER" match_system=$(uname -s) match_host=$(hostname -s) match_user=$(id -u -n) match="^(.+)##($match_system|$match_system.$match_host|$match_system.$match_host.$match_user|())$" #; process relative to YADM_WORK YADM_WORK=$(git config core.worktree) cd $YADM_WORK #; only be noisy if the "alt" command was run directly [ "$YADM_COMMAND" = "alt" ] && loud="YES" #; loop over all "tracked" files #; for every file which matches the above regex, create a symlink for tracked_file in $(git ls-files | sort); do tracked_file="$YADM_WORK/$tracked_file" if [ -e "$tracked_file" ] ; then if [[ $tracked_file =~ $match ]] ; then new_link="${BASH_REMATCH[1]}" debug "Linking $tracked_file to $new_link" [ -n "$loud" ] && echo "Linking $tracked_file to $new_link" ln -fs "$tracked_file" "$new_link" fi fi done } function clean() { error_out "\"git clean\" has been disabled for safety. You could end up removing all unmanaged files." } function clone() { #; clone will begin with a bare repo init #; add the specified remote, and configure the repo to track origin/master debug "Adding remote to new repo" git remote add origin "$1" debug "Configuring new repo to track origin/master" git config branch.master.remote origin git config branch.master.merge refs/heads/master #; fetch / merge (and possibly fallback to reset) debug "Doing an initial fetch of the origin" git fetch origin debug "Doing an initial merge of origin/master" git merge origin/master || { debug "Merge failed, doing a reset." git reset origin/master cat </dev/null)) fi done < "$YADM_ENCRYPT" #; encrypt all files which match the globs tar -cv ${GLOBS[@]} | gpg --yes -c --output "$YADM_ARCHIVE" if [ $? = 0 ]; then echo "Wrote new file: $YADM_ARCHIVE" else error_out "Unable to write $YADM_ARCHIVE" fi #; offer to add YADM_ARCHIVE if untracked archive_status=$(git status --porcelain -uall "$YADM_ARCHIVE" 2>/dev/null) archive_regex="^\?\?" if [[ $archive_status =~ $archive_regex ]] ; then echo "It appears that $YADM_ARCHIVE is not tracked by yadm's repository." echo "Would you like to add it now? (y/n)" read answer if [[ $answer =~ ^[yY]$ ]] ; then git add "$YADM_ARCHIVE" fi fi CHANGES_POSSIBLE=1 } function git_command() { require_repo #; pass commands through to git git "$@" CHANGES_POSSIBLE=1 } function help() { cat << EOF Usage: yadm [options...] Manage dotfiles maintained in a Git repository. Manage alternate files for specific systems or hosts. Encrypt/decrypt private files. Git Commands: Any Git command or alias can be used as a . It will operate on yadm's repository and files in the work tree (usually \$HOME). Commands: yadm init [-f] - Initialize an empty repository yadm clone [-f] - Clone an existing repository yadm config - Configure a setting yadm list [-a] - List tracked files yadm alt - Create links for alternates yadm encrypt - Encrypt files yadm decrypt [-l] - Decrypt files yadm perms - Fix perms for private files Files: \$HOME/.yadm/config - yadm's configuration file \$HOME/.yadm/repo.git - yadm's Git repository \$HOME/.yadm/encrypt - List of globs used for encrypt/decrypt \$HOME/.yadm/files.gpg - Encrypted data stored here Use "man yadm" for complete documentation. EOF exit 1 } function init() { #; safety check, don't attempt to init when the repo is already present [ -d "$YADM_REPO" ] && [ -z "$FORCE" ] && \ error_out "Git repo already exist. [$YADM_REPO]\nUse '-f' if you want to force it to be overwritten." #; remove existing if forcing the init to happen anyway [ -d "$YADM_REPO" ] && { debug "Removing existing repo prior to init" rm -rf "$YADM_REPO" } #; init a new bare repo debug "Init new repo" git init --shared=0600 --bare "$YADM_REPO" configure_repo CHANGES_POSSIBLE=1 } function list() { require_repo #; process relative to YADM_WORK when --all is specified if [ -n "$LIST_ALL" ] ; then YADM_WORK=$(git config core.worktree) cd $YADM_WORK fi #; list tracked files git ls-files } function perms() { #; TODO: prevent repeats in the files changed #; process relative to YADM_WORK YADM_WORK=$(git config core.worktree) cd $YADM_WORK GLOBS=() #; include the archive created by "encrypt" [ -f "$YADM_ARCHIVE" ] && GLOBS=("${GLOBS[@]}" "$YADM_ARCHIVE") #; include all .ssh files (unless disabled) if [[ $(config --bool yadm.ssh-perms) != "false" ]] ; then GLOBS=("${GLOBS[@]}" ".ssh" ".ssh/*") fi #; include all gpg files (unless disabled) if [[ $(config --bool yadm.gpg-perms) != "false" ]] ; then GLOBS=("${GLOBS[@]}" ".gnupg" ".gnupg/*") fi #; include globs found in YADM_ENCRYPT (if present) if [ -f "$YADM_ENCRYPT" ] ; then while IFS='' read -r glob || [ -n "$glob" ]; do if [[ ! $glob =~ ^# ]] ; then GLOBS=("${GLOBS[@]}" $(eval /bin/ls "$glob" 2>/dev/null)) fi done < "$YADM_ENCRYPT" fi #; remove group/other permissions from collected globs chmod -f go-rwx ${GLOBS[@]} >/dev/null 2>&1 #; TODO: detect and report changing permissions in a portable way } function version() { echo "yadm $VERSION" exit 0 } #; ****** Utility Functions ****** function configure_repo() { debug "Configuring new repo" #; change bare to false (there is a working directory) git config core.bare 'false' #; set the worktree for the yadm repo git config core.worktree "$YADM_WORK" #; by default, do not show untracked files and directories git config status.showUntrackedFiles no #; possibly used later to ensure we're working on the yadm repo git config yadm.managed 'true' } function debug() { [ -n "$DEBUG" ] && echo -e "DEBUG: $@" } function error_out() { echo -e "ERROR: $@" exit 1 } #; ****** Auto Functions ****** function auto_alt() { #; process alternates if there are possible changes if [ "$CHANGES_POSSIBLE" = "1" ] ; then auto_alt=$(config --bool yadm.auto-alt) if [ "$auto_alt" != "false" ] ; then alt fi fi } function auto_perms() { #; process permissions if there are possible changes if [ "$CHANGES_POSSIBLE" = "1" ] ; then auto_perms=$(config --bool yadm.auto-perms) if [ "$auto_perms" != "false" ] ; then perms fi fi } #; ****** Prerequisites Functions ****** function require_archive() { [ -f "$YADM_ARCHIVE" ] || error_out "$YADM_ARCHIVE does not exist. did you forget to create it?" } function require_encrypt() { [ -f "$YADM_ENCRYPT" ] || error_out "$YADM_ENCRYPT does not exist. did you forget to create it?" } function require_git() { command -v git >/dev/null 2>&1 || \ error_out "This functionality requires Git to be installed, but the command git cannot be located." } function require_gpg() { command -v gpg >/dev/null 2>&1 || \ error_out "This functionality requires GPG to be installed, but the command gpg cannot be located." } function require_repo() { [ -d "$YADM_REPO" ] || error_out "Git repo does not exist. did you forget to run 'init' or 'clone'?" } main "$@" yadm-1.03/yadm.1000066400000000000000000000256541264410130500134130ustar00rootroot00000000000000." vim: set spell so=8: .TH yadm 1 "08 January 2016" "1.03" .SH NAME yadm \- Yet Another Dotfiles Manager .SH SYNOPSIS .B yadm .I command .RI [ options ] .B yadm .I git-command-or-alias .RI [ options ] .B yadm init .RB [ -f ] .RB [ -w .IR directory ] .B yadm .RI clone " url .RB [ -f ] .RB [ -w .IR directory ] .B yadm .RI config " name .RI [ value ] .B yadm config .RB [ -e ] .B yadm list .RB [ -a ] .BR yadm " encrypt .BR yadm " decrypt .RB [ -l ] .BR yadm " alt .BR yadm " perms .SH DESCRIPTION .B yadm is a tool for managing a collection of files across multiple computers, using a shared Git repository. In addition, .B yadm provides a feature to select alternate versions of files based on the operation system or host name. Lastly, .B yadm supplies the ability to manage a subset of secure files, which are encrypted before they are included in the repository. .SH COMMANDS .TP .IR git-command " or " git-alias Any command not internally handled by .B yadm is passed through to .BR git (1). Git commands or aliases are invoked with the .B yadm managed repository. The working directory for git commands will be the configured .IR work-tree " (usually .IR $HOME ). Dotfiles are managed by using standard .B git commands; .IR add , .IR commit , .IR push , .IR pull , etc. .RI The " config command is not passed directly through. Instead use the .I gitconfig command (see below). .TP .B alt Create symbolic links for any managed files matching the naming rules describe in the ALTERNATES section. It is usually unnecessary to run this command, as .B yadm automatically processes alternates by default. This automatic behavior can be disabled by setting the configuration .I yadm.auto-alt to "false". .TP .BI clone " url Clone a remote repository for tracking dotfiles. After the contents of the remote repository have been fetched, a "merge" of .I origin/master is attempted. If there are conflicting files already present in the .IR work-tree , this merge will fail and instead a "reset" of .I origin/master will be done. It is up to the user to resolve these conflicts, but if the desired action is to have the contents in the repository overwrite the existing files, then a "hard reset" should accomplish that: .RS .RS yadm reset --hard origin/master .RE .RE .IP The repository is stored in .IR $HOME/.yadm/repo.git . By default, .I $HOME will be used as the .IR work-tree , but this can be overridden with the .BR -w " option. .B yadm can be forced to overwrite an existing repository by providing the .BR -f " option. .TP .B config This command manages configurations for .BR yadm . This command works exactly they way .BR git-config (1) does. See the CONFIGURATION section for more details. .TP .B decrypt Decrypt all files stored in .IR $HOME/.yadm/files.gpg . Files decrypted will be relative to the configured .IR work-tree " (usually .IR $HOME ). Using the .B -l option will list the files stored without extracting them. .TP .B encrypt Encrypt all files matching the patterns found in .IR $HOME/.yadm/encrypt . See the ENCRYPTION section for more details. .TP .B gitconfig Pass options to the .B git config command. Since .B yadm already uses the .I config command to manage its own configurations, this command is provided as a way to change configurations of the repository managed by .BR yadm . One useful case might be to configure the repository so untracked files are shown in status commands. .B yadm initially configures its repository so that untracked files are not shown. If you wish use the default git behavior (to show untracked files and directories), you can remove this configuration. .RS .RS yadm gitconfig --unset status.showUntrackedFiles .RE .RE .TP .B help Print a summary of .BR yadm " commands. .TP .B init Initialize a new, empty repository for tracking dotfiles. The repository is stored in .IR $HOME/.yadm/repo.git . By default, .I $HOME will be used as the .IR work-tree , but this can be overridden with the .BR -w " option. .B yadm can be forced to overwrite an existing repository by providing the .BR -f " option. .TP .B list Print a list of files managed by .BR yadm . .RB The " -a option will cause all managed files to be listed. Otherwise, the list will only include files from the current directory or below. .TP .B perms Update permissions as described in the PERMISSIONS section. It is usually unnecessary to run this command, as .B yadm automatically processes permissions by default. This automatic behavior can be disabled by setting the configuration .I yadm.auto-perms to "false". .TP .B version Print the version of .BR yadm . .SH CONFIGURATION .B yadm uses a configuration file named .IR $HOME/.yadm/config . This file uses the same format as .BR git-config (1). Also, you can control the contents of the configuration file via the .B yadm config command (which works exactly like .BR git-config ). For example, to disable alternates you can run the command: .RS yadm config yadm.auto-alt false .RE The following is the full list of supported configurations: .TP .B yadm.auto-alt Disable the automatic linking described in the section ALTERNATES. If disabled, you may still run .B yadm alt manually to create the alternate links. This feature is enabled by default. .TP .B yadm.auto-perms Disable the automatic permission changes described in the section PERMISSIONS. If disabled, you may still run .B yadm perms manually to update permissions. This feature is enabled by default. .TP .B yadm.ssh-perms Disable the permission changes to .IR $HOME/.ssh/* . This feature is enabled by default. .TP .B yadm.gpg-perms Disable the permission changes to .IR $HOME/.gnupg/* . This feature is enabled by default. .SH ALTERNATES When managing a set of files across different systems, it can be useful to have an automated way of choosing an alternate version of a file for a different operation system, host, or user. .B yadm implements a feature which will automatically create a symbolic link to the appropriate version of a file, as long as you follow a specific naming convention. .B yadm can detect files with names ending in: .RS .BR ## " or " ##OS " or " ##OS.HOSTNAME " or " ##OS.HOSTNAME.USER .RE If there are any files managed by .BR yadm \'s repository which match this naming convention, symbolic links will be created for the most appropriate version. This may best be demonstrated by example. Assume the following files are managed by .BR yadm \'s repository: - $HOME/path/example.txt## - $HOME/path/example.txt##Darwin - $HOME/path/example.txt##Darwin.host1 - $HOME/path/example.txt##Darwin.host2 - $HOME/path/example.txt##Linux - $HOME/path/example.txt##Linux.host1 - $HOME/path/example.txt##Linux.host2 If running on a Macbook named "host2", .B yadm will create a symbolic link which looks like this: .IR $HOME/path/example.txt " -> " $HOME/path/example.txt##Darwin.host2 However, on another Mackbook named "host3", .B yadm will create a symbolic link which looks like this: .IR $HOME/path/example.txt " -> " $HOME/path/example.txt##Darwin Since the hostname doesn't match any of the managed files, the more generic version is chosen. If running on a Linux server named "host4", the link will be: .IR $HOME/path/example.txt " -> " $HOME/path/example.txt##Linux If running on a Solaris server, the link use the default "##" version: .IR $HOME/path/example.txt " -> " $HOME/path/example.txt## If no "##" version exists and no files match the current OS/HOSTNAME/USER, then no link will be created. OS is determined by running .BR uname\ -s , HOSTNAME by running .BR hostname\ -s , and USER by running .BR id\ -u\ -n . .B yadm will automatically create these links by default. This can be disabled using the .I yadm.auto-alt configuration. Even if disabled, links can be manually created by running .BR yadm\ alt . .SH ENCRYPTION It can be useful to manage confidential files, like SSH or GPG keys, across multiple systems. However, doing so would put plain text data into a Git repository, which often resides on a public system. .B yadm implements a feature which can make it easy to encrypt and decrypt a set of files so the encrypted version can be maintained in the Git repository. This feature will only work if the .BR gpg (1) command is available. To use this feature, a list of patterns must be created and saved as .IR $HOME/.yadm/encrypt . This list of patterns should be relative to the configured .IR work-tree " (usually .IR $HOME ). For example: .RS .ssh/*.key .gnupg/*.gpg .RE The .B yadm encrypt command will find all files matching the patterns, and prompt for a password. Once a password has confirmed, the matching files will be encrypted and saved as .IR $HOME/.yadm/files.gpg . The patterns and files.gpg should be added to the .B yadm repository so they are available across multiple systems. To decrypt these files later, or on another system run .BR yadm\ decrypt and provide the correct password. After files are decrypted, permissions are automatically updated as described in the PERMISSIONS section. .BR NOTE : It is recommended that you use a private repository when keeping confidential files, even though they are encrypted. .SH PERMISSIONS When files are checked out of a Git repository, their initial permissions are dependent upon the user's umask. This can result in confidential files with lax permissions. To prevent this, .B yadm will automatically update the permissions of confidential files. The "group" and "others" permissions will be removed from the following files: .RI - " $HOME/.yadm/files.gpg - All files matching patterns in .I $HOME/.yadm/encrypt - The SSH directory and files, .I .ssh/* - The GPG directory and files, .I .gnupg/* .B yadm will automatically update permissions by default. This can be disabled using the .I yadm.auto-perms configuration. Even if disabled, permissions can be manually updated by running .BR yadm\ perms . The SSH directory processing can be disabled using the .I yadm.ssh-perms configuration. .SH FILES .TP .I $HOME/.yadm/config Configuration file for .BR yadm . .TP .I $HOME/.yadm/repo.git Git repository used by .BR yadm . .TP .I $HOME/.yadm/encrypt List of globs used for encrypt/decrypt .TP .I $HOME/.yadm/files.gpg All files encrypted with .B yadm encrypt are stored in this file. .SH EXAMPLES .TP .B yadm init Create an empty repo for managing files .TP .B yadm add .bash_profile ; yadm commit Add .I .bash_profile to the Git index and create a new commit .TP .B yadm remote add origin Add a remote origin to an existing repository .TP .B yadm push -u origin master Initial push of master to origin .TP .B echo ".ssh/*.key" >> $HOME/.yadm/encrypt Add a new pattern to the list of encrypted files .TP .B yadm encrypt ; yadm add ~/.yadm/files.gpg ; yadm commit Commit a new set of encrypted files .SH REPORTING BUGS Report issues or create pull requests at GitHub: https://github.com/TheLocehiliosan/yadm .SH AUTHOR Tim Byrne .SH SEE ALSO .BR git (1), .BR gpg (1) Other management tools which inspired the creation of .BR yadm : .BR homeshick " .BR vcsh " yadm-1.03/yadm.md000066400000000000000000000305251264410130500136440ustar00rootroot00000000000000 ## NAME yadm - Yet Another Dotfiles Manager ## SYNOPSIS yadm command [options] yadm git-command-or-alias [options] yadm init [-f] [-w directory] yadm clone url [-f] [-w directory] yadm config name [value] yadm config [-e] yadm list [-a] yadm encrypt yadm decrypt [-l] yadm alt yadm perms ## DESCRIPTION yadm is a tool for managing a collection of files across multiple com- puters, using a shared Git repository. In addition, yadm provides a feature to select alternate versions of files based on the operation system or host name. Lastly, yadm supplies the ability to manage a subset of secure files, which are encrypted before they are included in the repository. ## COMMANDS git-command or git-alias Any command not internally handled by yadm is passed through to git(1). Git commands or aliases are invoked with the yadm man- aged repository. The working directory for git commands will be the configured work-tree (usually $HOME). Dotfiles are managed by using standard git commands; add, com- mit, push, pull, etc. The config command is not passed directly through. Instead use the gitconfig command (see below). alt Create symbolic links for any managed files matching the naming rules describe in the ALTERNATES section. It is usually unnec- essary to run this command, as yadm automatically processes alternates by default. This automatic behavior can be disabled by setting the configuration yadm.auto-alt to "false". clone url Clone a remote repository for tracking dotfiles. After the con- tents of the remote repository have been fetched, a "merge" of origin/master is attempted. If there are conflicting files already present in the work-tree, this merge will fail and instead a "reset" of origin/master will be done. It is up to the user to resolve these conflicts, but if the desired action is to have the contents in the repository overwrite the existing files, then a "hard reset" should accomplish that: yadm reset --hard origin/master The repository is stored in $HOME/.yadm/repo.git. By default, $HOME will be used as the work-tree, but this can be overridden with the -w option. yadm can be forced to overwrite an existing repository by providing the -f option. config This command manages configurations for yadm. This command works exactly they way git-config(1) does. See the CONFIGURA- TION section for more details. decrypt Decrypt all files stored in $HOME/.yadm/files.gpg. Files decrypted will be relative to the configured work-tree (usually $HOME). Using the -l option will list the files stored without extracting them. encrypt Encrypt all files matching the patterns found in $HOME/.yadm/encrypt. See the ENCRYPTION section for more details. gitconfig Pass options to the git config command. Since yadm already uses the config command to manage its own configurations, this com- mand is provided as a way to change configurations of the repos- itory managed by yadm. One useful case might be to configure the repository so untracked files are shown in status commands. yadm initially configures its repository so that untracked files are not shown. If you wish use the default git behavior (to show untracked files and directories), you can remove this con- figuration. yadm gitconfig --unset status.showUntrackedFiles help Print a summary of yadm commands. init Initialize a new, empty repository for tracking dotfiles. The repository is stored in $HOME/.yadm/repo.git. By default, $HOME will be used as the work-tree, but this can be overridden with the -w option. yadm can be forced to overwrite an existing repository by providing the -f option. list Print a list of files managed by yadm. The -a option will cause all managed files to be listed. Otherwise, the list will only include files from the current directory or below. perms Update permissions as described in the PERMISSIONS section. It is usually unnecessary to run this command, as yadm automati- cally processes permissions by default. This automatic behavior can be disabled by setting the configuration yadm.auto-perms to "false". version Print the version of yadm. ## CONFIGURATION yadm uses a configuration file named $HOME/.yadm/config. This file uses the same format as git-config(1). Also, you can control the con- tents of the configuration file via the yadm config command (which works exactly like git-config). For example, to disable alternates you can run the command: yadm config yadm.auto-alt false The following is the full list of supported configurations: yadm.auto-alt Disable the automatic linking described in the section ALTER- NATES. If disabled, you may still run yadm alt manually to cre- ate the alternate links. This feature is enabled by default. yadm.auto-perms Disable the automatic permission changes described in the sec- tion PERMISSIONS. If disabled, you may still run yadm perms manually to update permissions. This feature is enabled by default. yadm.ssh-perms Disable the permission changes to $HOME/.ssh/*. This feature is enabled by default. yadm.gpg-perms Disable the permission changes to $HOME/.gnupg/*. This feature is enabled by default. ## ALTERNATES When managing a set of files across different systems, it can be useful to have an automated way of choosing an alternate version of a file for a different operation system, host, or user. yadm implements a feature which will automatically create a symbolic link to the appropriate ver- sion of a file, as long as you follow a specific naming convention. yadm can detect files with names ending in: ## or ##OS or ##OS.HOSTNAME or ##OS.HOSTNAME.USER If there are any files managed by yadm's repository which match this naming convention, symbolic links will be created for the most appro- priate version. This may best be demonstrated by example. Assume the following files are managed by yadm's repository: - $HOME/path/example.txt## - $HOME/path/example.txt##Darwin - $HOME/path/example.txt##Darwin.host1 - $HOME/path/example.txt##Darwin.host2 - $HOME/path/example.txt##Linux - $HOME/path/example.txt##Linux.host1 - $HOME/path/example.txt##Linux.host2 If running on a Macbook named "host2", yadm will create a symbolic link which looks like this: $HOME/path/example.txt -> $HOME/path/example.txt##Darwin.host2 However, on another Mackbook named "host3", yadm will create a symbolic link which looks like this: $HOME/path/example.txt -> $HOME/path/example.txt##Darwin Since the hostname doesn't match any of the managed files, the more generic version is chosen. If running on a Linux server named "host4", the link will be: $HOME/path/example.txt -> $HOME/path/example.txt##Linux If running on a Solaris server, the link use the default "##" version: $HOME/path/example.txt -> $HOME/path/example.txt## If no "##" version exists and no files match the current OS/HOST- NAME/USER, then no link will be created. OS is determined by running uname -s, HOSTNAME by running hostname -s, and USER by running id -u -n. yadm will automatically create these links by default. This can be disabled using the yadm.auto-alt configu- ration. Even if disabled, links can be manually created by running yadm alt. ## ENCRYPTION It can be useful to manage confidential files, like SSH or GPG keys, across multiple systems. However, doing so would put plain text data into a Git repository, which often resides on a public system. yadm implements a feature which can make it easy to encrypt and decrypt a set of files so the encrypted version can be maintained in the Git repository. This feature will only work if the gpg(1) command is available. To use this feature, a list of patterns must be created and saved as $HOME/.yadm/encrypt. This list of patterns should be relative to the configured work-tree (usually $HOME). For example: .ssh/*.key .gnupg/*.gpg The yadm encrypt command will find all files matching the patterns, and prompt for a password. Once a password has confirmed, the matching files will be encrypted and saved as $HOME/.yadm/files.gpg. The pat- terns and files.gpg should be added to the yadm repository so they are available across multiple systems. To decrypt these files later, or on another system run yadm decrypt and provide the correct password. After files are decrypted, permissions are automatically updated as described in the PERMISSIONS section. NOTE: It is recommended that you use a private repository when keeping confidential files, even though they are encrypted. ## PERMISSIONS When files are checked out of a Git repository, their initial permis- sions are dependent upon the user's umask. This can result in confiden- tial files with lax permissions. To prevent this, yadm will automatically update the permissions of con- fidential files. The "group" and "others" permissions will be removed from the following files: - $HOME/.yadm/files.gpg - All files matching patterns in $HOME/.yadm/encrypt - The SSH directory and files, .ssh/* - The GPG directory and files, .gnupg/* yadm will automatically update permissions by default. This can be dis- abled using the yadm.auto-perms configuration. Even if disabled, per- missions can be manually updated by running yadm perms. The SSH direc- tory processing can be disabled using the yadm.ssh-perms configuration. ## FILES $HOME/.yadm/config Configuration file for yadm. $HOME/.yadm/repo.git Git repository used by yadm. $HOME/.yadm/encrypt List of globs used for encrypt/decrypt $HOME/.yadm/files.gpg All files encrypted with yadm encrypt are stored in this file. ## EXAMPLES yadm init Create an empty repo for managing files yadm add .bash_profile ; yadm commit Add .bash_profile to the Git index and create a new commit yadm remote add origin Add a remote origin to an existing repository yadm push -u origin master Initial push of master to origin echo .ssh/*.key >> $HOME/.yadm/encrypt Add a new pattern to the list of encrypted files yadm encrypt ; yadm add ~/.yadm/files.gpg ; yadm commit Commit a new set of encrypted files ## REPORTING BUGS Report issues or create pull requests at GitHub: https://github.com/TheLocehiliosan/yadm ## AUTHOR Tim Byrne ## SEE ALSO git(1), gpg(1) Other management tools which inspired the creation of yadm: homeshick vcsh yadm-1.03/yadm.spec000066400000000000000000000017641264410130500142010ustar00rootroot00000000000000Summary: Yet Another Dotfiles Manager Name: yadm Version: 1.02 Release: 1 URL: https://github.com/TheLocehiliosan/yadm License: GPL Group: Development/Tools Packager: Tim Byrne BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root Requires: bash Requires: git Source0: %{name}-%{version}.tar.gz BuildArch: noarch %description yadm is a dotfile management tool with 3 main features: Manages files across systems using a single Git repository. Provides a way to use alternate files on a specific OS or host. Supplies a method of encrypting confidential data so it can safely be stored in your repository. %prep %setup %build %install rm -rf ${RPM_BUILD_ROOT} mkdir -p ${RPM_BUILD_ROOT}%{_bindir} mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1 install -m 755 yadm ${RPM_BUILD_ROOT}%{_bindir} install -m 644 yadm.1 ${RPM_BUILD_ROOT}%{_mandir}/man1 %clean rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,root) %attr(755,root,root) %{_bindir}/yadm %attr(644,root,root) %{_mandir}/man1/*