Add bootstrap command (#42)
This commit is contained in:
parent
3f1a8364ae
commit
e82c4dac4c
1 changed files with 26 additions and 1 deletions
27
yadm
27
yadm
|
@ -28,6 +28,7 @@ YADM_REPO="repo.git"
|
||||||
YADM_CONFIG="config"
|
YADM_CONFIG="config"
|
||||||
YADM_ENCRYPT="encrypt"
|
YADM_ENCRYPT="encrypt"
|
||||||
YADM_ARCHIVE="files.gpg"
|
YADM_ARCHIVE="files.gpg"
|
||||||
|
YADM_BOOTSTRAP="bootstrap"
|
||||||
|
|
||||||
GPG_PROGRAM="gpg"
|
GPG_PROGRAM="gpg"
|
||||||
GIT_PROGRAM="git"
|
GIT_PROGRAM="git"
|
||||||
|
@ -48,7 +49,7 @@ function main() {
|
||||||
|
|
||||||
#; parse command line arguments
|
#; parse command line arguments
|
||||||
local retval=0
|
local retval=0
|
||||||
internal_commands="^(alt|clean|clone|config|decrypt|encrypt|help|init|list|perms|version)$"
|
internal_commands="^(alt|bootstrap|clean|clone|config|decrypt|encrypt|help|init|list|perms|version)$"
|
||||||
if [ -z "$*" ] ; then
|
if [ -z "$*" ] ; then
|
||||||
#; no argumnts will result in help()
|
#; no argumnts will result in help()
|
||||||
help
|
help
|
||||||
|
@ -170,6 +171,15 @@ function alt() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bootstrap() {
|
||||||
|
|
||||||
|
bootstrap_available || error_out "Cannot execute bootstrap\n'$YADM_BOOTSTRAP' is not an executable program."
|
||||||
|
|
||||||
|
echo "Executing $YADM_BOOTSTRAP"
|
||||||
|
exec "$YADM_BOOTSTRAP"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function clean() {
|
function clean() {
|
||||||
|
|
||||||
error_out "\"git clean\" has been disabled for safety. You could end up removing all unmanaged files."
|
error_out "\"git clean\" has been disabled for safety. You could end up removing all unmanaged files."
|
||||||
|
@ -521,6 +531,13 @@ function process_global_args() {
|
||||||
YADM_OVERRIDE_ARCHIVE="$2"
|
YADM_OVERRIDE_ARCHIVE="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--yadm-bootstrap) #; override the standard YADM_BOOTSTRAP
|
||||||
|
if [[ ! "$2" =~ ^/ ]] ; then
|
||||||
|
error_out "You must specify a fully qualified bootstrap path"
|
||||||
|
fi
|
||||||
|
YADM_OVERRIDE_BOOTSTRAP="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*) #; main arguments are kept intact
|
*) #; main arguments are kept intact
|
||||||
MAIN_ARGS+=("$1")
|
MAIN_ARGS+=("$1")
|
||||||
;;
|
;;
|
||||||
|
@ -537,6 +554,7 @@ function configure_paths() {
|
||||||
YADM_CONFIG="$YADM_DIR/$YADM_CONFIG"
|
YADM_CONFIG="$YADM_DIR/$YADM_CONFIG"
|
||||||
YADM_ENCRYPT="$YADM_DIR/$YADM_ENCRYPT"
|
YADM_ENCRYPT="$YADM_DIR/$YADM_ENCRYPT"
|
||||||
YADM_ARCHIVE="$YADM_DIR/$YADM_ARCHIVE"
|
YADM_ARCHIVE="$YADM_DIR/$YADM_ARCHIVE"
|
||||||
|
YADM_BOOTSTRAP="$YADM_DIR/$YADM_BOOTSTRAP"
|
||||||
|
|
||||||
#; independent overrides for paths
|
#; independent overrides for paths
|
||||||
if [ -n "$YADM_OVERRIDE_REPO" ]; then
|
if [ -n "$YADM_OVERRIDE_REPO" ]; then
|
||||||
|
@ -551,6 +569,9 @@ function configure_paths() {
|
||||||
if [ -n "$YADM_OVERRIDE_ARCHIVE" ]; then
|
if [ -n "$YADM_OVERRIDE_ARCHIVE" ]; then
|
||||||
YADM_ARCHIVE="$YADM_OVERRIDE_ARCHIVE"
|
YADM_ARCHIVE="$YADM_OVERRIDE_ARCHIVE"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$YADM_OVERRIDE_BOOTSTRAP" ]; then
|
||||||
|
YADM_BOOTSTRAP="$YADM_OVERRIDE_BOOTSTRAP"
|
||||||
|
fi
|
||||||
|
|
||||||
#; use the yadm repo for all git operations
|
#; use the yadm repo for all git operations
|
||||||
GIT_DIR=$(mixed_path "$YADM_REPO")
|
GIT_DIR=$(mixed_path "$YADM_REPO")
|
||||||
|
@ -661,6 +682,10 @@ function require_ls() {
|
||||||
LS_PROGRAM=ls
|
LS_PROGRAM=ls
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
function bootstrap_available() {
|
||||||
|
[ -f "$YADM_BOOTSTRAP" ] && [ -x "$YADM_BOOTSTRAP" ] && return
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
#; ****** Directory tranlations ******
|
#; ****** Directory tranlations ******
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue