Add k8s and agent options #1
@ -3,6 +3,7 @@
 | 
				
			|||||||
set -eu
 | 
					set -eu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR=/home/oscarzhou/source/github.com/portainer
 | 
					WORKDIR=/home/oscarzhou/source/github.com/portainer
 | 
				
			||||||
 | 
					GLOBAL_VOLUME=/home/oscarzhou/volumes
 | 
				
			||||||
TRUE=0;
 | 
					TRUE=0;
 | 
				
			||||||
FALSE=1;
 | 
					FALSE=1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -13,7 +14,7 @@ ERROR_COLOR='\033[0;31m';
 | 
				
			|||||||
HIGHLIGHT_COLOR='\033[0;32m';
 | 
					HIGHLIGHT_COLOR='\033[0;32m';
 | 
				
			||||||
NO_COLOR='\033[0m';
 | 
					NO_COLOR='\033[0m';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function is_ce_project() {
 | 
					function choose_repo() {
 | 
				
			||||||
    read -p "Choose the working project EE/(CE):" REPO
 | 
					    read -p "Choose the working project EE/(CE):" REPO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [ -z "$REPO" ]; then 
 | 
					    if [ -z "$REPO" ]; then 
 | 
				
			||||||
@ -21,10 +22,10 @@ function is_ce_project() {
 | 
				
			|||||||
    fi 
 | 
					    fi 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ "${REPO}" == "ee" || "${REPO}" == "EE" ]]; then 
 | 
					    if [[ "${REPO}" == "ee" || "${REPO}" == "EE" ]]; then 
 | 
				
			||||||
        return $FALSE;
 | 
					        cd ${WORKDIR}/portainer-ee
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elif [[ "${REPO}" == "ce" || "${REPO}" == "CE" ]]; then 
 | 
					    elif [[ "${REPO}" == "ce" || "${REPO}" == "CE" ]]; then 
 | 
				
			||||||
        return $TRUE;
 | 
					        cd ${WORKDIR}/portainer
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -49,20 +50,41 @@ function check_branch() {
 | 
				
			|||||||
    return $TRUE;
 | 
					    return $TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function export_volume() {
 | 
					function choose_export_volume() {
 | 
				
			||||||
    local VOLUME=~/volumes/portainer-ee-data
 | 
					    read -p "Choose the volume EE/CE/Temp-data(TD):" DEST
 | 
				
			||||||
    if is_ce_project; then 
 | 
					
 | 
				
			||||||
        VOLUME=~/volumes/portainer-ce-data
 | 
					    if [ -z "$DEST" ]; then 
 | 
				
			||||||
        cd ${WORKDIR}/portainer
 | 
					        DEST="EE";
 | 
				
			||||||
 | 
					    fi 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [[ "${DEST}" == "ee" || "${DEST}" == "EE" ]]; then 
 | 
				
			||||||
 | 
					        VOLUME=~/volumes/portainer-ee-data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elif [[ "${DEST}" == "ce" || "${DEST}" == "CE" ]]; then 
 | 
				
			||||||
 | 
					        VOLUME=~/volumes/portainer-ce-data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elif [[ "${DEST}" == "td" || "${DEST}" == "TD" ]]; then 
 | 
				
			||||||
 | 
					        VOLUME=~/volumes/temp-data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    else 
 | 
					 | 
				
			||||||
        cd ${WORKDIR}/portainer-ee
 | 
					 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    export PORTAINER_DATA=${VOLUME}
 | 
					    export PORTAINER_DATA=${VOLUME}
 | 
				
			||||||
    printf "${HIGHLIGHT_COLOR}export PORTAINER_DATA=${PORTAINER_DATA}${NO_COLOR}\n"
 | 
					    printf "${HIGHLIGHT_COLOR}export PORTAINER_DATA=${PORTAINER_DATA}${NO_COLOR}\n"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function prepare_temporary_volume() {
 | 
				
			||||||
 | 
					    printf "${HIGHLIGHT_COLOR}Prepare temporary data${NO_COLOR}\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    local VOLUME=~/volumes/temp-data
 | 
				
			||||||
 | 
					    if [ -d ${VOLUME} ]; then 
 | 
				
			||||||
 | 
					        read -p "Do you want to clean up the existing data N/(Y)?" CLEAN_DATA
 | 
				
			||||||
 | 
					        if [[ "${CLEAN_DATA}" == "y" || "${CLEAN_DATA}" == "Y" ]]; then 
 | 
				
			||||||
 | 
					            rm -rvf ${VOLUME}/*
 | 
				
			||||||
 | 
					        fi 
 | 
				
			||||||
 | 
					    else 
 | 
				
			||||||
 | 
					        mkdir ${VOLUME}
 | 
				
			||||||
 | 
					    fi 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function build_portainer_frontend_without_prompt() {
 | 
					function build_portainer_frontend_without_prompt() {
 | 
				
			||||||
    printf "${HIGHLIGHT_COLOR}Build Portainer Frontend${NO_COLOR}\n"
 | 
					    printf "${HIGHLIGHT_COLOR}Build Portainer Frontend${NO_COLOR}\n"
 | 
				
			||||||
@ -81,7 +103,7 @@ function build_portainer_backend_without_prompt() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function build_portainer_frontend() {
 | 
					function build_portainer_frontend() {
 | 
				
			||||||
    export_volume
 | 
					    choose_repo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ! check_branch; then 
 | 
					    if ! check_branch; then 
 | 
				
			||||||
        exit;
 | 
					        exit;
 | 
				
			||||||
@ -92,7 +114,9 @@ function build_portainer_frontend() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function build_portainer_backend() {
 | 
					function build_portainer_backend() {
 | 
				
			||||||
    export_volume
 | 
					    choose_repo 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    choose_export_volume
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ! check_branch; then 
 | 
					    if ! check_branch; then 
 | 
				
			||||||
        exit;
 | 
					        exit;
 | 
				
			||||||
@ -104,7 +128,9 @@ function build_portainer_backend() {
 | 
				
			|||||||
function build_portainer_all() {
 | 
					function build_portainer_all() {
 | 
				
			||||||
    printf "${HIGHLIGHT_COLOR}Build Portainer all${NO_COLOR}\n"
 | 
					    printf "${HIGHLIGHT_COLOR}Build Portainer all${NO_COLOR}\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    export_volume
 | 
					    choose_repo 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    choose_export_volume
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ! check_branch; then 
 | 
					    if ! check_branch; then 
 | 
				
			||||||
        exit;
 | 
					        exit;
 | 
				
			||||||
@ -118,11 +144,7 @@ function build_portainer_all() {
 | 
				
			|||||||
function run_before_commit() {
 | 
					function run_before_commit() {
 | 
				
			||||||
    printf "${HIGHLIGHT_COLOR}Run before commit${NO_COLOR}\n"
 | 
					    printf "${HIGHLIGHT_COLOR}Run before commit${NO_COLOR}\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if is_ce_project; then 
 | 
					    choose_repo 
 | 
				
			||||||
        cd ${WORKDIR}/portainer
 | 
					 | 
				
			||||||
    else 
 | 
					 | 
				
			||||||
        cd ${WORKDIR}/portainer-ee
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ! check_branch; then 
 | 
					    if ! check_branch; then 
 | 
				
			||||||
        exit;
 | 
					        exit;
 | 
				
			||||||
@ -135,8 +157,6 @@ function run_before_commit() {
 | 
				
			|||||||
    yarn lint
 | 
					    yarn lint
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function menu() {
 | 
					function menu() {
 | 
				
			||||||
    PS3='Please select the option: '
 | 
					    PS3='Please select the option: '
 | 
				
			||||||
    OPTIONS=(
 | 
					    OPTIONS=(
 | 
				
			||||||
@ -144,6 +164,7 @@ function menu() {
 | 
				
			|||||||
        'Build Portainer Frontend'
 | 
					        'Build Portainer Frontend'
 | 
				
			||||||
        'Build Portainer Backend'
 | 
					        'Build Portainer Backend'
 | 
				
			||||||
        'Run Before Commit'
 | 
					        'Run Before Commit'
 | 
				
			||||||
 | 
					        'Prepare Temporary Volume'
 | 
				
			||||||
        'Quit'
 | 
					        'Quit'
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -162,6 +183,9 @@ function menu() {
 | 
				
			|||||||
            'Run Before Commit')
 | 
					            'Run Before Commit')
 | 
				
			||||||
                run_before_commit
 | 
					                run_before_commit
 | 
				
			||||||
                ;;
 | 
					                ;;
 | 
				
			||||||
 | 
					            'Prepare Temporary Volume')
 | 
				
			||||||
 | 
					                prepare_temporary_volume 
 | 
				
			||||||
 | 
					                ;;
 | 
				
			||||||
            'Quit')
 | 
					            'Quit')
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
                ;;
 | 
					                ;;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user