Last active
November 22, 2016 02:32
-
-
Save geopelia/1b05d43d69dfbf84141ce349992e4259 to your computer and use it in GitHub Desktop.
Lista proyectos que están en determinadas rutas y ejecuta una acción determinada
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
path=/home/pi | |
action=$1 | |
num_folder=$2 | |
project_sufix="/scm/Deploy_EAR/wee" | |
is_folder_exist() { | |
[[ -d $1 ]] && return 0 || return 1 | |
} | |
deploy_file() { | |
location="$path/$1" | |
if (is_folder_exist $location ) then | |
deploy_path="$location$project_sufix" | |
if (is_folder_exist $deploy_path) then | |
cd $deploy_path | |
./scripts.sh | |
else | |
echo "Ruta Invalida de despliege" | |
fi | |
else | |
echo "Ruta Invalida" | |
fi | |
} | |
case $action in | |
-l) ls $path | awk 'BEGIN{count = 0} | |
{count++; print count," -> ", $1}' | |
;; | |
-n) if [[ $num_folder -gt 0 ]]; then | |
folder_name=$(ls $path | awk 'NR==line' line=$num_flder) | |
deploy_file $folder_name | |
else | |
echo "Opcion no valida" | |
fi | |
;; | |
*) if [[ $action != '' ]]; then | |
deploy_file $action | |
else | |
echo "Otra accion" | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment