5 # since we're running with nounset we've to ensure all variables exist
10 ${0} [ -r repository ] [ pull | push | pass-command ]
12 mpass is a thin wrapper around pass to ease working with
15 Before you get started create a configuration file in
16 ${HOME}/.mpass. This fill must contain an associative bash array
17 named "REPO_STORE_DIR[reponame]" to define your repository location.
18 The default repoistory should be named "default" is used when no
19 other repository name is defined with "-r" on the mpass invocation.
22 REPO_STORE_DIR[default]="/home/sven/pass"
23 REPO_STORE_DIR[foo]="/home/sven/pass-foo"
28 pull: executes a "git pull" in the configured REPO_STORE_DIR[reponame]
29 push: executes a "git push" in the configured REPO_STORE_DIR[reponame]
36 # try to source our configuration
37 if [ -f "${HOME}/.mpass" ]; then
38 # declare all known configuration options as an associative array first
39 declare -A REPO_STORE_DIR
42 echo "ERROR: Could not find mpass configuration in ${HOME}/.mpass" >&2
46 # in case no repository is defined, assume it's "default"
47 if [ -z "${repo}" ]; then
51 # define pass repo location
52 # this variable is also used by pass to decide where to operate
53 export PASSWORD_STORE_DIR="${REPO_STORE_DIR[${repo}]}"
55 # check if we actually have something that could be a repository configuraton
56 if [ -z "${PASSWORD_STORE_DIR}" ]; then
57 echo "ERROR: No valid repository configuration found for repo ${repo}" >&2
61 # try to find out if we've a repository at hand, otherwise issue a warning
62 # this could still result in an error, but is perfectly fine on an "init" command
63 if ! [ -d "${PASSWORD_STORE_DIR}" ]; then
64 echo "WARNING: Given pass repo ${PASSWORD_STORE_DIR} does not exist" >&2
68 while getopts ":r:" option; do
75 echo "ERROR: Invalid option: -$OPTARG" >&2
79 echo "ERROR: Option -$OPTARG requires an argument" >&2
91 echo "Trying to update pass repo ${PASSWORD_STORE_DIR}"
92 cd ${PASSWORD_STORE_DIR}
99 echo "Trying to push pass repo ${PASSWORD_STORE_DIR}"
100 cd ${PASSWORD_STORE_DIR}