mirror of
				https://github.com/TheLocehiliosan/yadm
				synced 2025-06-13 13:03:58 +00:00 
			
		
		
		
	Add bootstrap command (#42)
This commit is contained in:
		
							parent
							
								
									3f1a8364ae
								
							
						
					
					
						commit
						e82c4dac4c
					
				
							
								
								
									
										27
									
								
								yadm
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								yadm
									
									
									
									
									
								
							| @ -28,6 +28,7 @@ YADM_REPO="repo.git" | ||||
| YADM_CONFIG="config" | ||||
| YADM_ENCRYPT="encrypt" | ||||
| YADM_ARCHIVE="files.gpg" | ||||
| YADM_BOOTSTRAP="bootstrap" | ||||
| 
 | ||||
| GPG_PROGRAM="gpg" | ||||
| GIT_PROGRAM="git" | ||||
| @ -48,7 +49,7 @@ function main() { | ||||
| 
 | ||||
|   #; parse command line arguments | ||||
|   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 | ||||
|     #; no argumnts will result in 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() { | ||||
| 
 | ||||
|   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" | ||||
|         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_ARGS+=("$1") | ||||
|       ;; | ||||
| @ -537,6 +554,7 @@ function configure_paths() { | ||||
|   YADM_CONFIG="$YADM_DIR/$YADM_CONFIG" | ||||
|   YADM_ENCRYPT="$YADM_DIR/$YADM_ENCRYPT" | ||||
|   YADM_ARCHIVE="$YADM_DIR/$YADM_ARCHIVE" | ||||
|   YADM_BOOTSTRAP="$YADM_DIR/$YADM_BOOTSTRAP" | ||||
| 
 | ||||
|   #; independent overrides for paths | ||||
|   if [ -n "$YADM_OVERRIDE_REPO" ]; then | ||||
| @ -551,6 +569,9 @@ function configure_paths() { | ||||
|   if [ -n "$YADM_OVERRIDE_ARCHIVE" ]; then | ||||
|     YADM_ARCHIVE="$YADM_OVERRIDE_ARCHIVE" | ||||
|   fi | ||||
|   if [ -n "$YADM_OVERRIDE_BOOTSTRAP" ]; then | ||||
|     YADM_BOOTSTRAP="$YADM_OVERRIDE_BOOTSTRAP" | ||||
|   fi | ||||
| 
 | ||||
|   #; use the yadm repo for all git operations | ||||
|   GIT_DIR=$(mixed_path "$YADM_REPO") | ||||
| @ -661,6 +682,10 @@ function require_ls() { | ||||
|     LS_PROGRAM=ls | ||||
|   fi | ||||
| } | ||||
| function bootstrap_available() { | ||||
|   [ -f "$YADM_BOOTSTRAP" ] && [ -x "$YADM_BOOTSTRAP" ] && return | ||||
|   return 1 | ||||
| } | ||||
| 
 | ||||
| #; ****** Directory tranlations ****** | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user