mirror of
				https://github.com/pelican-eggs/eggs.git
				synced 2025-10-31 08:58:06 +00:00 
			
		
		
		
	Add git cloner script
This commit is contained in:
		
							parent
							
								
									24cbf33c78
								
							
						
					
					
						commit
						8e378d0ce8
					
				
							
								
								
									
										58
									
								
								scripts/git_cloner.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								scripts/git_cloner.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| ## clone git repos | ||||
| ## supports both github and gitlab | ||||
| ## supports using a personal access token to run git pull | ||||
| 
 | ||||
| apt update | ||||
| apt install -y git curl jq file unzip | ||||
| 
 | ||||
| mkdir -p /mnt/server | ||||
| cd /mnt/server | ||||
| 
 | ||||
| if [ "${USER_UPLOAD}" == "true" ] || [ "${USER_UPLOAD}" == "1" ]; then | ||||
|     echo -e "assuming user knows what they are doing have a good day." | ||||
|     exit 0 | ||||
| fi | ||||
| 
 | ||||
| ## add git ending if it's not on the address | ||||
| if [[ ${GIT_ADDRESS} != *.git ]]; then | ||||
|     GIT_ADDRESS=${GIT_ADDRESS}.git | ||||
| fi | ||||
| 
 | ||||
| if [ -z "${USERNAME}" ] && [ -z "${ACCESS_TOKEN}" ]; then | ||||
|     echo -e "using anon api call" | ||||
| else | ||||
|     GIT_ADDRESS="https://${USERNAME}:${ACCESS_TOKEN}@$(echo -e ${GIT_ADDRESS} | cut -d/ -f3-)" | ||||
| fi | ||||
| 
 | ||||
| ## pull git js bot repo | ||||
| if [[ ! "${USERNAME}" == "" ]]; then | ||||
|     if [ "$(ls -A /mnt/server)" ]; then | ||||
|         echo -e "/mnt/server directory is not empty." | ||||
|         if [ -d .git ]; then | ||||
|             echo -e ".git directory exists" | ||||
|             if [ -f .git/config ]; then | ||||
|                 echo -e "loading info from git config" | ||||
|                 ORIGIN=$(git config --get remote.origin.url) | ||||
|             else | ||||
|                 echo -e "files found with no git config" | ||||
|                 echo -e "closing out without touching things to not break anything" | ||||
|                 exit 10 | ||||
|             fi | ||||
|         fi | ||||
| 
 | ||||
|         if [ "${ORIGIN}" == "${GIT_ADDRESS}" ]; then | ||||
|             echo "pulling latest from github" | ||||
|             git pull | ||||
|         fi | ||||
|     else | ||||
|         echo -e "/mnt/server is empty.\ncloning files into repo" | ||||
|         if [ -z ${BRANCH} ]; then | ||||
|             echo -e "cloning default branch" | ||||
|             git clone ${GIT_ADDRESS} . | ||||
|         else | ||||
|             echo -e "cloning ${BRANCH}'" | ||||
|             git clone --single-branch --branch ${BRANCH} ${GIT_ADDRESS} . | ||||
|         fi | ||||
| 
 | ||||
|     fi | ||||
| fi | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user